Chromium Code Reviews| 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 CHROME_BROWSER_CUSTOM_HANDLERS_PROTOCOL_HANDLER_REGISTRY_H_ | 5 #ifndef CHROME_BROWSER_CUSTOM_HANDLERS_PROTOCOL_HANDLER_REGISTRY_H_ |
| 6 #define CHROME_BROWSER_CUSTOM_HANDLERS_PROTOCOL_HANDLER_REGISTRY_H_ | 6 #define CHROME_BROWSER_CUSTOM_HANDLERS_PROTOCOL_HANDLER_REGISTRY_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 77 virtual ShellIntegration::DefaultProtocolClientWorker* CreateShellWorker( | 77 virtual ShellIntegration::DefaultProtocolClientWorker* CreateShellWorker( |
| 78 ShellIntegration::DefaultWebClientObserver* observer, | 78 ShellIntegration::DefaultWebClientObserver* observer, |
| 79 const std::string& protocol); | 79 const std::string& protocol); |
| 80 virtual DefaultClientObserver* CreateShellObserver( | 80 virtual DefaultClientObserver* CreateShellObserver( |
| 81 ProtocolHandlerRegistry* registry); | 81 ProtocolHandlerRegistry* registry); |
| 82 virtual void RegisterWithOSAsDefaultClient( | 82 virtual void RegisterWithOSAsDefaultClient( |
| 83 const std::string& protocol, | 83 const std::string& protocol, |
| 84 ProtocolHandlerRegistry* registry); | 84 ProtocolHandlerRegistry* registry); |
| 85 }; | 85 }; |
| 86 | 86 |
| 87 // Forward declaration of the internal implementation class. | |
| 88 class Core; | |
| 89 | |
| 90 class JobFactory : public net::URLRequestJobFactory { | |
| 91 public: | |
| 92 explicit JobFactory(Core* core); | |
| 93 virtual ~JobFactory(); | |
| 94 | |
| 95 // Set the URLRequestJobFactory where requests are passed if JobFactory | |
| 96 // decides to pass on them. | |
| 97 void Chain(scoped_ptr<net::URLRequestJobFactory> job_factory); | |
| 98 | |
| 99 // URLRequestJobFactory implementation | |
| 100 virtual bool SetProtocolHandler(const std::string& scheme, | |
| 101 ProtocolHandler* protocol_handler) OVERRIDE; | |
| 102 virtual void AddInterceptor(Interceptor* interceptor) OVERRIDE; | |
| 103 virtual net::URLRequestJob* MaybeCreateJobWithInterceptor( | |
| 104 net::URLRequest* request, | |
| 105 net::NetworkDelegate* network_delegate) const OVERRIDE; | |
| 106 virtual net::URLRequestJob* MaybeCreateJobWithProtocolHandler( | |
| 107 const std::string& scheme, | |
| 108 net::URLRequest* request, | |
| 109 net::NetworkDelegate* network_delegate) const OVERRIDE; | |
| 110 virtual net::URLRequestJob* MaybeInterceptRedirect( | |
| 111 const GURL& location, | |
| 112 net::URLRequest* request, | |
| 113 net::NetworkDelegate* network_delegate) const OVERRIDE; | |
| 114 virtual net::URLRequestJob* MaybeInterceptResponse( | |
| 115 net::URLRequest* request, | |
| 116 net::NetworkDelegate* network_delegate) const OVERRIDE; | |
| 117 virtual bool IsHandledProtocol(const std::string& scheme) const OVERRIDE; | |
| 118 virtual bool IsHandledURL(const GURL& url) const OVERRIDE; | |
| 119 | |
| 120 private: | |
| 121 scoped_ptr<URLRequestJobFactory> job_factory_; | |
| 122 scoped_refptr<Core> core_; | |
| 123 | |
| 124 DISALLOW_COPY_AND_ASSIGN(JobFactory); | |
| 125 }; | |
| 126 | |
| 87 typedef std::map<std::string, ProtocolHandler> ProtocolHandlerMap; | 127 typedef std::map<std::string, ProtocolHandler> ProtocolHandlerMap; |
| 88 typedef std::vector<ProtocolHandler> ProtocolHandlerList; | 128 typedef std::vector<ProtocolHandler> ProtocolHandlerList; |
| 89 typedef std::map<std::string, ProtocolHandlerList> ProtocolHandlerMultiMap; | 129 typedef std::map<std::string, ProtocolHandlerList> ProtocolHandlerMultiMap; |
| 90 typedef std::vector<DefaultClientObserver*> DefaultClientObserverList; | 130 typedef std::vector<DefaultClientObserver*> DefaultClientObserverList; |
| 91 | 131 |
| 92 // Creates a new instance. Assumes ownership of |delegate|. | 132 // Creates a new instance. Assumes ownership of |delegate|. |
| 93 ProtocolHandlerRegistry(Profile* profile, Delegate* delegate); | 133 ProtocolHandlerRegistry(Profile* profile, Delegate* delegate); |
| 94 virtual ~ProtocolHandlerRegistry(); | 134 virtual ~ProtocolHandlerRegistry(); |
| 95 | 135 |
| 96 // Returns a net::URLRequestJobFactory::Interceptor suitable | 136 // Returns a net::URLRequestJobFactory suitable for use on the IO thread, but |
| 97 // for use on the IO thread, but is initialized on the UI thread. | 137 // is initialized on the UI thread. Callers assume responsibility for deleting |
|
erikwright (departed)
2013/01/02 16:29:36
The switch to returning a scoped_ptr makes the "Ca
| |
| 98 // Callers assume responsibility for deleting this object. | 138 // this object. |
| 99 net::URLRequestJobFactory::Interceptor* CreateURLInterceptor(); | 139 scoped_ptr<JobFactory> CreateURLRequestJobFactory(); |
| 100 | 140 |
| 101 // Called when a site tries to register as a protocol handler. If the request | 141 // Called when a site tries to register as a protocol handler. If the request |
| 102 // can be handled silently by the registry - either to ignore the request | 142 // can be handled silently by the registry - either to ignore the request |
| 103 // or to update an existing handler - the request will succeed. If this | 143 // or to update an existing handler - the request will succeed. If this |
| 104 // function returns false the user needs to be prompted for confirmation. | 144 // function returns false the user needs to be prompted for confirmation. |
| 105 bool SilentlyHandleRegisterHandlerRequest(const ProtocolHandler& handler); | 145 bool SilentlyHandleRegisterHandlerRequest(const ProtocolHandler& handler); |
| 106 | 146 |
| 107 // Called when the user accepts the registration of a given protocol handler. | 147 // Called when the user accepts the registration of a given protocol handler. |
| 108 void OnAcceptRegisterProtocolHandler(const ProtocolHandler& handler); | 148 void OnAcceptRegisterProtocolHandler(const ProtocolHandler& handler); |
| 109 | 149 |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 205 friend class base::DeleteHelper<ProtocolHandlerRegistry>; | 245 friend class base::DeleteHelper<ProtocolHandlerRegistry>; |
| 206 friend struct content::BrowserThread::DeleteOnThread< | 246 friend struct content::BrowserThread::DeleteOnThread< |
| 207 content::BrowserThread::IO>; | 247 content::BrowserThread::IO>; |
| 208 | 248 |
| 209 // for access to InstallDefaultsForChromeOS | 249 // for access to InstallDefaultsForChromeOS |
| 210 friend class ProtocolHandlerRegistryFactory; | 250 friend class ProtocolHandlerRegistryFactory; |
| 211 | 251 |
| 212 friend class ProtocolHandlerRegistryTest; | 252 friend class ProtocolHandlerRegistryTest; |
| 213 friend class RegisterProtocolHandlerBrowserTest; | 253 friend class RegisterProtocolHandlerBrowserTest; |
| 214 | 254 |
| 215 // Forward declaration of the internal implementation classes. | |
| 216 class Core; | |
| 217 class URLInterceptor; | |
| 218 | |
| 219 // Puts the given handler at the top of the list of handlers for its | 255 // Puts the given handler at the top of the list of handlers for its |
| 220 // protocol. | 256 // protocol. |
| 221 void PromoteHandler(const ProtocolHandler& handler); | 257 void PromoteHandler(const ProtocolHandler& handler); |
| 222 | 258 |
| 223 // Saves a user's registered protocol handlers. | 259 // Saves a user's registered protocol handlers. |
| 224 void Save(); | 260 void Save(); |
| 225 | 261 |
| 226 // Returns a pointer to the list of handlers registered for the given scheme, | 262 // Returns a pointer to the list of handlers registered for the given scheme, |
| 227 // or NULL if there are none. | 263 // or NULL if there are none. |
| 228 const ProtocolHandlerList* GetHandlerList(const std::string& scheme) const; | 264 const ProtocolHandlerList* GetHandlerList(const std::string& scheme) const; |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 287 | 323 |
| 288 // Copy of registry data for use on the IO thread. Changes to the registry | 324 // Copy of registry data for use on the IO thread. Changes to the registry |
| 289 // are posted to the IO thread where updates are applied to this object. | 325 // are posted to the IO thread where updates are applied to this object. |
| 290 scoped_refptr<Core> core_; | 326 scoped_refptr<Core> core_; |
| 291 | 327 |
| 292 DefaultClientObserverList default_client_observers_; | 328 DefaultClientObserverList default_client_observers_; |
| 293 | 329 |
| 294 DISALLOW_COPY_AND_ASSIGN(ProtocolHandlerRegistry); | 330 DISALLOW_COPY_AND_ASSIGN(ProtocolHandlerRegistry); |
| 295 }; | 331 }; |
| 296 #endif // CHROME_BROWSER_CUSTOM_HANDLERS_PROTOCOL_HANDLER_REGISTRY_H_ | 332 #endif // CHROME_BROWSER_CUSTOM_HANDLERS_PROTOCOL_HANDLER_REGISTRY_H_ |
| OLD | NEW |