Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(264)

Side by Side Diff: content/browser/ssl/ssl_manager.cc

Issue 1368863002: Set SSL info when an HTTP auth dialog is triggered by direct navigation. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Respond to creis' comments on the other CL. Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/browser/ssl/ssl_manager.h" 5 #include "content/browser/ssl/ssl_manager.h"
6 6
7 #include <set> 7 #include <set>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/strings/utf_string_conversions.h" 10 #include "base/strings/utf_string_conversions.h"
11 #include "base/supports_user_data.h" 11 #include "base/supports_user_data.h"
12 #include "content/browser/frame_host/navigation_entry_impl.h" 12 #include "content/browser/frame_host/navigation_entry_impl.h"
13 #include "content/browser/loader/resource_dispatcher_host_impl.h" 13 #include "content/browser/loader/resource_dispatcher_host_impl.h"
14 #include "content/browser/loader/resource_request_info_impl.h" 14 #include "content/browser/loader/resource_request_info_impl.h"
15 #include "content/browser/ssl/ssl_cert_error_handler.h" 15 #include "content/browser/ssl/ssl_cert_error_handler.h"
16 #include "content/browser/ssl/ssl_policy.h" 16 #include "content/browser/ssl/ssl_policy.h"
17 #include "content/browser/ssl/ssl_request_info.h" 17 #include "content/browser/ssl/ssl_request_info.h"
18 #include "content/browser/web_contents/web_contents_impl.h" 18 #include "content/browser/web_contents/web_contents_impl.h"
19 #include "content/common/ssl_status_serialization.h" 19 #include "content/common/ssl_status_serialization.h"
20 #include "content/public/browser/browser_context.h" 20 #include "content/public/browser/browser_context.h"
21 #include "content/public/browser/browser_thread.h" 21 #include "content/public/browser/browser_thread.h"
22 #include "content/public/browser/load_from_memory_cache_details.h" 22 #include "content/public/browser/load_from_memory_cache_details.h"
23 #include "content/public/browser/navigation_details.h" 23 #include "content/public/browser/navigation_details.h"
24 #include "content/public/browser/navigation_entry.h"
24 #include "content/public/browser/resource_request_details.h" 25 #include "content/public/browser/resource_request_details.h"
25 #include "content/public/common/ssl_status.h" 26 #include "content/public/common/ssl_status.h"
26 #include "net/url_request/url_request.h" 27 #include "net/url_request/url_request.h"
27 28
28 namespace content { 29 namespace content {
29 30
30 namespace { 31 namespace {
31 32
32 const char kSSLManagerKeyName[] = "content_ssl_manager"; 33 const char kSSLManagerKeyName[] = "content_ssl_manager";
33 34
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 new SSLCertErrorHandler(delegate, 73 new SSLCertErrorHandler(delegate,
73 resource_type, 74 resource_type,
74 url, 75 url,
75 render_process_id, 76 render_process_id,
76 render_frame_id, 77 render_frame_id,
77 ssl_info, 78 ssl_info,
78 fatal))); 79 fatal)));
79 } 80 }
80 81
81 // static 82 // static
83 void SSLManager::OnAuthDialog(int render_process_id,
84 int render_frame_id,
85 const SSLStatus& ssl_status,
86 bool is_main_frame) {
87 DCHECK_CURRENTLY_ON(BrowserThread::IO);
88 BrowserThread::PostTask(
89 BrowserThread::UI, FROM_HERE,
90 base::Bind(SSLManager::OnAuthDialogOnUI, render_process_id,
91 render_frame_id, ssl_status, is_main_frame));
92 }
93
94 // static
95 void SSLManager::OnAuthDialogOnUI(int render_process_id,
96 int render_frame_id,
97 const SSLStatus& ssl_status,
98 bool is_main_frame) {
99 DCHECK_CURRENTLY_ON(BrowserThread::UI);
100 RenderFrameHost* render_frame_host =
101 RenderFrameHostImpl::FromID(render_process_id, render_frame_id);
102 WebContents* web_contents =
103 WebContents::FromRenderFrameHost(render_frame_host);
104 if (!web_contents)
105 return;
106 NavigationControllerImpl* controller =
107 static_cast<NavigationControllerImpl*>(&web_contents->GetController());
108 // TODO(palmer, creis, meacer): If you've just done a PostTask to get here,
109 // then there's no guarantee that the pending entry still exists or is for the
110 // same navigation. (It may have been discarded or replaced with a different
111 // one in the meantime.) Ensure this is safe.
112 NavigationEntryImpl* entry = controller->GetPendingEntry();
113 controller->ssl_manager()->UpdateEntry(ssl_status, is_main_frame, entry);
114 }
115
116 // static
82 void SSLManager::NotifySSLInternalStateChanged(BrowserContext* context) { 117 void SSLManager::NotifySSLInternalStateChanged(BrowserContext* context) {
83 SSLManagerSet* managers = static_cast<SSLManagerSet*>( 118 SSLManagerSet* managers = static_cast<SSLManagerSet*>(
84 context->GetUserData(kSSLManagerKeyName)); 119 context->GetUserData(kSSLManagerKeyName));
85 120
86 for (std::set<SSLManager*>::iterator i = managers->get().begin(); 121 for (std::set<SSLManager*>::iterator i = managers->get().begin();
87 i != managers->get().end(); ++i) { 122 i != managers->get().end(); ++i) {
88 (*i)->UpdateEntry((*i)->controller()->GetLastCommittedEntry()); 123 (*i)->UpdateEntry((*i)->controller()->GetLastCommittedEntry());
89 } 124 }
90 } 125 }
91 126
(...skipping 13 matching lines...) Expand all
105 } 140 }
106 141
107 SSLManager::~SSLManager() { 142 SSLManager::~SSLManager() {
108 SSLManagerSet* managers = static_cast<SSLManagerSet*>( 143 SSLManagerSet* managers = static_cast<SSLManagerSet*>(
109 controller_->GetBrowserContext()->GetUserData(kSSLManagerKeyName)); 144 controller_->GetBrowserContext()->GetUserData(kSSLManagerKeyName));
110 managers->get().erase(this); 145 managers->get().erase(this);
111 } 146 }
112 147
113 void SSLManager::DidCommitProvisionalLoad(const LoadCommittedDetails& details) { 148 void SSLManager::DidCommitProvisionalLoad(const LoadCommittedDetails& details) {
114 NavigationEntryImpl* entry = controller_->GetLastCommittedEntry(); 149 NavigationEntryImpl* entry = controller_->GetLastCommittedEntry();
150 UpdateEntry(details.ssl_status, details.is_main_frame, entry);
151 }
115 152
116 if (details.is_main_frame) { 153 void SSLManager::UpdateEntry(const SSLStatus& ssl_status,
117 if (entry) { 154 bool is_main_frame,
118 // We may not have an entry if this is a navigation to an initial blank 155 NavigationEntryImpl* entry) {
119 // page. Add the new data we have. 156 if (is_main_frame && entry) {
120 entry->GetSSL() = details.ssl_status; 157 // We may not have an entry if this is a navigation to an initial blank
121 } 158 // page. Reset the SSL information and add the new data we have.
159 entry->GetSSL() = SSLStatus();
160 entry->GetSSL().cert_id = ssl_status.cert_id;
161 entry->GetSSL().cert_status = ssl_status.cert_status;
162 entry->GetSSL().security_bits = ssl_status.security_bits;
163 entry->GetSSL().connection_status = ssl_status.connection_status;
164 entry->GetSSL().signed_certificate_timestamp_ids =
165 ssl_status.signed_certificate_timestamp_ids;
meacer 2015/09/29 00:17:02 estark added a constructor for SSLStatus, this can
palmer 2015/09/29 00:46:36 How shall we get the SecurityStyle argument?
meacer 2015/09/29 00:48:51 You can copy directly from ssl_status.security_sty
palmer 2015/09/29 00:56:46 Ah, right. But, now we are missing the SSLInfo...
122 } 166 }
123 167
124 policy()->UpdateEntry(entry, controller_->delegate()->GetWebContents()); 168 policy()->UpdateEntry(entry, controller_->delegate()->GetWebContents());
125 // Always notify the WebContents that the SSL state changed when a 169 // Always notify the WebContents that the SSL state changed when a
126 // load is committed, in case the active navigation entry has changed. 170 // load is committed, in case the active navigation entry has changed.
127 NotifyDidChangeVisibleSSLState(); 171 NotifyDidChangeVisibleSSLState();
128 } 172 }
129 173
130 void SSLManager::DidDisplayInsecureContent() { 174 void SSLManager::DidDisplayInsecureContent() {
131 UpdateEntry(controller_->GetLastCommittedEntry()); 175 UpdateEntry(controller_->GetLastCommittedEntry());
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
193 NotifyDidChangeVisibleSSLState(); 237 NotifyDidChangeVisibleSSLState();
194 } 238 }
195 239
196 void SSLManager::NotifyDidChangeVisibleSSLState() { 240 void SSLManager::NotifyDidChangeVisibleSSLState() {
197 WebContentsImpl* contents = 241 WebContentsImpl* contents =
198 static_cast<WebContentsImpl*>(controller_->delegate()->GetWebContents()); 242 static_cast<WebContentsImpl*>(controller_->delegate()->GetWebContents());
199 contents->DidChangeVisibleSSLState(); 243 contents->DidChangeVisibleSSLState();
200 } 244 }
201 245
202 } // namespace content 246 } // namespace content
OLDNEW
« content/browser/loader/resource_loader.cc ('K') | « content/browser/ssl/ssl_manager.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698