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/sequenced_task_runner_helpers.h" | 14 #include "base/sequenced_task_runner_helpers.h" |
15 #include "base/values.h" | 15 #include "base/values.h" |
16 #include "chrome/browser/profiles/profile.h" | 16 #include "chrome/browser/profiles/profile.h" |
17 #include "chrome/browser/shell_integration.h" | 17 #include "chrome/browser/shell_integration.h" |
18 #include "chrome/common/custom_handlers/protocol_handler.h" | 18 #include "chrome/common/custom_handlers/protocol_handler.h" |
19 #include "content/public/browser/browser_thread.h" | 19 #include "content/public/browser/browser_thread.h" |
20 #include "content/public/browser/notification_service.h" | 20 #include "content/public/browser/notification_service.h" |
21 #include "net/url_request/url_request.h" | 21 #include "net/url_request/url_request.h" |
22 #include "net/url_request/url_request_job.h" | 22 #include "net/url_request/url_request_job.h" |
23 #include "net/url_request/url_request_job_factory.h" | 23 #include "net/url_request/url_request_job_factory.h" |
24 | 24 |
| 25 class PrefServiceSyncable; |
| 26 |
25 // This is where handlers for protocols registered with | 27 // This is where handlers for protocols registered with |
26 // navigator.registerProtocolHandler() are registered. Each Profile owns an | 28 // navigator.registerProtocolHandler() are registered. Each Profile owns an |
27 // instance of this class, which is initialized on browser start through | 29 // instance of this class, which is initialized on browser start through |
28 // Profile::InitRegisteredProtocolHandlers(), and they should be the only | 30 // Profile::InitRegisteredProtocolHandlers(), and they should be the only |
29 // instances of this class. | 31 // instances of this class. |
30 class ProtocolHandlerRegistry : public ProfileKeyedService { | 32 class ProtocolHandlerRegistry : public ProfileKeyedService { |
31 | 33 |
32 public: | 34 public: |
33 // Provides notification of when the OS level user agent settings | 35 // Provides notification of when the OS level user agent settings |
34 // are changed. | 36 // are changed. |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
184 | 186 |
185 // Puts this registry in the disabled state - registered protocol handlers | 187 // Puts this registry in the disabled state - registered protocol handlers |
186 // will not handle requests. | 188 // will not handle requests. |
187 void Disable(); | 189 void Disable(); |
188 | 190 |
189 // This is called by the UI thread when the system is shutting down. This | 191 // This is called by the UI thread when the system is shutting down. This |
190 // does finalization which must be done on the UI thread. | 192 // does finalization which must be done on the UI thread. |
191 virtual void Shutdown() OVERRIDE; | 193 virtual void Shutdown() OVERRIDE; |
192 | 194 |
193 // Registers the preferences that we store registered protocol handlers in. | 195 // Registers the preferences that we store registered protocol handlers in. |
194 static void RegisterPrefs(PrefService* prefService); | 196 static void RegisterUserPrefs(PrefServiceSyncable* prefService); |
195 | 197 |
196 bool enabled() const { return enabled_; } | 198 bool enabled() const { return enabled_; } |
197 | 199 |
198 // Add a predefined protocol handler. This has to be called before the first | 200 // Add a predefined protocol handler. This has to be called before the first |
199 // load command was issued, otherwise the command will be ignored. | 201 // load command was issued, otherwise the command will be ignored. |
200 void AddPredefinedHandler(const ProtocolHandler& handler); | 202 void AddPredefinedHandler(const ProtocolHandler& handler); |
201 | 203 |
202 private: | 204 private: |
203 friend class base::DeleteHelper<ProtocolHandlerRegistry>; | 205 friend class base::DeleteHelper<ProtocolHandlerRegistry>; |
204 friend struct content::BrowserThread::DeleteOnThread< | 206 friend struct content::BrowserThread::DeleteOnThread< |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
285 | 287 |
286 // Copy of registry data for use on the IO thread. Changes to the registry | 288 // Copy of registry data for use on the IO thread. Changes to the registry |
287 // are posted to the IO thread where updates are applied to this object. | 289 // are posted to the IO thread where updates are applied to this object. |
288 scoped_refptr<Core> core_; | 290 scoped_refptr<Core> core_; |
289 | 291 |
290 DefaultClientObserverList default_client_observers_; | 292 DefaultClientObserverList default_client_observers_; |
291 | 293 |
292 DISALLOW_COPY_AND_ASSIGN(ProtocolHandlerRegistry); | 294 DISALLOW_COPY_AND_ASSIGN(ProtocolHandlerRegistry); |
293 }; | 295 }; |
294 #endif // CHROME_BROWSER_CUSTOM_HANDLERS_PROTOCOL_HANDLER_REGISTRY_H_ | 296 #endif // CHROME_BROWSER_CUSTOM_HANDLERS_PROTOCOL_HANDLER_REGISTRY_H_ |
OLD | NEW |