| OLD | NEW |
| (Empty) |
| 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. | |
| 4 | |
| 5 #ifndef CHROME_BROWSER_UI_WEBUI_OPTIONS2_HANDLER_OPTIONS_HANDLER2_H_ | |
| 6 #define CHROME_BROWSER_UI_WEBUI_OPTIONS2_HANDLER_OPTIONS_HANDLER2_H_ | |
| 7 | |
| 8 #include <string> | |
| 9 | |
| 10 #include "chrome/browser/custom_handlers/protocol_handler_registry.h" | |
| 11 #include "chrome/browser/ui/webui/options2/options_ui2.h" | |
| 12 #include "chrome/common/custom_handlers/protocol_handler.h" | |
| 13 #include "content/public/browser/notification_registrar.h" | |
| 14 | |
| 15 //////////////////////////////////////////////////////////////////////////////// | |
| 16 // HandlerOptionsHandler | |
| 17 | |
| 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). | |
| 21 | |
| 22 namespace base { | |
| 23 class DictionaryValue; | |
| 24 } | |
| 25 | |
| 26 namespace options2 { | |
| 27 | |
| 28 class HandlerOptionsHandler : public OptionsPageUIHandler { | |
| 29 public: | |
| 30 HandlerOptionsHandler(); | |
| 31 virtual ~HandlerOptionsHandler(); | |
| 32 | |
| 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; | |
| 39 | |
| 40 // content::NotificationObserver implementation. | |
| 41 virtual void Observe(int type, | |
| 42 const content::NotificationSource& source, | |
| 43 const content::NotificationDetails& details) OVERRIDE; | |
| 44 | |
| 45 private: | |
| 46 // Called when the user toggles whether custom handlers are enabled. | |
| 47 void SetHandlersEnabled(const ListValue* args); | |
| 48 | |
| 49 // Called when the user sets a new default handler for a protocol. | |
| 50 void SetDefault(const ListValue* args); | |
| 51 | |
| 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 ListValue* args); | |
| 55 | |
| 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 ListValue* args) const; | |
| 59 | |
| 60 // Returns a JSON object describing the set of protocol handlers for the | |
| 61 // given protocol. | |
| 62 void GetHandlersForProtocol(const std::string& protocol, | |
| 63 base::DictionaryValue* value); | |
| 64 | |
| 65 // Returns a JSON list of the ignored protocol handlers. | |
| 66 void GetIgnoredHandlers(ListValue* handlers); | |
| 67 | |
| 68 // Called when the JS PasswordManager object is initialized. | |
| 69 void UpdateHandlerList(); | |
| 70 | |
| 71 // Remove a handler. | |
| 72 // |args| is a list of [protocol, url, title]. | |
| 73 void RemoveHandler(const ListValue* args); | |
| 74 | |
| 75 // Remove an ignored handler. | |
| 76 // |args| is a list of [protocol, url, title]. | |
| 77 void RemoveIgnoredHandler(const ListValue* args); | |
| 78 | |
| 79 ProtocolHandlerRegistry* GetProtocolHandlerRegistry(); | |
| 80 | |
| 81 content::NotificationRegistrar notification_registrar_; | |
| 82 | |
| 83 DISALLOW_COPY_AND_ASSIGN(HandlerOptionsHandler); | |
| 84 }; | |
| 85 | |
| 86 } // namespace options2 | |
| 87 | |
| 88 #endif // CHROME_BROWSER_UI_WEBUI_OPTIONS2_HANDLER_OPTIONS_HANDLER2_H_ | |
| OLD | NEW |