OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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_SSL_MANAGER_H_ | 5 #ifndef CHROME_BROWSER_SSL_SSL_MANAGER_H_ |
6 #define CHROME_BROWSER_SSL_SSL_MANAGER_H_ | 6 #define CHROME_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" |
(...skipping 20 matching lines...) Expand all Loading... |
31 // The SSLManager SSLManager controls the SSL UI elements in a TabContents. It | 31 // The SSLManager SSLManager controls the SSL UI elements in a TabContents. It |
32 // listens for various events that influence when these elements should or | 32 // listens for various events that influence when these elements should or |
33 // should not be displayed and adjusts them accordingly. | 33 // should not be displayed and adjusts them accordingly. |
34 // | 34 // |
35 // There is one SSLManager per tab. | 35 // There is one SSLManager per tab. |
36 // The security state (secure/insecure) is stored in the navigation entry. | 36 // The security state (secure/insecure) is stored in the navigation entry. |
37 // Along with it are stored any SSL error code and the associated cert. | 37 // Along with it are stored any SSL error code and the associated cert. |
38 | 38 |
39 class SSLManager : public NotificationObserver { | 39 class SSLManager : public NotificationObserver { |
40 public: | 40 public: |
| 41 // Construct an SSLManager for the specified tab. |
| 42 // If |delegate| is NULL, SSLPolicy::GetDefaultPolicy() is used. |
| 43 explicit SSLManager(NavigationController* controller); |
| 44 ~SSLManager(); |
| 45 |
| 46 SSLPolicy* policy() { return policy_.get(); } |
| 47 SSLPolicyBackend* backend() { return &backend_; } |
| 48 |
| 49 // The navigation controller associated with this SSLManager. The |
| 50 // NavigationController is guaranteed to outlive the SSLManager. |
| 51 NavigationController* controller() { return controller_; } |
| 52 |
41 static void RegisterUserPrefs(PrefService* prefs); | 53 static void RegisterUserPrefs(PrefService* prefs); |
42 | 54 |
43 // Entry point for SSLCertificateErrors. This function begins the process | 55 // Entry point for SSLCertificateErrors. This function begins the process |
44 // of resolving a certificate error during an SSL connection. SSLManager | 56 // of resolving a certificate error during an SSL connection. SSLManager |
45 // will adjust the security UI and either call |Cancel| or | 57 // will adjust the security UI and either call |Cancel| or |
46 // |ContinueDespiteLastError| on the URLRequest. | 58 // |ContinueDespiteLastError| on the URLRequest. |
47 // | 59 // |
48 // Called on the IO thread. | 60 // Called on the IO thread. |
49 static void OnSSLCertificateError(ResourceDispatcherHost* resource_dispatcher, | 61 static void OnSSLCertificateError(ResourceDispatcherHost* resource_dispatcher, |
50 URLRequest* request, | 62 URLRequest* request, |
51 int cert_error, | 63 int cert_error, |
52 net::X509Certificate* cert); | 64 net::X509Certificate* cert); |
53 | 65 |
54 // Called when SSL state for a host or tab changes. Broadcasts the | 66 // Mixed content entry points. |
55 // SSL_INTERNAL_STATE_CHANGED notification. | 67 void DidDisplayInsecureContent(); |
56 static void NotifySSLInternalStateChanged(); | 68 void DidRunInsecureContent(const std::string& security_origin); |
| 69 |
| 70 // Entry point for navigation. This function begins the process of updating |
| 71 // the security UI when the main frame navigates to a new URL. |
| 72 // |
| 73 // Called on the UI thread. |
| 74 virtual void Observe(NotificationType type, |
| 75 const NotificationSource& source, |
| 76 const NotificationDetails& details); |
| 77 |
| 78 // This entry point is called directly (instead of via the notification |
| 79 // service) because we need more precise control of the order in which folks |
| 80 // are notified of this event. |
| 81 void DidCommitProvisionalLoad(const NotificationDetails& details); |
| 82 |
| 83 // Called to determine if there were any processed SSL errors from request. |
| 84 bool ProcessedSSLErrorFromRequest() const; |
57 | 85 |
58 // Convenience methods for serializing/deserializing the security info. | 86 // Convenience methods for serializing/deserializing the security info. |
59 static std::string SerializeSecurityInfo(int cert_id, | 87 static std::string SerializeSecurityInfo(int cert_id, |
60 int cert_status, | 88 int cert_status, |
61 int security_bits); | 89 int security_bits); |
62 static bool DeserializeSecurityInfo(const std::string& state, | 90 static bool DeserializeSecurityInfo(const std::string& state, |
63 int* cert_id, | 91 int* cert_id, |
64 int* cert_status, | 92 int* cert_status, |
65 int* security_bits); | 93 int* security_bits); |
66 | 94 |
67 // Returns "<organization_name> [<country>]". | 95 // Returns "<organization_name> [<country>]". |
68 static std::wstring GetEVCertName(const net::X509Certificate& cert); | 96 static std::wstring GetEVCertName(const net::X509Certificate& cert); |
69 | 97 |
70 // Construct an SSLManager for the specified tab. | |
71 // If |delegate| is NULL, SSLPolicy::GetDefaultPolicy() is used. | |
72 explicit SSLManager(NavigationController* controller); | |
73 ~SSLManager(); | |
74 | |
75 SSLPolicy* policy() { return policy_.get(); } | |
76 SSLPolicyBackend* backend() { return &backend_; } | |
77 | |
78 // The navigation controller associated with this SSLManager. The | |
79 // NavigationController is guaranteed to outlive the SSLManager. | |
80 NavigationController* controller() { return controller_; } | |
81 | |
82 // This entry point is called directly (instead of via the notification | |
83 // service) because we need more precise control of the order in which folks | |
84 // are notified of this event. | |
85 void DidCommitProvisionalLoad(const NotificationDetails& details); | |
86 | |
87 // Mixed content entry point. | |
88 void DidRunInsecureContent(const std::string& security_origin); | |
89 | |
90 // Called to determine if there were any processed SSL errors from request. | |
91 bool ProcessedSSLErrorFromRequest() const; | |
92 | |
93 // Entry point for navigation. This function begins the process of updating | |
94 // the security UI when the main frame navigates to a new URL. | |
95 // | |
96 // Called on the UI thread. | |
97 virtual void Observe(NotificationType type, | |
98 const NotificationSource& source, | |
99 const NotificationDetails& details); | |
100 | |
101 private: | 98 private: |
102 // SSLMessageInfo contains the information necessary for displaying a message | 99 // SSLMessageInfo contains the information necessary for displaying a message |
103 // in an info-bar. | 100 // in an info-bar. |
104 struct SSLMessageInfo { | 101 struct SSLMessageInfo { |
105 public: | 102 public: |
106 explicit SSLMessageInfo(const std::wstring& text) | 103 explicit SSLMessageInfo(const std::wstring& text) |
107 : message(text), | 104 : message(text), |
108 action(NULL) { } | 105 action(NULL) { } |
109 | 106 |
110 SSLMessageInfo(const std::wstring& message, | 107 SSLMessageInfo(const std::wstring& message, |
(...skipping 15 matching lines...) Expand all Loading... |
126 // Entry points for notifications to which we subscribe. Note that | 123 // Entry points for notifications to which we subscribe. Note that |
127 // DidCommitProvisionalLoad uses the abstract NotificationDetails type since | 124 // DidCommitProvisionalLoad uses the abstract NotificationDetails type since |
128 // the type we need is in NavigationController which would create a circular | 125 // the type we need is in NavigationController which would create a circular |
129 // header file dependency. | 126 // header file dependency. |
130 void DidLoadFromMemoryCache(LoadFromMemoryCacheDetails* details); | 127 void DidLoadFromMemoryCache(LoadFromMemoryCacheDetails* details); |
131 void DidFailProvisionalLoadWithError(ProvisionalLoadDetails* details); | 128 void DidFailProvisionalLoadWithError(ProvisionalLoadDetails* details); |
132 void DidStartResourceResponse(ResourceRequestDetails* details); | 129 void DidStartResourceResponse(ResourceRequestDetails* details); |
133 void DidReceiveResourceRedirect(ResourceRedirectDetails* details); | 130 void DidReceiveResourceRedirect(ResourceRedirectDetails* details); |
134 void DidChangeSSLInternalState(); | 131 void DidChangeSSLInternalState(); |
135 | 132 |
| 133 // Dispatch NotificationType::SSL_VISIBLE_STATE_CHANGED notification. |
| 134 void DispatchSSLVisibleStateChanged(); |
| 135 |
136 // Update the NavigationEntry with our current state. | 136 // Update the NavigationEntry with our current state. |
137 void UpdateEntry(NavigationEntry* entry); | 137 void UpdateEntry(NavigationEntry* entry); |
138 | 138 |
139 // The backend for the SSLPolicy to actuate its decisions. | 139 // The backend for the SSLPolicy to actuate its decisions. |
140 SSLPolicyBackend backend_; | 140 SSLPolicyBackend backend_; |
141 | 141 |
142 // The SSLPolicy instance for this manager. | 142 // The SSLPolicy instance for this manager. |
143 scoped_ptr<SSLPolicy> policy_; | 143 scoped_ptr<SSLPolicy> policy_; |
144 | 144 |
145 // The NavigationController that owns this SSLManager. We are responsible | 145 // The NavigationController that owns this SSLManager. We are responsible |
146 // for the security UI of this tab. | 146 // for the security UI of this tab. |
147 NavigationController* controller_; | 147 NavigationController* controller_; |
148 | 148 |
149 // Handles registering notifications with the NotificationService. | 149 // Handles registering notifications with the NotificationService. |
150 NotificationRegistrar registrar_; | 150 NotificationRegistrar registrar_; |
151 | 151 |
152 DISALLOW_COPY_AND_ASSIGN(SSLManager); | 152 DISALLOW_COPY_AND_ASSIGN(SSLManager); |
153 }; | 153 }; |
154 | 154 |
155 #endif // CHROME_BROWSER_SSL_SSL_MANAGER_H_ | 155 #endif // CHROME_BROWSER_SSL_SSL_MANAGER_H_ |
OLD | NEW |