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 namespace user_prefs { |
27 class PrefRegistrySyncable; | 28 class PrefRegistrySyncable; |
| 29 } |
28 | 30 |
29 // This is where handlers for protocols registered with | 31 // This is where handlers for protocols registered with |
30 // navigator.registerProtocolHandler() are registered. Each Profile owns an | 32 // navigator.registerProtocolHandler() are registered. Each Profile owns an |
31 // instance of this class, which is initialized on browser start through | 33 // instance of this class, which is initialized on browser start through |
32 // Profile::InitRegisteredProtocolHandlers(), and they should be the only | 34 // Profile::InitRegisteredProtocolHandlers(), and they should be the only |
33 // instances of this class. | 35 // instances of this class. |
34 class ProtocolHandlerRegistry : public ProfileKeyedService { | 36 class ProtocolHandlerRegistry : public ProfileKeyedService { |
35 | 37 |
36 public: | 38 public: |
37 // Provides notification of when the OS level user agent settings | 39 // Provides notification of when the OS level user agent settings |
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
225 | 227 |
226 // Puts this registry in the disabled state - registered protocol handlers | 228 // Puts this registry in the disabled state - registered protocol handlers |
227 // will not handle requests. | 229 // will not handle requests. |
228 void Disable(); | 230 void Disable(); |
229 | 231 |
230 // This is called by the UI thread when the system is shutting down. This | 232 // This is called by the UI thread when the system is shutting down. This |
231 // does finalization which must be done on the UI thread. | 233 // does finalization which must be done on the UI thread. |
232 virtual void Shutdown() OVERRIDE; | 234 virtual void Shutdown() OVERRIDE; |
233 | 235 |
234 // Registers the preferences that we store registered protocol handlers in. | 236 // Registers the preferences that we store registered protocol handlers in. |
235 static void RegisterUserPrefs(PrefRegistrySyncable* registry); | 237 static void RegisterUserPrefs(user_prefs::PrefRegistrySyncable* registry); |
236 | 238 |
237 bool enabled() const { return enabled_; } | 239 bool enabled() const { return enabled_; } |
238 | 240 |
239 // Add a predefined protocol handler. This has to be called before the first | 241 // Add a predefined protocol handler. This has to be called before the first |
240 // load command was issued, otherwise the command will be ignored. | 242 // load command was issued, otherwise the command will be ignored. |
241 void AddPredefinedHandler(const ProtocolHandler& handler); | 243 void AddPredefinedHandler(const ProtocolHandler& handler); |
242 | 244 |
243 private: | 245 private: |
244 friend class base::DeleteHelper<ProtocolHandlerRegistry>; | 246 friend class base::DeleteHelper<ProtocolHandlerRegistry>; |
245 friend struct content::BrowserThread::DeleteOnThread< | 247 friend struct content::BrowserThread::DeleteOnThread< |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
322 | 324 |
323 // Copy of registry data for use on the IO thread. Changes to the registry | 325 // Copy of registry data for use on the IO thread. Changes to the registry |
324 // are posted to the IO thread where updates are applied to this object. | 326 // are posted to the IO thread where updates are applied to this object. |
325 scoped_refptr<IOThreadDelegate> io_thread_delegate_; | 327 scoped_refptr<IOThreadDelegate> io_thread_delegate_; |
326 | 328 |
327 DefaultClientObserverList default_client_observers_; | 329 DefaultClientObserverList default_client_observers_; |
328 | 330 |
329 DISALLOW_COPY_AND_ASSIGN(ProtocolHandlerRegistry); | 331 DISALLOW_COPY_AND_ASSIGN(ProtocolHandlerRegistry); |
330 }; | 332 }; |
331 #endif // CHROME_BROWSER_CUSTOM_HANDLERS_PROTOCOL_HANDLER_REGISTRY_H_ | 333 #endif // CHROME_BROWSER_CUSTOM_HANDLERS_PROTOCOL_HANDLER_REGISTRY_H_ |
OLD | NEW |