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

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: Fill in the rest of entry->GetSSL(). 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 BrowserThread::PostTask(
88 BrowserThread::UI, FROM_HERE,
89 base::Bind(SSLManager::OnAuthDialogOnUI, render_process_id,
90 render_frame_id, ssl_status, is_main_frame));
91 }
92
93 // static
94 void SSLManager::OnAuthDialogOnUI(int render_process_id,
95 int render_frame_id,
96 const SSLStatus& ssl_status,
97 bool is_main_frame) {
98 DCHECK_CURRENTLY_ON(BrowserThread::UI);
99 RenderFrameHost* render_frame_host =
100 RenderFrameHostImpl::FromID(render_process_id, render_frame_id);
101 WebContents* web_contents =
102 WebContents::FromRenderFrameHost(render_frame_host);
103 if (!web_contents)
104 return;
105 NavigationControllerImpl* controller =
106 static_cast<NavigationControllerImpl*>(&web_contents->GetController());
107 // TODO(palmer, creis, meacer): If you've just done a PostTask to get here,
108 // then there's no guarantee that the pending entry still exists or is for the
109 // same navigation. (It may have been discarded or replaced with a different
110 // one in the meantime.) Ensure this is safe.
Charlie Reis 2015/09/29 22:52:11 Same concerns. I don't know how to make this safe
111 NavigationEntryImpl* entry = controller->GetPendingEntry();
112 controller->ssl_manager()->UpdateEntry(ssl_status, is_main_frame, entry);
113 }
114
115 // static
82 void SSLManager::NotifySSLInternalStateChanged(BrowserContext* context) { 116 void SSLManager::NotifySSLInternalStateChanged(BrowserContext* context) {
83 SSLManagerSet* managers = static_cast<SSLManagerSet*>( 117 SSLManagerSet* managers = static_cast<SSLManagerSet*>(
84 context->GetUserData(kSSLManagerKeyName)); 118 context->GetUserData(kSSLManagerKeyName));
85 119
86 for (std::set<SSLManager*>::iterator i = managers->get().begin(); 120 for (std::set<SSLManager*>::iterator i = managers->get().begin();
87 i != managers->get().end(); ++i) { 121 i != managers->get().end(); ++i) {
88 (*i)->UpdateEntry((*i)->controller()->GetLastCommittedEntry()); 122 (*i)->UpdateEntry((*i)->controller()->GetLastCommittedEntry());
89 } 123 }
90 } 124 }
91 125
(...skipping 13 matching lines...) Expand all
105 } 139 }
106 140
107 SSLManager::~SSLManager() { 141 SSLManager::~SSLManager() {
108 SSLManagerSet* managers = static_cast<SSLManagerSet*>( 142 SSLManagerSet* managers = static_cast<SSLManagerSet*>(
109 controller_->GetBrowserContext()->GetUserData(kSSLManagerKeyName)); 143 controller_->GetBrowserContext()->GetUserData(kSSLManagerKeyName));
110 managers->get().erase(this); 144 managers->get().erase(this);
111 } 145 }
112 146
113 void SSLManager::DidCommitProvisionalLoad(const LoadCommittedDetails& details) { 147 void SSLManager::DidCommitProvisionalLoad(const LoadCommittedDetails& details) {
114 NavigationEntryImpl* entry = controller_->GetLastCommittedEntry(); 148 NavigationEntryImpl* entry = controller_->GetLastCommittedEntry();
149 UpdateEntry(details.ssl_status, details.is_main_frame, entry);
150 }
115 151
116 if (details.is_main_frame) { 152 void SSLManager::UpdateEntry(const SSLStatus& ssl_status,
117 if (entry) { 153 bool is_main_frame,
118 // We may not have an entry if this is a navigation to an initial blank 154 NavigationEntryImpl* entry) {
119 // page. Add the new data we have. 155 if (!entry)
120 entry->GetSSL() = details.ssl_status; 156 return;
121 } 157 if (is_main_frame) {
158 // We may not have an entry if this is a navigation to an initial blank
159 // page. Reset the SSL information and add the new data we have.
160 entry->GetSSL() = SSLStatus();
161 entry->GetSSL().security_style = ssl_status.security_style;
162 entry->GetSSL().cert_id = ssl_status.cert_id;
163 entry->GetSSL().cert_status = ssl_status.cert_status;
164 entry->GetSSL().security_bits = ssl_status.security_bits;
165 entry->GetSSL().key_exchange_info = ssl_status.key_exchange_info;
166 entry->GetSSL().connection_status = ssl_status.connection_status;
167 entry->GetSSL().content_status = ssl_status.content_status;
168 entry->GetSSL().signed_certificate_timestamp_ids =
169 ssl_status.signed_certificate_timestamp_ids;
122 } 170 }
123 171
124 policy()->UpdateEntry(entry, controller_->delegate()->GetWebContents()); 172 policy()->UpdateEntry(entry, controller_->delegate()->GetWebContents());
125 // Always notify the WebContents that the SSL state changed when a 173 // Always notify the WebContents that the SSL state changed when a
126 // load is committed, in case the active navigation entry has changed. 174 // load is committed, in case the active navigation entry has changed.
127 NotifyDidChangeVisibleSSLState(); 175 NotifyDidChangeVisibleSSLState();
128 } 176 }
129 177
130 void SSLManager::DidDisplayInsecureContent() { 178 void SSLManager::DidDisplayInsecureContent() {
131 UpdateEntry(controller_->GetLastCommittedEntry()); 179 UpdateEntry(controller_->GetLastCommittedEntry());
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
193 NotifyDidChangeVisibleSSLState(); 241 NotifyDidChangeVisibleSSLState();
194 } 242 }
195 243
196 void SSLManager::NotifyDidChangeVisibleSSLState() { 244 void SSLManager::NotifyDidChangeVisibleSSLState() {
197 WebContentsImpl* contents = 245 WebContentsImpl* contents =
198 static_cast<WebContentsImpl*>(controller_->delegate()->GetWebContents()); 246 static_cast<WebContentsImpl*>(controller_->delegate()->GetWebContents());
199 contents->DidChangeVisibleSSLState(); 247 contents->DidChangeVisibleSSLState();
200 } 248 }
201 249
202 } // namespace content 250 } // namespace content
OLDNEW
« chrome/browser/ui/login/login_prompt.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