| OLD | NEW |
| 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 #ifndef CONTENT_BROWSER_SSL_SSL_MANAGER_H_ | 5 #ifndef CONTENT_BROWSER_SSL_SSL_MANAGER_H_ |
| 6 #define CONTENT_BROWSER_SSL_SSL_MANAGER_H_ | 6 #define CONTENT_BROWSER_SSL_SSL_MANAGER_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| 11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
| 12 #include "base/memory/weak_ptr.h" | 12 #include "base/memory/weak_ptr.h" |
| 13 #include "content/browser/ssl/ssl_error_handler.h" | 13 #include "content/browser/ssl/ssl_error_handler.h" |
| 14 #include "content/browser/ssl/ssl_policy_backend.h" | 14 #include "content/browser/ssl/ssl_policy_backend.h" |
| 15 #include "content/common/content_export.h" | 15 #include "content/common/content_export.h" |
| 16 #include "content/public/browser/global_request_id.h" | 16 #include "content/public/browser/global_request_id.h" |
| 17 #include "net/base/net_errors.h" | 17 #include "net/base/net_errors.h" |
| 18 #include "net/cert/cert_status_flags.h" | 18 #include "net/cert/cert_status_flags.h" |
| 19 #include "url/gurl.h" | 19 #include "url/gurl.h" |
| 20 | 20 |
| 21 namespace net { | 21 namespace net { |
| 22 class SSLInfo; | 22 class SSLInfo; |
| 23 } | 23 } |
| 24 | 24 |
| 25 namespace content { | 25 namespace content { |
| 26 class BrowserContext; | 26 class BrowserContext; |
| 27 class NavigationEntryImpl; | 27 class NavigationEntryImpl; |
| 28 class NavigationControllerImpl; | 28 class NavigationControllerImpl; |
| 29 class SSLPolicy; | 29 class SSLPolicy; |
| 30 struct SSLStatus; |
| 30 struct LoadCommittedDetails; | 31 struct LoadCommittedDetails; |
| 31 struct LoadFromMemoryCacheDetails; | 32 struct LoadFromMemoryCacheDetails; |
| 32 struct ResourceRedirectDetails; | 33 struct ResourceRedirectDetails; |
| 33 struct ResourceRequestDetails; | 34 struct ResourceRequestDetails; |
| 34 | 35 |
| 35 // The SSLManager SSLManager controls the SSL UI elements in a WebContents. It | 36 // The SSLManager SSLManager controls the SSL UI elements in a WebContents. It |
| 36 // listens for various events that influence when these elements should or | 37 // listens for various events that influence when these elements should or |
| 37 // should not be displayed and adjusts them accordingly. | 38 // should not be displayed and adjusts them accordingly. |
| 38 // | 39 // |
| 39 // There is one SSLManager per tab. | 40 // There is one SSLManager per tab. |
| (...skipping 10 matching lines...) Expand all Loading... |
| 50 // Called on the IO thread. | 51 // Called on the IO thread. |
| 51 static void OnSSLCertificateError( | 52 static void OnSSLCertificateError( |
| 52 const base::WeakPtr<SSLErrorHandler::Delegate>& delegate, | 53 const base::WeakPtr<SSLErrorHandler::Delegate>& delegate, |
| 53 ResourceType resource_type, | 54 ResourceType resource_type, |
| 54 const GURL& url, | 55 const GURL& url, |
| 55 int render_process_id, | 56 int render_process_id, |
| 56 int render_frame_id, | 57 int render_frame_id, |
| 57 const net::SSLInfo& ssl_info, | 58 const net::SSLInfo& ssl_info, |
| 58 bool fatal); | 59 bool fatal); |
| 59 | 60 |
| 61 // Called before an HTTP basic auth dialog is displayed. Call this from the IO |
| 62 // thread. |
| 63 static void OnAuthDialog(int render_process_id, |
| 64 int render_frame_id, |
| 65 const content::SSLStatus& ssl_status, |
| 66 bool is_main_frame); |
| 67 |
| 68 // Called before an HTTP basic auth dialog is displayed. Call this from the UI |
| 69 // thread. |
| 70 static void OnAuthDialogOnUI(int render_process_id, |
| 71 int render_frame_id, |
| 72 const content::SSLStatus& ssl_status, |
| 73 bool is_main_frame); |
| 74 |
| 60 // Called when SSL state for a host or tab changes. | 75 // Called when SSL state for a host or tab changes. |
| 61 static void NotifySSLInternalStateChanged(BrowserContext* context); | 76 static void NotifySSLInternalStateChanged(BrowserContext* context); |
| 62 | 77 |
| 63 // Construct an SSLManager for the specified tab. | 78 // Construct an SSLManager for the specified tab. |
| 64 // If |delegate| is NULL, SSLPolicy::GetDefaultPolicy() is used. | 79 // If |delegate| is NULL, SSLPolicy::GetDefaultPolicy() is used. |
| 65 explicit SSLManager(NavigationControllerImpl* controller); | 80 explicit SSLManager(NavigationControllerImpl* controller); |
| 66 virtual ~SSLManager(); | 81 virtual ~SSLManager(); |
| 67 | 82 |
| 68 SSLPolicy* policy() { return policy_.get(); } | 83 SSLPolicy* policy() { return policy_.get(); } |
| 69 SSLPolicyBackend* backend() { return &backend_; } | 84 SSLPolicyBackend* backend() { return &backend_; } |
| 70 | 85 |
| 71 // The navigation controller associated with this SSLManager. The | 86 // The navigation controller associated with this SSLManager. The |
| 72 // NavigationController is guaranteed to outlive the SSLManager. | 87 // NavigationController is guaranteed to outlive the SSLManager. |
| 73 NavigationControllerImpl* controller() { return controller_; } | 88 NavigationControllerImpl* controller() { return controller_; } |
| 74 | 89 |
| 75 void DidCommitProvisionalLoad(const LoadCommittedDetails& details); | 90 void DidCommitProvisionalLoad(const LoadCommittedDetails& details); |
| 76 void DidLoadFromMemoryCache(const LoadFromMemoryCacheDetails& details); | 91 void DidLoadFromMemoryCache(const LoadFromMemoryCacheDetails& details); |
| 77 void DidStartResourceResponse(const ResourceRequestDetails& details); | 92 void DidStartResourceResponse(const ResourceRequestDetails& details); |
| 78 void DidReceiveResourceRedirect(const ResourceRedirectDetails& details); | 93 void DidReceiveResourceRedirect(const ResourceRedirectDetails& details); |
| 79 | 94 |
| 80 // Insecure content entry point. | 95 // Insecure content entry point. |
| 81 void DidDisplayInsecureContent(); | 96 void DidDisplayInsecureContent(); |
| 82 void DidRunInsecureContent(const std::string& security_origin); | 97 void DidRunInsecureContent(const std::string& security_origin); |
| 83 | 98 |
| 84 private: | 99 private: |
| 85 // Updates the NavigationEntry with our current state. This will | 100 // Updates the NavigationEntry with our current state. This will |
| 86 // notify the WebContents of an SSL state change if a change was | 101 // notify the WebContents of an SSL state change if a change was |
| 87 // actually made. | 102 // actually made. |
| 88 void UpdateEntry(NavigationEntryImpl* entry); | 103 void UpdateEntry(NavigationEntryImpl* entry); |
| 104 void UpdateEntry(const content::SSLStatus& ssl_status, |
| 105 bool is_main_frame, |
| 106 NavigationEntryImpl* entry); |
| 89 | 107 |
| 90 // Notifies the WebContents that the SSL state changed. | 108 // Notifies the WebContents that the SSL state changed. |
| 91 void NotifyDidChangeVisibleSSLState(); | 109 void NotifyDidChangeVisibleSSLState(); |
| 92 | 110 |
| 93 // The backend for the SSLPolicy to actuate its decisions. | 111 // The backend for the SSLPolicy to actuate its decisions. |
| 94 SSLPolicyBackend backend_; | 112 SSLPolicyBackend backend_; |
| 95 | 113 |
| 96 // The SSLPolicy instance for this manager. | 114 // The SSLPolicy instance for this manager. |
| 97 scoped_ptr<SSLPolicy> policy_; | 115 scoped_ptr<SSLPolicy> policy_; |
| 98 | 116 |
| 99 // The NavigationController that owns this SSLManager. We are responsible | 117 // The NavigationController that owns this SSLManager. We are responsible |
| 100 // for the security UI of this tab. | 118 // for the security UI of this tab. |
| 101 NavigationControllerImpl* controller_; | 119 NavigationControllerImpl* controller_; |
| 102 | 120 |
| 103 DISALLOW_COPY_AND_ASSIGN(SSLManager); | 121 DISALLOW_COPY_AND_ASSIGN(SSLManager); |
| 104 }; | 122 }; |
| 105 | 123 |
| 106 } // namespace content | 124 } // namespace content |
| 107 | 125 |
| 108 #endif // CONTENT_BROWSER_SSL_SSL_MANAGER_H_ | 126 #endif // CONTENT_BROWSER_SSL_SSL_MANAGER_H_ |
| OLD | NEW |