| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_UI_WEBUI_OPTIONS_OPTIONS_UI_H_ | 5 #ifndef CHROME_BROWSER_UI_WEBUI_OPTIONS_OPTIONS_UI_H_ |
| 6 #define CHROME_BROWSER_UI_WEBUI_OPTIONS_OPTIONS_UI_H_ | 6 #define CHROME_BROWSER_UI_WEBUI_OPTIONS_OPTIONS_UI_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 class OptionsPageUIHandler : public WebUIMessageHandler, | 24 class OptionsPageUIHandler : public WebUIMessageHandler, |
| 25 public NotificationObserver { | 25 public NotificationObserver { |
| 26 public: | 26 public: |
| 27 OptionsPageUIHandler(); | 27 OptionsPageUIHandler(); |
| 28 virtual ~OptionsPageUIHandler(); | 28 virtual ~OptionsPageUIHandler(); |
| 29 | 29 |
| 30 // Is this handler enabled? | 30 // Is this handler enabled? |
| 31 virtual bool IsEnabled(); | 31 virtual bool IsEnabled(); |
| 32 | 32 |
| 33 // Collects localized strings for options page. | 33 // Collects localized strings for options page. |
| 34 virtual void GetLocalizedValues(DictionaryValue* localized_strings) = 0; | 34 virtual void GetLocalizedValues(base::DictionaryValue* localized_strings) = 0; |
| 35 | 35 |
| 36 // Initialize the page. Called once the DOM is available for manipulation. | 36 // Initialize the page. Called once the DOM is available for manipulation. |
| 37 // This will be called only once. | 37 // This will be called only once. |
| 38 virtual void Initialize() {} | 38 virtual void Initialize() {} |
| 39 | 39 |
| 40 // Uninitializes the page. Called just before the object is destructed. | 40 // Uninitializes the page. Called just before the object is destructed. |
| 41 virtual void Uninitialize() {} | 41 virtual void Uninitialize() {} |
| 42 | 42 |
| 43 // WebUIMessageHandler implementation. | 43 // WebUIMessageHandler implementation. |
| 44 virtual void RegisterMessages() {} | 44 virtual void RegisterMessages() {} |
| 45 | 45 |
| 46 // NotificationObserver implementation. | 46 // NotificationObserver implementation. |
| 47 virtual void Observe(int type, | 47 virtual void Observe(int type, |
| 48 const NotificationSource& source, | 48 const NotificationSource& source, |
| 49 const NotificationDetails& details) {} | 49 const NotificationDetails& details) {} |
| 50 | 50 |
| 51 void UserMetricsRecordAction(const UserMetricsAction& action); | 51 void UserMetricsRecordAction(const UserMetricsAction& action); |
| 52 | 52 |
| 53 protected: | 53 protected: |
| 54 struct OptionsStringResource { | 54 struct OptionsStringResource { |
| 55 // The name of the resource in templateData. | 55 // The name of the resource in templateData. |
| 56 const char* name; | 56 const char* name; |
| 57 // The .grd ID for the resource (IDS_*). | 57 // The .grd ID for the resource (IDS_*). |
| 58 int id; | 58 int id; |
| 59 }; | 59 }; |
| 60 // A helper for simplifying the process of registering strings in WebUI. | 60 // A helper for simplifying the process of registering strings in WebUI. |
| 61 static void RegisterStrings(DictionaryValue* localized_strings, | 61 static void RegisterStrings(base::DictionaryValue* localized_strings, |
| 62 const OptionsStringResource* resources, | 62 const OptionsStringResource* resources, |
| 63 size_t length); | 63 size_t length); |
| 64 | 64 |
| 65 // Registers string resources for a page's header and tab title. | 65 // Registers string resources for a page's header and tab title. |
| 66 static void RegisterTitle(DictionaryValue* localized_strings, | 66 static void RegisterTitle(base::DictionaryValue* localized_strings, |
| 67 const std::string& variable_name, | 67 const std::string& variable_name, |
| 68 int title_id); | 68 int title_id); |
| 69 | 69 |
| 70 NotificationRegistrar registrar_; | 70 NotificationRegistrar registrar_; |
| 71 | 71 |
| 72 private: | 72 private: |
| 73 DISALLOW_COPY_AND_ASSIGN(OptionsPageUIHandler); | 73 DISALLOW_COPY_AND_ASSIGN(OptionsPageUIHandler); |
| 74 }; | 74 }; |
| 75 | 75 |
| 76 // An interface for common operations that a host of OptionsPageUIHandlers | 76 // An interface for common operations that a host of OptionsPageUIHandlers |
| (...skipping 14 matching lines...) Expand all Loading... |
| 91 | 91 |
| 92 // Overridden from WebUI: | 92 // Overridden from WebUI: |
| 93 virtual void RenderViewCreated(RenderViewHost* render_view_host) OVERRIDE; | 93 virtual void RenderViewCreated(RenderViewHost* render_view_host) OVERRIDE; |
| 94 virtual void DidBecomeActiveForReusedRenderView() OVERRIDE; | 94 virtual void DidBecomeActiveForReusedRenderView() OVERRIDE; |
| 95 | 95 |
| 96 // Overridden from OptionsPageUIHandlerHost: | 96 // Overridden from OptionsPageUIHandlerHost: |
| 97 virtual void InitializeHandlers() OVERRIDE; | 97 virtual void InitializeHandlers() OVERRIDE; |
| 98 | 98 |
| 99 private: | 99 private: |
| 100 // Adds OptionsPageUiHandler to the handlers list if handler is enabled. | 100 // Adds OptionsPageUiHandler to the handlers list if handler is enabled. |
| 101 void AddOptionsPageUIHandler(DictionaryValue* localized_strings, | 101 void AddOptionsPageUIHandler(base::DictionaryValue* localized_strings, |
| 102 OptionsPageUIHandler* handler); | 102 OptionsPageUIHandler* handler); |
| 103 | 103 |
| 104 bool initialized_handlers_; | 104 bool initialized_handlers_; |
| 105 | 105 |
| 106 DISALLOW_COPY_AND_ASSIGN(OptionsUI); | 106 DISALLOW_COPY_AND_ASSIGN(OptionsUI); |
| 107 }; | 107 }; |
| 108 | 108 |
| 109 #endif // CHROME_BROWSER_UI_WEBUI_OPTIONS_OPTIONS_UI_H_ | 109 #endif // CHROME_BROWSER_UI_WEBUI_OPTIONS_OPTIONS_UI_H_ |
| OLD | NEW |