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

Side by Side Diff: chrome/browser/ssl/ssl_manager.h

Issue 20296: Remember that we've white listed a certificate when we switch to a new tab.... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 11 years, 10 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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 #ifndef CHROME_BROWSER_SSL_MANAGER_H_ 5 #ifndef CHROME_BROWSER_SSL_SSL_MANAGER_H_
6 #define CHROME_BROWSER_SSL_MANAGER_H_ 6 #define CHROME_BROWSER_SSL_SSL_MANAGER_H_
7 7
8 #include <string> 8 #include <string>
9 #include <map> 9 #include <map>
10 #include <vector>
10 11
11 #include "base/basictypes.h" 12 #include "base/basictypes.h"
12 #include "base/observer_list.h" 13 #include "base/observer_list.h"
13 #include "base/ref_counted.h" 14 #include "base/ref_counted.h"
14 #include "chrome/browser/renderer_host/resource_dispatcher_host.h" 15 #include "chrome/browser/renderer_host/resource_dispatcher_host.h"
15 #include "chrome/browser/tab_contents/provisional_load_details.h" 16 #include "chrome/browser/tab_contents/provisional_load_details.h"
16 #include "chrome/browser/tab_contents/security_style.h" 17 #include "chrome/browser/tab_contents/security_style.h"
17 #include "chrome/common/notification_observer.h" 18 #include "chrome/common/notification_observer.h"
18 #include "chrome/common/notification_registrar.h" 19 #include "chrome/common/notification_registrar.h"
19 #include "googleurl/src/gurl.h" 20 #include "googleurl/src/gurl.h"
20 #include "net/base/net_errors.h" 21 #include "net/base/net_errors.h"
21 #include "net/base/ssl_info.h" 22 #include "net/base/ssl_info.h"
22 #include "net/base/x509_certificate.h" 23 #include "net/base/x509_certificate.h"
23 #include "webkit/glue/console_message_level.h" 24 #include "webkit/glue/console_message_level.h"
24 #include "webkit/glue/resource_type.h" 25 #include "webkit/glue/resource_type.h"
25 26
26 class AutomationProvider; 27 class AutomationProvider;
27 class NavigationEntry; 28 class NavigationEntry;
28 class LoadFromMemoryCacheDetails; 29 class LoadFromMemoryCacheDetails;
29 class LoadNotificationDetails; 30 class LoadNotificationDetails;
30 class NavigationController; 31 class NavigationController;
31 class PrefService; 32 class PrefService;
32 class ResourceRedirectDetails; 33 class ResourceRedirectDetails;
33 class ResourceRequestDetails; 34 class ResourceRequestDetails;
34 class SSLErrorInfo; 35 class SSLErrorInfo;
36 class SSLHostState;
35 class Task; 37 class Task;
36 class URLRequest; 38 class URLRequest;
37 class WebContents; 39 class WebContents;
38 40
39 // The SSLManager SSLManager controls the SSL UI elements in a TabContents. It 41 // The SSLManager SSLManager controls the SSL UI elements in a TabContents. It
40 // listens for various events that influence when these elements should or 42 // listens for various events that influence when these elements should or
41 // should not be displayed and adjusts them accordingly. 43 // should not be displayed and adjusts them accordingly.
42 // 44 //
43 // There is one SSLManager per tab. 45 // There is one SSLManager per tab.
44 // The security state (secure/insecure) is stored in the navigation entry. 46 // The security state (secure/insecure) is stored in the navigation entry.
(...skipping 19 matching lines...) Expand all
64 // Find the appropriate SSLManager for the URLRequest and begin handling 66 // Find the appropriate SSLManager for the URLRequest and begin handling
65 // this error. 67 // this error.
66 // 68 //
67 // Call on UI thread. 69 // Call on UI thread.
68 void Dispatch(); 70 void Dispatch();
69 71
70 // Available on either thread. 72 // Available on either thread.
71 const GURL& request_url() const { return request_url_; } 73 const GURL& request_url() const { return request_url_; }
72 74
73 // Call on the UI thread. 75 // Call on the UI thread.
74 SSLManager* manager() const { return manager_; }; 76 SSLManager* manager() const { return manager_; }
75 77
76 // Returns the WebContents this object is associated with. Should be 78 // Returns the WebContents this object is associated with. Should be
77 // called from the UI thread. 79 // called from the UI thread.
78 WebContents* GetWebContents(); 80 WebContents* GetWebContents();
79 81
80 // Cancels the associated URLRequest. 82 // Cancels the associated URLRequest.
81 // This method can be called from OnDispatchFailed and OnDispatched. 83 // This method can be called from OnDispatchFailed and OnDispatched.
82 void CancelRequest(); 84 void CancelRequest();
83 85
84 // Continue the URLRequest ignoring any previous errors. Note that some 86 // Continue the URLRequest ignoring any previous errors. Note that some
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 157
156 // We use these members to find the correct SSLManager when we arrive on 158 // We use these members to find the correct SSLManager when we arrive on
157 // the UI thread. 159 // the UI thread.
158 int render_process_host_id_; 160 int render_process_host_id_;
159 int tab_contents_id_; 161 int tab_contents_id_;
160 162
161 // This read-only member can be accessed on any thread. 163 // This read-only member can be accessed on any thread.
162 const GURL request_url_; // The URL that we requested. 164 const GURL request_url_; // The URL that we requested.
163 165
164 // Should only be accessed on the IO thread 166 // Should only be accessed on the IO thread
165 bool request_has_been_notified_; // A flag to make sure we notify the 167 bool request_has_been_notified_; // A flag to make sure we notify the
166 // URLRequest exactly once. 168 // URLRequest exactly once.
167 169
168 DISALLOW_EVIL_CONSTRUCTORS(ErrorHandler); 170 DISALLOW_EVIL_CONSTRUCTORS(ErrorHandler);
169 }; 171 };
170 172
171 // A CertError represents an error that occurred with the certificate in an 173 // A CertError represents an error that occurred with the certificate in an
172 // SSL session. A CertError object exists both on the IO thread and on the UI 174 // SSL session. A CertError object exists both on the IO thread and on the UI
173 // thread and allows us to cancel/continue a request it is associated with. 175 // thread and allows us to cancel/continue a request it is associated with.
174 class CertError : public ErrorHandler { 176 class CertError : public ErrorHandler {
175 public: 177 public:
176 // These accessors are available on either thread 178 // These accessors are available on either thread
(...skipping 14 matching lines...) Expand all
191 int cert_error, 193 int cert_error,
192 net::X509Certificate* cert, 194 net::X509Certificate* cert,
193 MessageLoop* ui_loop); 195 MessageLoop* ui_loop);
194 196
195 // ErrorHandler methods 197 // ErrorHandler methods
196 virtual void OnDispatchFailed() { CancelRequest(); } 198 virtual void OnDispatchFailed() { CancelRequest(); }
197 virtual void OnDispatched() { manager_->OnCertError(this); } 199 virtual void OnDispatched() { manager_->OnCertError(this); }
198 200
199 // These read-only members can be accessed on any thread. 201 // These read-only members can be accessed on any thread.
200 net::SSLInfo ssl_info_; 202 net::SSLInfo ssl_info_;
201 const int cert_error_; // The error we represent. 203 const int cert_error_; // The error we represent.
202 204
203 // What kind of resource is associated with the requested that generated 205 // What kind of resource is associated with the requested that generated
204 // that error. 206 // that error.
205 ResourceType::Type resource_type_; 207 ResourceType::Type resource_type_;
206 208
207 DISALLOW_EVIL_CONSTRUCTORS(CertError); 209 DISALLOW_EVIL_CONSTRUCTORS(CertError);
208 }; 210 };
209 211
210 // The MixedContentHandler class is used to query what to do with 212 // The MixedContentHandler class is used to query what to do with
211 // mixed content, from the IO thread to the UI thread. 213 // mixed content, from the IO thread to the UI thread.
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
330 // Called on the IO thread. 332 // Called on the IO thread.
331 static void OnSSLCertificateError(ResourceDispatcherHost* resource_dispatcher, 333 static void OnSSLCertificateError(ResourceDispatcherHost* resource_dispatcher,
332 URLRequest* request, 334 URLRequest* request,
333 int cert_error, 335 int cert_error,
334 net::X509Certificate* cert, 336 net::X509Certificate* cert,
335 MessageLoop* ui_loop); 337 MessageLoop* ui_loop);
336 338
337 // Called when a mixed-content sub-resource request has been detected. The 339 // Called when a mixed-content sub-resource request has been detected. The
338 // request is not started yet. The SSLManager will make a decision on whether 340 // request is not started yet. The SSLManager will make a decision on whether
339 // to filter that request's content (with the filter_policy flag). 341 // to filter that request's content (with the filter_policy flag).
340 // TODO (jcampan): Implement a way to just cancel the request. This is not 342 // TODO(jcampan): Implement a way to just cancel the request. This is not
341 // straight-forward as canceling a request that has not been started will 343 // straight-forward as canceling a request that has not been started will
342 // not remove from the pending_requests_ of the ResourceDispatcherHost. 344 // not remove from the pending_requests_ of the ResourceDispatcherHost.
343 // Called on the IO thread. 345 // Called on the IO thread.
344 static void OnMixedContentRequest(ResourceDispatcherHost* resource_dispatcher, 346 static void OnMixedContentRequest(ResourceDispatcherHost* resource_dispatcher,
345 URLRequest* request, 347 URLRequest* request,
346 MessageLoop* ui_loop); 348 MessageLoop* ui_loop);
347 349
348 // Called by CertError::Dispatch to kick off processing of the cert error by 350 // Called by CertError::Dispatch to kick off processing of the cert error by
349 // the SSL manager. The error originated from the ResourceDispatcherHost. 351 // the SSL manager. The error originated from the ResourceDispatcherHost.
350 // 352 //
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
391 // "Verified by <issuer_organization_name>" 393 // "Verified by <issuer_organization_name>"
392 static bool GetEVCertNames(const net::X509Certificate& cert, 394 static bool GetEVCertNames(const net::X509Certificate& cert,
393 std::wstring* short_name, 395 std::wstring* short_name,
394 std::wstring* ca_name); 396 std::wstring* ca_name);
395 397
396 private: 398 private:
397 // SSLMessageInfo contains the information necessary for displaying a message 399 // SSLMessageInfo contains the information necessary for displaying a message
398 // in an info-bar. 400 // in an info-bar.
399 struct SSLMessageInfo { 401 struct SSLMessageInfo {
400 public: 402 public:
401 explicit SSLMessageInfo(const std::wstring& text) 403 explicit SSLMessageInfo(const std::wstring& text)
402 : message(text), 404 : message(text),
wtc 2009/02/12 21:41:46 Nit: this colon should be indented 4 spaces. See
403 action(NULL) { } 405 action(NULL) { }
404 SSLMessageInfo(const std::wstring& message, 406 SSLMessageInfo(const std::wstring& message,
405 const std::wstring& link_text, 407 const std::wstring& link_text,
406 Task* action) 408 Task* action)
407 : message(message), link_text(link_text), action(action) { } 409 : message(message), link_text(link_text), action(action) { }
408 410
409 // Overridden so that std::find works. 411 // Overridden so that std::find works.
410 bool operator==(const std::wstring& other_message) const { 412 bool operator==(const std::wstring& other_message) const {
411 // We are uniquing SSLMessageInfo by their message only. 413 // We are uniquing SSLMessageInfo by their message only.
412 return message == other_message; 414 return message == other_message;
413 } 415 }
414 416
415 std::wstring message; 417 std::wstring message;
416 std::wstring link_text; 418 std::wstring link_text;
417 Task* action; 419 Task* action;
418 }; 420 };
419 421
420 // Entry points for notifications to which we subscribe. Note that 422 // Entry points for notifications to which we subscribe. Note that
421 // DidCommitProvisionalLoad uses the abstract NotificationDetails type since 423 // DidCommitProvisionalLoad uses the abstract NotificationDetails type since
422 // the type we need is in NavigationController which would create a circular 424 // the type we need is in NavigationController which would create a circular
423 // header file dependency. 425 // header file dependency.
424 void DidLoadFromMemoryCache(LoadFromMemoryCacheDetails* details); 426 void DidLoadFromMemoryCache(LoadFromMemoryCacheDetails* details);
425 void DidCommitProvisionalLoad(const NotificationDetails& details); 427 void DidCommitProvisionalLoad(const NotificationDetails& details);
426 void DidFailProvisionalLoadWithError(ProvisionalLoadDetails* details); 428 void DidFailProvisionalLoadWithError(ProvisionalLoadDetails* details);
427 void DidStartResourceResponse(ResourceRequestDetails* details); 429 void DidStartResourceResponse(ResourceRequestDetails* details);
428 void DidReceiveResourceRedirect(ResourceRedirectDetails* details); 430 void DidReceiveResourceRedirect(ResourceRedirectDetails* details);
(...skipping 11 matching lines...) Expand all
440 // Must not be NULL. 442 // Must not be NULL.
441 Delegate* delegate_; 443 Delegate* delegate_;
442 444
443 // The NavigationController that owns this SSLManager. We are responsible 445 // The NavigationController that owns this SSLManager. We are responsible
444 // for the security UI of this tab. 446 // for the security UI of this tab.
445 NavigationController* controller_; 447 NavigationController* controller_;
446 448
447 // Handles registering notifications with the NotificationService. 449 // Handles registering notifications with the NotificationService.
448 NotificationRegistrar registrar_; 450 NotificationRegistrar registrar_;
449 451
450 // Certificate policies for each host. 452 // SSL state specific for each host.
451 std::map<std::string, net::X509Certificate::Policy> cert_policy_for_host_; 453 SSLHostState* ssl_host_state_;
452
453 // Domains for which it is OK to show insecure content.
454 std::set<std::string> can_show_insecure_content_for_host_;
455 454
456 // The list of messages that should be displayed (in info bars) when the page 455 // The list of messages that should be displayed (in info bars) when the page
457 // currently loading had loaded. 456 // currently loading had loaded.
458 std::vector<SSLMessageInfo> pending_messages_; 457 std::vector<SSLMessageInfo> pending_messages_;
459 458
460 DISALLOW_COPY_AND_ASSIGN(SSLManager); 459 DISALLOW_COPY_AND_ASSIGN(SSLManager);
461 }; 460 };
462 461
463 #endif // CHROME_BROWSER_SSL_MANAGER_H_ 462 #endif // CHROME_BROWSER_SSL_SSL_MANAGER_H_
464
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698