| 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_ERROR_HANDLER_H_ | 5 #ifndef CHROME_BROWSER_SSL_SSL_ERROR_HANDLER_H_ |
| 6 #define CHROME_BROWSER_SSL_SSL_ERROR_HANDLER_H_ | 6 #define CHROME_BROWSER_SSL_SSL_ERROR_HANDLER_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 | 21 |
| 22 namespace net { | 22 namespace net { |
| 23 class URLRequest; | 23 class URLRequest; |
| 24 } // namespace net | 24 } // namespace net |
| 25 | 25 |
| 26 // An SSLErrorHandler carries information from the IO thread to the UI thread | 26 // An SSLErrorHandler carries information from the IO thread to the UI thread |
| 27 // and is dispatched to the appropriate SSLManager when it arrives on the | 27 // and is dispatched to the appropriate SSLManager when it arrives on the |
| 28 // UI thread. Subclasses should override the OnDispatched/OnDispatchFailed | 28 // UI thread. Subclasses should override the OnDispatched/OnDispatchFailed |
| 29 // methods to implement the actions that should be taken on the UI thread. | 29 // methods to implement the actions that should be taken on the UI thread. |
| 30 // These methods can call the different convenience methods ContinueRequest/ | 30 // These methods can call the different convenience methods ContinueRequest/ |
| 31 // CancelRequest to perform any required action on the URLRequest the | 31 // CancelRequest to perform any required action on the net::URLRequest the |
| 32 // ErrorHandler was created with. | 32 // ErrorHandler was created with. |
| 33 // | 33 // |
| 34 // IMPORTANT NOTE: | 34 // IMPORTANT NOTE: |
| 35 // | 35 // |
| 36 // If you are not doing anything in OnDispatched/OnDispatchFailed, make sure | 36 // If you are not doing anything in OnDispatched/OnDispatchFailed, make sure |
| 37 // you call TakeNoAction(). This is necessary for ensuring the instance is | 37 // you call TakeNoAction(). This is necessary for ensuring the instance is |
| 38 // not leaked. | 38 // not leaked. |
| 39 // | 39 // |
| 40 class SSLErrorHandler : public base::RefCountedThreadSafe<SSLErrorHandler> { | 40 class SSLErrorHandler : public base::RefCountedThreadSafe<SSLErrorHandler> { |
| 41 public: | 41 public: |
| 42 virtual SSLCertErrorHandler* AsSSLCertErrorHandler() { return NULL; } | 42 virtual SSLCertErrorHandler* AsSSLCertErrorHandler() { return NULL; } |
| 43 | 43 |
| 44 // Find the appropriate SSLManager for the URLRequest and begin handling | 44 // Find the appropriate SSLManager for the net::URLRequest and begin handling |
| 45 // this error. | 45 // this error. |
| 46 // | 46 // |
| 47 // Call on UI thread. | 47 // Call on UI thread. |
| 48 void Dispatch(); | 48 void Dispatch(); |
| 49 | 49 |
| 50 // Available on either thread. | 50 // Available on either thread. |
| 51 const GURL& request_url() const { return request_url_; } | 51 const GURL& request_url() const { return request_url_; } |
| 52 | 52 |
| 53 // Available on either thread. | 53 // Available on either thread. |
| 54 ResourceType::Type resource_type() const { return resource_type_; } | 54 ResourceType::Type resource_type() const { return resource_type_; } |
| 55 | 55 |
| 56 // Available on either thread. | 56 // Available on either thread. |
| 57 const std::string& frame_origin() const { return frame_origin_; } | 57 const std::string& frame_origin() const { return frame_origin_; } |
| 58 | 58 |
| 59 // Available on either thread. | 59 // Available on either thread. |
| 60 const std::string& main_frame_origin() const { return main_frame_origin_; } | 60 const std::string& main_frame_origin() const { return main_frame_origin_; } |
| 61 | 61 |
| 62 // Returns the TabContents this object is associated with. Should be | 62 // Returns the TabContents this object is associated with. Should be |
| 63 // called from the UI thread. | 63 // called from the UI thread. |
| 64 TabContents* GetTabContents(); | 64 TabContents* GetTabContents(); |
| 65 | 65 |
| 66 // Cancels the associated URLRequest. | 66 // Cancels the associated net::URLRequest. |
| 67 // This method can be called from OnDispatchFailed and OnDispatched. | 67 // This method can be called from OnDispatchFailed and OnDispatched. |
| 68 void CancelRequest(); | 68 void CancelRequest(); |
| 69 | 69 |
| 70 // Continue the URLRequest ignoring any previous errors. Note that some | 70 // Continue the net::URLRequest ignoring any previous errors. Note that some |
| 71 // errors cannot be ignored, in which case this will result in the request | 71 // errors cannot be ignored, in which case this will result in the request |
| 72 // being canceled. | 72 // being canceled. |
| 73 // This method can be called from OnDispatchFailed and OnDispatched. | 73 // This method can be called from OnDispatchFailed and OnDispatched. |
| 74 void ContinueRequest(); | 74 void ContinueRequest(); |
| 75 | 75 |
| 76 // Cancels the associated URLRequest and mark it as denied. The renderer | 76 // Cancels the associated net::URLRequest and mark it as denied. The renderer |
| 77 // processes such request in a special manner, optionally replacing them | 77 // processes such request in a special manner, optionally replacing them |
| 78 // with alternate content (typically frames content is replaced with a | 78 // with alternate content (typically frames content is replaced with a |
| 79 // warning message). | 79 // warning message). |
| 80 // This method can be called from OnDispatchFailed and OnDispatched. | 80 // This method can be called from OnDispatchFailed and OnDispatched. |
| 81 void DenyRequest(); | 81 void DenyRequest(); |
| 82 | 82 |
| 83 // Does nothing on the URLRequest but ensures the current instance ref | 83 // Does nothing on the net::URLRequest but ensures the current instance ref |
| 84 // count is decremented appropriately. Subclasses that do not want to | 84 // count is decremented appropriately. Subclasses that do not want to |
| 85 // take any specific actions in their OnDispatched/OnDispatchFailed should | 85 // take any specific actions in their OnDispatched/OnDispatchFailed should |
| 86 // call this. | 86 // call this. |
| 87 void TakeNoAction(); | 87 void TakeNoAction(); |
| 88 | 88 |
| 89 protected: | 89 protected: |
| 90 friend class base::RefCountedThreadSafe<SSLErrorHandler>; | 90 friend class base::RefCountedThreadSafe<SSLErrorHandler>; |
| 91 | 91 |
| 92 // Construct on the IO thread. | 92 // Construct on the IO thread. |
| 93 SSLErrorHandler(ResourceDispatcherHost* resource_dispatcher_host, | 93 SSLErrorHandler(ResourceDispatcherHost* resource_dispatcher_host, |
| 94 net::URLRequest* request, | 94 net::URLRequest* request, |
| 95 ResourceType::Type resource_type, | 95 ResourceType::Type resource_type, |
| 96 const std::string& frame_origin, | 96 const std::string& frame_origin, |
| 97 const std::string& main_frame_origin); | 97 const std::string& main_frame_origin); |
| 98 | 98 |
| 99 virtual ~SSLErrorHandler(); | 99 virtual ~SSLErrorHandler(); |
| 100 | 100 |
| 101 // The following 2 methods are the methods subclasses should implement. | 101 // The following 2 methods are the methods subclasses should implement. |
| 102 virtual void OnDispatchFailed(); | 102 virtual void OnDispatchFailed(); |
| 103 | 103 |
| 104 // Can use the manager_ member. | 104 // Can use the manager_ member. |
| 105 virtual void OnDispatched(); | 105 virtual void OnDispatched(); |
| 106 | 106 |
| 107 // Should only be accessed on the UI thread. | 107 // Should only be accessed on the UI thread. |
| 108 SSLManager* manager_; // Our manager. | 108 SSLManager* manager_; // Our manager. |
| 109 | 109 |
| 110 // The id of the URLRequest associated with this object. | 110 // The id of the net::URLRequest associated with this object. |
| 111 // Should only be accessed from the IO thread. | 111 // Should only be accessed from the IO thread. |
| 112 GlobalRequestID request_id_; | 112 GlobalRequestID request_id_; |
| 113 | 113 |
| 114 // The ResourceDispatcherHost we are associated with. | 114 // The ResourceDispatcherHost we are associated with. |
| 115 ResourceDispatcherHost* resource_dispatcher_host_; | 115 ResourceDispatcherHost* resource_dispatcher_host_; |
| 116 | 116 |
| 117 private: | 117 private: |
| 118 // Completes the CancelRequest operation on the IO thread. | 118 // Completes the CancelRequest operation on the IO thread. |
| 119 // Call on the IO thread. | 119 // Call on the IO thread. |
| 120 void CompleteCancelRequest(int error); | 120 void CompleteCancelRequest(int error); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 143 const ResourceType::Type resource_type_; | 143 const ResourceType::Type resource_type_; |
| 144 | 144 |
| 145 // The origin of the frame associated with this request. | 145 // The origin of the frame associated with this request. |
| 146 // This read-only member can be accessed on any thread. | 146 // This read-only member can be accessed on any thread. |
| 147 const std::string frame_origin_; | 147 const std::string frame_origin_; |
| 148 | 148 |
| 149 // The origin of the main frame associated with this request. | 149 // The origin of the main frame associated with this request. |
| 150 // This read-only member can be accessed on any thread. | 150 // This read-only member can be accessed on any thread. |
| 151 const std::string main_frame_origin_; | 151 const std::string main_frame_origin_; |
| 152 | 152 |
| 153 // A flag to make sure we notify the URLRequest exactly once. | 153 // A flag to make sure we notify the net::URLRequest exactly once. |
| 154 // Should only be accessed on the IO thread | 154 // Should only be accessed on the IO thread |
| 155 bool request_has_been_notified_; | 155 bool request_has_been_notified_; |
| 156 | 156 |
| 157 DISALLOW_COPY_AND_ASSIGN(SSLErrorHandler); | 157 DISALLOW_COPY_AND_ASSIGN(SSLErrorHandler); |
| 158 }; | 158 }; |
| 159 | 159 |
| 160 #endif // CHROME_BROWSER_SSL_SSL_ERROR_HANDLER_H_ | 160 #endif // CHROME_BROWSER_SSL_SSL_ERROR_HANDLER_H_ |
| OLD | NEW |