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_registrar.h"
15 ////////////////////////////////////////////////////////////////////////////////
16 // HandlerOptionsHandler
18 // Listen for changes to protocol handlers (i.e. registerProtocolHandler()).
19 // This get triggered whenever a user allows a specific website or application
20 // to handle clicks on a link with a specified protocol (i.e. mailto: -> Gmail).
23 class DictionaryValue
;
28 class HandlerOptionsHandler
: public OptionsPageUIHandler
{
30 HandlerOptionsHandler();
31 virtual ~HandlerOptionsHandler();
33 // OptionsPageUIHandler implementation.
34 virtual void GetLocalizedValues(
35 base::DictionaryValue
* localized_strings
) OVERRIDE
;
36 virtual void InitializeHandler() OVERRIDE
;
37 virtual void InitializePage() OVERRIDE
;
38 virtual void RegisterMessages() OVERRIDE
;
40 // content::NotificationObserver implementation.
41 virtual void Observe(int type
,
42 const content::NotificationSource
& source
,
43 const content::NotificationDetails
& details
) OVERRIDE
;
46 // Called when the user toggles whether custom handlers are enabled.
47 void SetHandlersEnabled(const base::ListValue
* args
);
49 // Called when the user sets a new default handler for a protocol.
50 void SetDefault(const base::ListValue
* args
);
52 // Called when the user clears the default handler for a protocol.
53 // |args| is the string name of the protocol to clear.
54 void ClearDefault(const base::ListValue
* args
);
56 // Parses a ProtocolHandler out of the arguments passed back from the view.
57 // |args| is a list of [protocol, url, title].
58 ProtocolHandler
ParseHandlerFromArgs(const base::ListValue
* args
) const;
60 // Returns a JSON object describing the set of protocol handlers for the
62 void GetHandlersForProtocol(const std::string
& protocol
,
63 base::DictionaryValue
* value
);
65 // Returns a JSON list of the ignored protocol handlers.
66 void GetIgnoredHandlers(base::ListValue
* handlers
);
68 // Called when the JS PasswordManager object is initialized.
69 void UpdateHandlerList();
72 // |args| is a list of [protocol, url, title].
73 void RemoveHandler(const base::ListValue
* args
);
75 // Remove an ignored handler.
76 // |args| is a list of [protocol, url, title].
77 void RemoveIgnoredHandler(const base::ListValue
* args
);
79 ProtocolHandlerRegistry
* GetProtocolHandlerRegistry();
81 content::NotificationRegistrar notification_registrar_
;
83 DISALLOW_COPY_AND_ASSIGN(HandlerOptionsHandler
);
86 } // namespace options
88 #endif // CHROME_BROWSER_UI_WEBUI_OPTIONS_HANDLER_OPTIONS_HANDLER_H_