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

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: 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 std::string& serialized_security_info,
86 bool is_main_frame) {
87 if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) {
88 BrowserThread::PostTask(
89 BrowserThread::UI, FROM_HERE,
90 base::Bind(SSLManager::OnAuthDialog, render_process_id, render_frame_id,
91 serialized_security_info, is_main_frame));
92 return;
93 }
94 RenderFrameHost* render_frame_host =
95 RenderFrameHostImpl::FromID(render_process_id, render_frame_id);
96 WebContents* web_contents =
97 WebContents::FromRenderFrameHost(render_frame_host);
98 if (!web_contents)
99 return;
100 NavigationControllerImpl* controller =
101 static_cast<NavigationControllerImpl*>(&web_contents->GetController());
102 NavigationEntryImpl* entry = controller->GetPendingEntry();
103 controller->ssl_manager()->UpdateEntry(serialized_security_info,
104 is_main_frame, entry);
105 }
106
107 // static
82 void SSLManager::NotifySSLInternalStateChanged(BrowserContext* context) { 108 void SSLManager::NotifySSLInternalStateChanged(BrowserContext* context) {
83 SSLManagerSet* managers = static_cast<SSLManagerSet*>( 109 SSLManagerSet* managers = static_cast<SSLManagerSet*>(
84 context->GetUserData(kSSLManagerKeyName)); 110 context->GetUserData(kSSLManagerKeyName));
85 111
86 for (std::set<SSLManager*>::iterator i = managers->get().begin(); 112 for (std::set<SSLManager*>::iterator i = managers->get().begin();
87 i != managers->get().end(); ++i) { 113 i != managers->get().end(); ++i) {
88 (*i)->UpdateEntry((*i)->controller()->GetLastCommittedEntry()); 114 (*i)->UpdateEntry((*i)->controller()->GetLastCommittedEntry());
89 } 115 }
90 } 116 }
91 117
(...skipping 12 matching lines...) Expand all
104 managers->get().insert(this); 130 managers->get().insert(this);
105 } 131 }
106 132
107 SSLManager::~SSLManager() { 133 SSLManager::~SSLManager() {
108 SSLManagerSet* managers = static_cast<SSLManagerSet*>( 134 SSLManagerSet* managers = static_cast<SSLManagerSet*>(
109 controller_->GetBrowserContext()->GetUserData(kSSLManagerKeyName)); 135 controller_->GetBrowserContext()->GetUserData(kSSLManagerKeyName));
110 managers->get().erase(this); 136 managers->get().erase(this);
111 } 137 }
112 138
113 void SSLManager::DidCommitProvisionalLoad(const LoadCommittedDetails& details) { 139 void SSLManager::DidCommitProvisionalLoad(const LoadCommittedDetails& details) {
114 NavigationEntryImpl* entry = controller_->GetLastCommittedEntry(); 140 // NavigationEntryImpl* entry = controller_->GetLastCommittedEntry();
141 // UpdateEntry(details.serialized_security_info, details.is_main_frame,
142 // entry);
143 // TODO(palmer): Should make use of details.SSLStatus instead.
144 }
115 145
116 if (details.is_main_frame) { 146 void SSLManager::UpdateEntry(const std::string& serialized_security_info,
117 if (entry) { 147 bool is_main_frame,
118 // We may not have an entry if this is a navigation to an initial blank 148 NavigationEntryImpl* entry) {
119 // page. Add the new data we have. 149 if (is_main_frame && entry) {
120 entry->GetSSL() = details.ssl_status; 150 // Decode the security details.
121 } 151 int ssl_cert_id = 0;
152 net::CertStatus ssl_cert_status = 0;
153 int ssl_security_bits = 0;
154 int ssl_connection_status = 0;
155 SignedCertificateTimestampIDStatusList ssl_signed_certificate_timestamp_ids;
156 /*
157 DeserializeSecurityInfo(serialized_security_info, &ssl_cert_id,
158 &ssl_cert_status, &ssl_security_bits,
159 &ssl_connection_status,
160 &ssl_signed_certificate_timestamp_ids);
161 */
162
163 // We may not have an entry if this is a navigation to an initial blank
164 // page. Reset the SSL information and add the new data we have.
165 entry->GetSSL() = SSLStatus();
166 entry->GetSSL().cert_id = ssl_cert_id;
167 entry->GetSSL().cert_status = ssl_cert_status;
168 entry->GetSSL().security_bits = ssl_security_bits;
169 entry->GetSSL().connection_status = ssl_connection_status;
170 entry->GetSSL().signed_certificate_timestamp_ids =
171 ssl_signed_certificate_timestamp_ids;
122 } 172 }
123 173
124 policy()->UpdateEntry(entry, controller_->delegate()->GetWebContents()); 174 policy()->UpdateEntry(entry, controller_->delegate()->GetWebContents());
125 // Always notify the WebContents that the SSL state changed when a 175 // Always notify the WebContents that the SSL state changed when a
126 // load is committed, in case the active navigation entry has changed. 176 // load is committed, in case the active navigation entry has changed.
127 NotifyDidChangeVisibleSSLState(); 177 NotifyDidChangeVisibleSSLState();
128 } 178 }
129 179
130 void SSLManager::DidDisplayInsecureContent() { 180 void SSLManager::DidDisplayInsecureContent() {
131 UpdateEntry(controller_->GetLastCommittedEntry()); 181 UpdateEntry(controller_->GetLastCommittedEntry());
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
193 NotifyDidChangeVisibleSSLState(); 243 NotifyDidChangeVisibleSSLState();
194 } 244 }
195 245
196 void SSLManager::NotifyDidChangeVisibleSSLState() { 246 void SSLManager::NotifyDidChangeVisibleSSLState() {
197 WebContentsImpl* contents = 247 WebContentsImpl* contents =
198 static_cast<WebContentsImpl*>(controller_->delegate()->GetWebContents()); 248 static_cast<WebContentsImpl*>(controller_->delegate()->GetWebContents());
199 contents->DidChangeVisibleSSLState(); 249 contents->DidChangeVisibleSSLState();
200 } 250 }
201 251
202 } // namespace content 252 } // 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