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
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_UI_WEBUI_OPTIONS_HANDLER_OPTIONS_HANDLER_H_
6 #define CHROME_BROWSER_UI_WEBUI_OPTIONS_HANDLER_OPTIONS_HANDLER_H_
10 #include "chrome/browser/custom_handlers/protocol_handler_registry.h"
11 #include "chrome/browser/ui/webui/options/options_ui.h"
12 #include "chrome/common/custom_handlers/protocol_handler.h"
13 #include "content/public/browser/notification_observer.h"
14 #include "content/public/browser/notification_registrar.h"
16 ////////////////////////////////////////////////////////////////////////////////
17 // HandlerOptionsHandler
19 // Listen for changes to protocol handlers (i.e. registerProtocolHandler()).
20 // This get triggered whenever a user allows a specific website or application
21 // to handle clicks on a link with a specified protocol (i.e. mailto: -> Gmail).
24 class DictionaryValue
;
29 class HandlerOptionsHandler
: public OptionsPageUIHandler
,
30 public content::NotificationObserver
{
32 HandlerOptionsHandler();
33 virtual ~HandlerOptionsHandler();
35 // OptionsPageUIHandler implementation.
36 virtual void GetLocalizedValues(
37 base::DictionaryValue
* localized_strings
) OVERRIDE
;
38 virtual void InitializeHandler() OVERRIDE
;
39 virtual void InitializePage() OVERRIDE
;
40 virtual void RegisterMessages() OVERRIDE
;
42 // content::NotificationObserver implementation.
43 virtual void Observe(int type
,
44 const content::NotificationSource
& source
,
45 const content::NotificationDetails
& details
) OVERRIDE
;
48 // Called when the user toggles whether custom handlers are enabled.
49 void SetHandlersEnabled(const base::ListValue
* args
);
51 // Called when the user sets a new default handler for a protocol.
52 void SetDefault(const base::ListValue
* args
);
54 // Called when the user clears the default handler for a protocol.
55 // |args| is the string name of the protocol to clear.
56 void ClearDefault(const base::ListValue
* args
);
58 // Parses a ProtocolHandler out of the arguments passed back from the view.
59 // |args| is a list of [protocol, url, title].
60 ProtocolHandler
ParseHandlerFromArgs(const base::ListValue
* args
) const;
62 // Returns a JSON object describing the set of protocol handlers for the
64 void GetHandlersForProtocol(const std::string
& protocol
,
65 base::DictionaryValue
* value
);
67 // Returns a JSON list of the ignored protocol handlers.
68 void GetIgnoredHandlers(base::ListValue
* handlers
);
70 // Called when the JS PasswordManager object is initialized.
71 void UpdateHandlerList();
74 // |args| is a list of [protocol, url, title].
75 void RemoveHandler(const base::ListValue
* args
);
77 // Remove an ignored handler.
78 // |args| is a list of [protocol, url, title].
79 void RemoveIgnoredHandler(const base::ListValue
* args
);
81 ProtocolHandlerRegistry
* GetProtocolHandlerRegistry();
83 content::NotificationRegistrar notification_registrar_
;
85 DISALLOW_COPY_AND_ASSIGN(HandlerOptionsHandler
);
88 } // namespace options
90 #endif // CHROME_BROWSER_UI_WEBUI_OPTIONS_HANDLER_OPTIONS_HANDLER_H_