| OLD | NEW |
| 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_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 #include <map> | 9 #include <map> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 // listens for various events that influence when these elements should or | 42 // listens for various events that influence when these elements should or |
| 43 // should not be displayed and adjusts them accordingly. | 43 // should not be displayed and adjusts them accordingly. |
| 44 // | 44 // |
| 45 // There is one SSLManager per tab. | 45 // There is one SSLManager per tab. |
| 46 // The security state (secure/insecure) is stored in the navigation entry. | 46 // The security state (secure/insecure) is stored in the navigation entry. |
| 47 // Along with it are stored any SSL error code and the associated cert. | 47 // Along with it are stored any SSL error code and the associated cert. |
| 48 // | 48 // |
| 49 | 49 |
| 50 class SSLManager : public NotificationObserver { | 50 class SSLManager : public NotificationObserver { |
| 51 public: | 51 public: |
| 52 class CertError; |
| 53 |
| 52 // An ErrorHandler carries information from the IO thread to the UI thread | 54 // An ErrorHandler carries information from the IO thread to the UI thread |
| 53 // and is dispatched to the appropriate SSLManager when it arrives on the | 55 // and is dispatched to the appropriate SSLManager when it arrives on the |
| 54 // UI thread. Subclasses should override the OnDispatched/OnDispatchFailed | 56 // UI thread. Subclasses should override the OnDispatched/OnDispatchFailed |
| 55 // methods to implement the actions that should be taken on the UI thread. | 57 // methods to implement the actions that should be taken on the UI thread. |
| 56 // These methods can call the different convenience methods ContinueRequest/ | 58 // These methods can call the different convenience methods ContinueRequest/ |
| 57 // CancelRequest/StartRequest to perform any required action on the URLRequest | 59 // CancelRequest/StartRequest to perform any required action on the URLRequest |
| 58 // the ErrorHandler was created with. | 60 // the ErrorHandler was created with. |
| 59 // IMPORTANT NOTE: if you are not doing anything in | 61 // IMPORTANT NOTE: if you are not doing anything in |
| 60 // OnDispatched/OnDispatchFailed, make sure you call TakeNoAction(). This is | 62 // OnDispatched/OnDispatchFailed, make sure you call TakeNoAction(). This is |
| 61 // necessary for ensuring the instance is not leaked. | 63 // necessary for ensuring the instance is not leaked. |
| 62 class ErrorHandler : public base::RefCountedThreadSafe<ErrorHandler> { | 64 class ErrorHandler : public base::RefCountedThreadSafe<ErrorHandler> { |
| 63 public: | 65 public: |
| 64 virtual ~ErrorHandler() { } | 66 virtual ~ErrorHandler() { } |
| 65 | 67 |
| 68 virtual CertError* AsCertError() { return NULL; } |
| 69 |
| 66 // Find the appropriate SSLManager for the URLRequest and begin handling | 70 // Find the appropriate SSLManager for the URLRequest and begin handling |
| 67 // this error. | 71 // this error. |
| 68 // | 72 // |
| 69 // Call on UI thread. | 73 // Call on UI thread. |
| 70 void Dispatch(); | 74 void Dispatch(); |
| 71 | 75 |
| 72 // Available on either thread. | 76 // Available on either thread. |
| 73 const GURL& request_url() const { return request_url_; } | 77 const GURL& request_url() const { return request_url_; } |
| 74 | 78 |
| 75 // Call on the UI thread. | 79 // Call on the UI thread. |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 160 int render_process_host_id_; | 164 int render_process_host_id_; |
| 161 int tab_contents_id_; | 165 int tab_contents_id_; |
| 162 | 166 |
| 163 // This read-only member can be accessed on any thread. | 167 // This read-only member can be accessed on any thread. |
| 164 const GURL request_url_; // The URL that we requested. | 168 const GURL request_url_; // The URL that we requested. |
| 165 | 169 |
| 166 // Should only be accessed on the IO thread | 170 // Should only be accessed on the IO thread |
| 167 bool request_has_been_notified_; // A flag to make sure we notify the | 171 bool request_has_been_notified_; // A flag to make sure we notify the |
| 168 // URLRequest exactly once. | 172 // URLRequest exactly once. |
| 169 | 173 |
| 170 DISALLOW_EVIL_CONSTRUCTORS(ErrorHandler); | 174 DISALLOW_COPY_AND_ASSIGN(ErrorHandler); |
| 171 }; | 175 }; |
| 172 | 176 |
| 173 // A CertError represents an error that occurred with the certificate in an | 177 // A CertError represents an error that occurred with the certificate in an |
| 174 // SSL session. A CertError object exists both on the IO thread and on the UI | 178 // SSL session. A CertError object exists both on the IO thread and on the UI |
| 175 // thread and allows us to cancel/continue a request it is associated with. | 179 // thread and allows us to cancel/continue a request it is associated with. |
| 176 class CertError : public ErrorHandler { | 180 class CertError : public ErrorHandler { |
| 177 public: | 181 public: |
| 182 |
| 183 virtual CertError* AsCertError() { return this; } |
| 184 |
| 178 // These accessors are available on either thread | 185 // These accessors are available on either thread |
| 179 const net::SSLInfo& ssl_info() const { return ssl_info_; } | 186 const net::SSLInfo& ssl_info() const { return ssl_info_; } |
| 180 int cert_error() const { return cert_error_; } | 187 int cert_error() const { return cert_error_; } |
| 181 | 188 |
| 182 ResourceType::Type resource_type() const { return resource_type_; } | 189 ResourceType::Type resource_type() const { return resource_type_; } |
| 183 private: | 190 private: |
| 184 // SSLManager is responsible for creating CertError objects. | 191 // SSLManager is responsible for creating CertError objects. |
| 185 friend class SSLManager; | 192 friend class SSLManager; |
| 186 | 193 |
| 187 // Construct on the IO thread. | 194 // Construct on the IO thread. |
| (...skipping 11 matching lines...) Expand all Loading... |
| 199 virtual void OnDispatched() { manager_->OnCertError(this); } | 206 virtual void OnDispatched() { manager_->OnCertError(this); } |
| 200 | 207 |
| 201 // These read-only members can be accessed on any thread. | 208 // These read-only members can be accessed on any thread. |
| 202 net::SSLInfo ssl_info_; | 209 net::SSLInfo ssl_info_; |
| 203 const int cert_error_; // The error we represent. | 210 const int cert_error_; // The error we represent. |
| 204 | 211 |
| 205 // What kind of resource is associated with the requested that generated | 212 // What kind of resource is associated with the requested that generated |
| 206 // that error. | 213 // that error. |
| 207 ResourceType::Type resource_type_; | 214 ResourceType::Type resource_type_; |
| 208 | 215 |
| 209 DISALLOW_EVIL_CONSTRUCTORS(CertError); | 216 DISALLOW_COPY_AND_ASSIGN(CertError); |
| 210 }; | 217 }; |
| 211 | 218 |
| 212 // The MixedContentHandler class is used to query what to do with | 219 // The MixedContentHandler class is used to query what to do with |
| 213 // mixed content, from the IO thread to the UI thread. | 220 // mixed content, from the IO thread to the UI thread. |
| 214 class MixedContentHandler : public ErrorHandler { | 221 class MixedContentHandler : public ErrorHandler { |
| 215 public: | 222 public: |
| 216 // Created on the IO thread. | 223 // Created on the IO thread. |
| 217 MixedContentHandler(ResourceDispatcherHost* rdh, | 224 MixedContentHandler(ResourceDispatcherHost* rdh, |
| 218 URLRequest* request, | 225 URLRequest* request, |
| 219 MessageLoop* ui_loop) | 226 MessageLoop* ui_loop) |
| 220 : ErrorHandler(rdh, request, ui_loop) { } | 227 : ErrorHandler(rdh, request, ui_loop) { } |
| 221 | 228 |
| 222 protected: | 229 protected: |
| 223 virtual void OnDispatchFailed() { TakeNoAction(); } | 230 virtual void OnDispatchFailed() { TakeNoAction(); } |
| 224 virtual void OnDispatched() { manager()->OnMixedContent(this); } | 231 virtual void OnDispatched() { manager()->OnMixedContent(this); } |
| 225 | 232 |
| 226 private: | 233 private: |
| 227 DISALLOW_EVIL_CONSTRUCTORS(MixedContentHandler); | 234 DISALLOW_COPY_AND_ASSIGN(MixedContentHandler); |
| 228 }; | 235 }; |
| 229 | 236 |
| 230 // The SSLManager will ask its delegate to decide how to handle events | 237 // The SSLManager will ask its delegate to decide how to handle events |
| 231 // relevant to SSL. Delegates are expected to be stateless and intended to be | 238 // relevant to SSL. Delegates are expected to be stateless and intended to be |
| 232 // easily implementable. | 239 // easily implementable. |
| 233 // | 240 // |
| 234 // Delegates should interact with the rest of the browser only through their | 241 // Delegates should interact with the rest of the browser only through their |
| 235 // parameters and through the delegate API of the SSLManager. | 242 // parameters and through the delegate API of the SSLManager. |
| 236 // | 243 // |
| 237 // If a delegate needs to do something tricky, consider having the SSLManager | 244 // If a delegate needs to do something tricky, consider having the SSLManager |
| (...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 454 SSLHostState* ssl_host_state_; | 461 SSLHostState* ssl_host_state_; |
| 455 | 462 |
| 456 // The list of messages that should be displayed (in info bars) when the page | 463 // The list of messages that should be displayed (in info bars) when the page |
| 457 // currently loading had loaded. | 464 // currently loading had loaded. |
| 458 std::vector<SSLMessageInfo> pending_messages_; | 465 std::vector<SSLMessageInfo> pending_messages_; |
| 459 | 466 |
| 460 DISALLOW_COPY_AND_ASSIGN(SSLManager); | 467 DISALLOW_COPY_AND_ASSIGN(SSLManager); |
| 461 }; | 468 }; |
| 462 | 469 |
| 463 #endif // CHROME_BROWSER_SSL_SSL_MANAGER_H_ | 470 #endif // CHROME_BROWSER_SSL_SSL_MANAGER_H_ |
| OLD | NEW |