| 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> |
| 11 | 11 |
| 12 #include "base/basictypes.h" | 12 #include "base/basictypes.h" |
| 13 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
| 14 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
| 15 #include "base/sequenced_task_runner_helpers.h" | 15 #include "base/sequenced_task_runner_helpers.h" |
| 16 #include "base/values.h" | 16 #include "base/values.h" |
| 17 #include "chrome/browser/profiles/profile.h" | 17 #include "chrome/browser/profiles/profile.h" |
| 18 #include "chrome/browser/profiles/profile_keyed_service.h" | 18 #include "chrome/browser/profiles/profile_keyed_service.h" |
| 19 #include "chrome/browser/shell_integration.h" | 19 #include "chrome/browser/shell_integration.h" |
| 20 #include "chrome/common/custom_handlers/protocol_handler.h" | 20 #include "chrome/common/custom_handlers/protocol_handler.h" |
| 21 #include "content/public/browser/browser_thread.h" | 21 #include "content/public/browser/browser_thread.h" |
| 22 #include "content/public/browser/notification_service.h" | 22 #include "content/public/browser/notification_service.h" |
| 23 #include "net/url_request/url_request.h" | 23 #include "net/url_request/url_request.h" |
| 24 #include "net/url_request/url_request_job.h" | 24 #include "net/url_request/url_request_job.h" |
| 25 #include "net/url_request/url_request_job_factory.h" | 25 #include "net/url_request/url_request_job_factory.h" |
| 26 | 26 |
| 27 class PrefServiceSyncable; | 27 class PrefRegistrySyncable; |
| 28 | 28 |
| 29 // This is where handlers for protocols registered with | 29 // This is where handlers for protocols registered with |
| 30 // navigator.registerProtocolHandler() are registered. Each Profile owns an | 30 // navigator.registerProtocolHandler() are registered. Each Profile owns an |
| 31 // instance of this class, which is initialized on browser start through | 31 // instance of this class, which is initialized on browser start through |
| 32 // Profile::InitRegisteredProtocolHandlers(), and they should be the only | 32 // Profile::InitRegisteredProtocolHandlers(), and they should be the only |
| 33 // instances of this class. | 33 // instances of this class. |
| 34 class ProtocolHandlerRegistry : public ProfileKeyedService { | 34 class ProtocolHandlerRegistry : public ProfileKeyedService { |
| 35 | 35 |
| 36 public: | 36 public: |
| 37 // Provides notification of when the OS level user agent settings | 37 // Provides notification of when the OS level user agent settings |
| (...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 238 | 238 |
| 239 // Puts this registry in the disabled state - registered protocol handlers | 239 // Puts this registry in the disabled state - registered protocol handlers |
| 240 // will not handle requests. | 240 // will not handle requests. |
| 241 void Disable(); | 241 void Disable(); |
| 242 | 242 |
| 243 // This is called by the UI thread when the system is shutting down. This | 243 // This is called by the UI thread when the system is shutting down. This |
| 244 // does finalization which must be done on the UI thread. | 244 // does finalization which must be done on the UI thread. |
| 245 virtual void Shutdown() OVERRIDE; | 245 virtual void Shutdown() OVERRIDE; |
| 246 | 246 |
| 247 // Registers the preferences that we store registered protocol handlers in. | 247 // Registers the preferences that we store registered protocol handlers in. |
| 248 static void RegisterUserPrefs(PrefServiceSyncable* prefService); | 248 static void RegisterUserPrefs(PrefRegistrySyncable* registry); |
| 249 | 249 |
| 250 bool enabled() const { return enabled_; } | 250 bool enabled() const { return enabled_; } |
| 251 | 251 |
| 252 // Add a predefined protocol handler. This has to be called before the first | 252 // Add a predefined protocol handler. This has to be called before the first |
| 253 // load command was issued, otherwise the command will be ignored. | 253 // load command was issued, otherwise the command will be ignored. |
| 254 void AddPredefinedHandler(const ProtocolHandler& handler); | 254 void AddPredefinedHandler(const ProtocolHandler& handler); |
| 255 | 255 |
| 256 private: | 256 private: |
| 257 friend class base::DeleteHelper<ProtocolHandlerRegistry>; | 257 friend class base::DeleteHelper<ProtocolHandlerRegistry>; |
| 258 friend struct content::BrowserThread::DeleteOnThread< | 258 friend struct content::BrowserThread::DeleteOnThread< |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 335 | 335 |
| 336 // Copy of registry data for use on the IO thread. Changes to the registry | 336 // Copy of registry data for use on the IO thread. Changes to the registry |
| 337 // are posted to the IO thread where updates are applied to this object. | 337 // are posted to the IO thread where updates are applied to this object. |
| 338 scoped_refptr<IOThreadDelegate> io_thread_delegate_; | 338 scoped_refptr<IOThreadDelegate> io_thread_delegate_; |
| 339 | 339 |
| 340 DefaultClientObserverList default_client_observers_; | 340 DefaultClientObserverList default_client_observers_; |
| 341 | 341 |
| 342 DISALLOW_COPY_AND_ASSIGN(ProtocolHandlerRegistry); | 342 DISALLOW_COPY_AND_ASSIGN(ProtocolHandlerRegistry); |
| 343 }; | 343 }; |
| 344 #endif // CHROME_BROWSER_CUSTOM_HANDLERS_PROTOCOL_HANDLER_REGISTRY_H_ | 344 #endif // CHROME_BROWSER_CUSTOM_HANDLERS_PROTOCOL_HANDLER_REGISTRY_H_ |
| OLD | NEW |