| 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 #pragma once |    7 #pragma once | 
|    8  |    8  | 
|    9 #include <map> |    9 #include <map> | 
|   10 #include <string> |   10 #include <string> | 
|   11 #include <vector> |   11 #include <vector> | 
|   12  |   12  | 
|   13 #include "base/basictypes.h" |   13 #include "base/basictypes.h" | 
|   14 #include "base/memory/ref_counted.h" |  | 
|   15 #include "base/sequenced_task_runner_helpers.h" |   14 #include "base/sequenced_task_runner_helpers.h" | 
|   16 #include "base/values.h" |   15 #include "base/values.h" | 
|   17 #include "chrome/browser/profiles/profile.h" |   16 #include "chrome/browser/profiles/profile.h" | 
|   18 #include "chrome/browser/shell_integration.h" |   17 #include "chrome/browser/shell_integration.h" | 
|   19 #include "chrome/common/custom_handlers/protocol_handler.h" |   18 #include "chrome/common/custom_handlers/protocol_handler.h" | 
|   20 #include "content/public/browser/browser_thread.h" |   19 #include "content/public/browser/browser_thread.h" | 
|   21 #include "content/public/browser/notification_service.h" |   20 #include "content/public/browser/notification_service.h" | 
|   22 #include "net/url_request/url_request.h" |   21 #include "net/url_request/url_request.h" | 
|   23 #include "net/url_request/url_request_job.h" |   22 #include "net/url_request/url_request_job.h" | 
|   24  |   23  | 
|   25 // This is where handlers for protocols registered with |   24 // This is where handlers for protocols registered with | 
|   26 // navigator.registerProtocolHandler() are registered. Each Profile owns an |   25 // navigator.registerProtocolHandler() are registered. Each Profile owns an | 
|   27 // instance of this class, which is initialized on browser start through |   26 // instance of this class, which is initialized on browser start through | 
|   28 // Profile::InitRegisteredProtocolHandlers(), and they should be the only |   27 // Profile::InitRegisteredProtocolHandlers(), and they should be the only | 
|   29 // instances of this class. |   28 // instances of this class. | 
|   30  |   29  | 
|   31 class ProtocolHandlerRegistry |   30 class ProtocolHandlerRegistry : public ProfileKeyedService { | 
|   32     : public base::RefCountedThreadSafe< |   31  | 
|   33           ProtocolHandlerRegistry, content::BrowserThread::DeleteOnIOThread> { |  | 
|   34  public: |   32  public: | 
|   35   class DefaultClientObserver |   33   class DefaultClientObserver | 
|   36       : public ShellIntegration::DefaultWebClientObserver { |   34       : public ShellIntegration::DefaultWebClientObserver { | 
|   37    public: |   35    public: | 
|   38     explicit DefaultClientObserver(ProtocolHandlerRegistry* registry); |   36     explicit DefaultClientObserver(ProtocolHandlerRegistry* registry); | 
|   39     virtual ~DefaultClientObserver(); |   37     virtual ~DefaultClientObserver(); | 
|   40  |   38  | 
|   41     // Get response from the worker regarding whether Chrome is the default |   39     // Get response from the worker regarding whether Chrome is the default | 
|   42     // handler for the protocol. |   40     // handler for the protocol. | 
|   43     virtual void SetDefaultWebClientUIState( |   41     virtual void SetDefaultWebClientUIState( | 
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  110   // Returns a list of protocol handlers that can be replaced by the given |  108   // Returns a list of protocol handlers that can be replaced by the given | 
|  111   // handler. |  109   // handler. | 
|  112   ProtocolHandlerList GetReplacedHandlers(const ProtocolHandler& handler) const; |  110   ProtocolHandlerList GetReplacedHandlers(const ProtocolHandler& handler) const; | 
|  113  |  111  | 
|  114   // Clears the default for the provided protocol. |  112   // Clears the default for the provided protocol. | 
|  115   void ClearDefault(const std::string& scheme); |  113   void ClearDefault(const std::string& scheme); | 
|  116  |  114  | 
|  117   // Returns true if this handler is the default handler for its protocol. |  115   // Returns true if this handler is the default handler for its protocol. | 
|  118   bool IsDefault(const ProtocolHandler& handler) const; |  116   bool IsDefault(const ProtocolHandler& handler) const; | 
|  119  |  117  | 
 |  118   // Initializes default protocol setttings and loads them from prefs. | 
 |  119   void InitProtocolSettings(); | 
 |  120  | 
|  120   // Loads a user's registered protocol handlers. |  121   // Loads a user's registered protocol handlers. | 
|  121   void Load(); |  122   void Load(); | 
|  122  |  123  | 
|  123   // Returns the offset in the list of handlers for a protocol of the default |  124   // Returns the offset in the list of handlers for a protocol of the default | 
|  124   // handler for that protocol. |  125   // handler for that protocol. | 
|  125   int GetHandlerIndex(const std::string& scheme) const; |  126   int GetHandlerIndex(const std::string& scheme) const; | 
|  126  |  127  | 
|  127   // Get the list of protocol handlers for the given scheme. |  128   // Get the list of protocol handlers for the given scheme. | 
|  128   ProtocolHandlerList GetHandlersFor(const std::string& scheme) const; |  129   ProtocolHandlerList GetHandlersFor(const std::string& scheme) const; | 
|  129  |  130  | 
| (...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  289   bool is_loaded_; |  290   bool is_loaded_; | 
|  290  |  291  | 
|  291   DefaultClientObserverList default_client_observers_; |  292   DefaultClientObserverList default_client_observers_; | 
|  292  |  293  | 
|  293   // Copy of default_handlers_ that is only accessed on the IO thread. |  294   // Copy of default_handlers_ that is only accessed on the IO thread. | 
|  294   ProtocolHandlerMap default_handlers_io_; |  295   ProtocolHandlerMap default_handlers_io_; | 
|  295  |  296  | 
|  296   DISALLOW_COPY_AND_ASSIGN(ProtocolHandlerRegistry); |  297   DISALLOW_COPY_AND_ASSIGN(ProtocolHandlerRegistry); | 
|  297 }; |  298 }; | 
|  298 #endif  // CHROME_BROWSER_CUSTOM_HANDLERS_PROTOCOL_HANDLER_REGISTRY_H_ |  299 #endif  // CHROME_BROWSER_CUSTOM_HANDLERS_PROTOCOL_HANDLER_REGISTRY_H_ | 
| OLD | NEW |