Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <map> | 9 #include <map> |
| 10 #include <string> | 10 #include <string> |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 127 // Get the list of protocol handlers for the given scheme. | 127 // Get the list of protocol handlers for the given scheme. |
| 128 ProtocolHandlerList GetHandlersFor(const std::string& scheme) const; | 128 ProtocolHandlerList GetHandlersFor(const std::string& scheme) const; |
| 129 | 129 |
| 130 // Get the list of ignored protocol handlers. | 130 // Get the list of ignored protocol handlers. |
| 131 ProtocolHandlerList GetIgnoredHandlers(); | 131 ProtocolHandlerList GetIgnoredHandlers(); |
| 132 | 132 |
| 133 // Yields a list of the protocols that have handlers registered in this | 133 // Yields a list of the protocols that have handlers registered in this |
| 134 // registry. | 134 // registry. |
| 135 void GetRegisteredProtocols(std::vector<std::string>* output) const; | 135 void GetRegisteredProtocols(std::vector<std::string>* output) const; |
| 136 | 136 |
| 137 // Returns true if the presented scheme is a build in scheme. | |
| 138 bool IsFixedHandler(const std::string& scheme) const; | |
| 139 | |
| 137 // Returns true if we allow websites to register handlers for the given | 140 // Returns true if we allow websites to register handlers for the given |
| 138 // scheme. | 141 // scheme. |
| 139 bool CanSchemeBeOverridden(const std::string& scheme) const; | 142 bool CanSchemeBeOverridden(const std::string& scheme) const; |
| 140 | 143 |
| 141 // Returns true if an identical protocol handler has already been registered. | 144 // Returns true if an identical protocol handler has already been registered. |
| 142 bool IsRegistered(const ProtocolHandler& handler) const; | 145 bool IsRegistered(const ProtocolHandler& handler) const; |
| 143 | 146 |
| 144 // Returns true if an identical protocol handler is being ignored. | 147 // Returns true if an identical protocol handler is being ignored. |
| 145 bool IsIgnored(const ProtocolHandler& handler) const; | 148 bool IsIgnored(const ProtocolHandler& handler) const; |
| 146 | 149 |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 187 void Finalize(); | 190 void Finalize(); |
| 188 | 191 |
| 189 // Registers the preferences that we store registered protocol handlers in. | 192 // Registers the preferences that we store registered protocol handlers in. |
| 190 static void RegisterPrefs(PrefService* prefService); | 193 static void RegisterPrefs(PrefService* prefService); |
| 191 | 194 |
| 192 bool enabled() const { return enabled_; } | 195 bool enabled() const { return enabled_; } |
| 193 | 196 |
| 194 private: | 197 private: |
| 195 friend class base::RefCountedThreadSafe<ProtocolHandlerRegistry>; | 198 friend class base::RefCountedThreadSafe<ProtocolHandlerRegistry>; |
| 196 | 199 |
| 200 // Install the default handlers. | |
| 201 void InstallSystemDefaultHandlers(); | |
|
benwells
2012/04/20 00:25:05
Can this be called InstallFixedHandlers to be cons
Mr4D (OOO till 08-26)
2012/04/20 13:44:41
Done.
| |
| 202 | |
| 197 // Puts the given handler at the top of the list of handlers for its | 203 // Puts the given handler at the top of the list of handlers for its |
| 198 // protocol. | 204 // protocol. |
| 199 void PromoteHandler(const ProtocolHandler& handler); | 205 void PromoteHandler(const ProtocolHandler& handler); |
| 200 | 206 |
| 201 // Clears the default for the provided protocol. | 207 // Clears the default for the provided protocol. |
| 202 // Should be called only from the IO thread. | 208 // Should be called only from the IO thread. |
| 203 void ClearDefaultIO(const std::string& scheme); | 209 void ClearDefaultIO(const std::string& scheme); |
| 204 | 210 |
| 205 // Makes this ProtocolHandler the default handler for its protocol. | 211 // Makes this ProtocolHandler the default handler for its protocol. |
| 206 // Should be called only from the IO thread. | 212 // Should be called only from the IO thread. |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 270 // If false then registered protocol handlers will not be used to handle | 276 // If false then registered protocol handlers will not be used to handle |
| 271 // requests. | 277 // requests. |
| 272 bool enabled_; | 278 bool enabled_; |
| 273 | 279 |
| 274 // Copy of enabled_ that is only accessed on the IO thread. | 280 // Copy of enabled_ that is only accessed on the IO thread. |
| 275 bool enabled_io_; | 281 bool enabled_io_; |
| 276 | 282 |
| 277 // Whether or not we are loading. | 283 // Whether or not we are loading. |
| 278 bool is_loading_; | 284 bool is_loading_; |
| 279 | 285 |
| 286 // Once predefined defaults are set, this will be set and an overwrite of | |
| 287 // them won't be possible anymore. | |
| 288 bool locking_defaults_; | |
|
benwells
2012/04/20 00:25:05
This variable name is confusing. Can it be renamed
Mr4D (OOO till 08-26)
2012/04/20 13:44:41
Done.
| |
| 289 | |
| 280 DefaultClientObserverList default_client_observers_; | 290 DefaultClientObserverList default_client_observers_; |
| 281 | 291 |
| 282 // Copy of default_handlers_ that is only accessed on the IO thread. | 292 // Copy of default_handlers_ that is only accessed on the IO thread. |
| 283 ProtocolHandlerMap default_handlers_io_; | 293 ProtocolHandlerMap default_handlers_io_; |
| 284 | 294 |
| 285 friend class ProtocolHandlerRegistryTest; | 295 friend class ProtocolHandlerRegistryTest; |
| 286 friend class RegisterProtocolHandlerBrowserTest; | 296 friend class RegisterProtocolHandlerBrowserTest; |
| 287 | 297 |
| 288 DISALLOW_COPY_AND_ASSIGN(ProtocolHandlerRegistry); | 298 DISALLOW_COPY_AND_ASSIGN(ProtocolHandlerRegistry); |
| 289 }; | 299 }; |
| 290 #endif // CHROME_BROWSER_CUSTOM_HANDLERS_PROTOCOL_HANDLER_REGISTRY_H_ | 300 #endif // CHROME_BROWSER_CUSTOM_HANDLERS_PROTOCOL_HANDLER_REGISTRY_H_ |
| OLD | NEW |