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_OPTIONS2_OPTIONS_UI_H_ |
6 #define CHROME_BROWSER_UI_WEBUI_OPTIONS_OPTIONS_UI_H_ | 6 #define CHROME_BROWSER_UI_WEBUI_OPTIONS2_OPTIONS_UI_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 | 10 |
11 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
13 #include "chrome/browser/ui/webui/chrome_url_data_manager.h" | 13 #include "chrome/browser/ui/webui/chrome_url_data_manager.h" |
14 #include "chrome/browser/ui/webui/chrome_web_ui.h" | 14 #include "chrome/browser/ui/webui/chrome_web_ui.h" |
15 #include "content/public/browser/notification_observer.h" | 15 #include "content/public/browser/notification_observer.h" |
16 #include "content/public/browser/notification_registrar.h" | 16 #include "content/public/browser/notification_registrar.h" |
17 #include "content/public/browser/notification_types.h" | 17 #include "content/public/browser/notification_types.h" |
18 | 18 |
19 // The base class handler of Javascript messages of options pages. | 19 // The base class handler of Javascript messages of options pages. |
20 class OptionsPageUIHandler : public WebUIMessageHandler, | 20 class OptionsPage2UIHandler : public WebUIMessageHandler, |
21 public content::NotificationObserver { | 21 public content::NotificationObserver { |
22 public: | 22 public: |
23 OptionsPageUIHandler(); | 23 OptionsPage2UIHandler(); |
24 virtual ~OptionsPageUIHandler(); | 24 virtual ~OptionsPage2UIHandler(); |
25 | 25 |
26 // Is this handler enabled? | 26 // Is this handler enabled? |
27 virtual bool IsEnabled(); | 27 virtual bool IsEnabled(); |
28 | 28 |
29 // Collects localized strings for options page. | 29 // Collects localized strings for options page. |
30 virtual void GetLocalizedValues(base::DictionaryValue* localized_strings) = 0; | 30 virtual void GetLocalizedValues(base::DictionaryValue* localized_strings) = 0; |
31 | 31 |
32 // Initialize the page. Called once the DOM is available for manipulation. | 32 // Initialize the page. Called once the DOM is available for manipulation. |
33 // This will be called only once. | 33 // This will be called only once. |
34 virtual void Initialize() {} | 34 virtual void Initialize() {} |
(...skipping 22 matching lines...) Expand all Loading... |
57 size_t length); | 57 size_t length); |
58 | 58 |
59 // Registers string resources for a page's header and tab title. | 59 // Registers string resources for a page's header and tab title. |
60 static void RegisterTitle(base::DictionaryValue* localized_strings, | 60 static void RegisterTitle(base::DictionaryValue* localized_strings, |
61 const std::string& variable_name, | 61 const std::string& variable_name, |
62 int title_id); | 62 int title_id); |
63 | 63 |
64 content::NotificationRegistrar registrar_; | 64 content::NotificationRegistrar registrar_; |
65 | 65 |
66 private: | 66 private: |
67 DISALLOW_COPY_AND_ASSIGN(OptionsPageUIHandler); | 67 DISALLOW_COPY_AND_ASSIGN(OptionsPage2UIHandler); |
68 }; | 68 }; |
69 | 69 |
70 // An interface for common operations that a host of OptionsPageUIHandlers | 70 // An interface for common operations that a host of OptionsPage2UIHandlers |
71 // should provide. | 71 // should provide. |
72 class OptionsPageUIHandlerHost { | 72 class OptionsPage2UIHandlerHost { |
73 public: | 73 public: |
74 virtual void InitializeHandlers() = 0; | 74 virtual void InitializeHandlers() = 0; |
| 75 |
| 76 protected: |
| 77 virtual ~OptionsPage2UIHandlerHost() {} |
75 }; | 78 }; |
76 | 79 |
77 // The WebUI for chrome:settings. | 80 // The WebUI for chrome:settings-frame. |
78 class OptionsUI : public ChromeWebUI, | 81 class Options2UI : public ChromeWebUI, |
79 public OptionsPageUIHandlerHost { | 82 public OptionsPage2UIHandlerHost { |
80 public: | 83 public: |
81 explicit OptionsUI(TabContents* contents); | 84 explicit Options2UI(TabContents* contents); |
82 virtual ~OptionsUI(); | 85 virtual ~Options2UI(); |
83 | 86 |
84 static RefCountedMemory* GetFaviconResourceBytes(); | 87 static RefCountedMemory* GetFaviconResourceBytes(); |
85 | 88 |
86 // WebUI implementation. | 89 // WebUI implementation. |
87 virtual void RenderViewCreated(RenderViewHost* render_view_host) OVERRIDE; | 90 virtual void RenderViewCreated(RenderViewHost* render_view_host) OVERRIDE; |
88 virtual void RenderViewReused(RenderViewHost* render_view_host) OVERRIDE; | 91 virtual void RenderViewReused(RenderViewHost* render_view_host) OVERRIDE; |
89 virtual void DidBecomeActiveForReusedRenderView() OVERRIDE; | 92 virtual void DidBecomeActiveForReusedRenderView() OVERRIDE; |
90 | 93 |
91 // Overridden from OptionsPageUIHandlerHost: | 94 // Overridden from OptionsPage2UIHandlerHost: |
92 virtual void InitializeHandlers() OVERRIDE; | 95 virtual void InitializeHandlers() OVERRIDE; |
93 | 96 |
94 private: | 97 private: |
95 // Adds OptionsPageUiHandler to the handlers list if handler is enabled. | 98 // Adds OptionsPageUiHandler to the handlers list if handler is enabled. |
96 void AddOptionsPageUIHandler(base::DictionaryValue* localized_strings, | 99 void AddOptionsPageUIHandler(base::DictionaryValue* localized_strings, |
97 OptionsPageUIHandler* handler); | 100 OptionsPage2UIHandler* handler); |
98 | 101 |
99 // Sets the WebUI CommandLineString property with arguments passed while | 102 // Sets the WebUI CommandLineString property with arguments passed while |
100 // launching chrome. | 103 // launching chrome. |
101 void SetCommandLineString(RenderViewHost* render_view_host); | 104 void SetCommandLineString(RenderViewHost* render_view_host); |
102 | 105 |
103 bool initialized_handlers_; | 106 bool initialized_handlers_; |
104 | 107 |
105 DISALLOW_COPY_AND_ASSIGN(OptionsUI); | 108 DISALLOW_COPY_AND_ASSIGN(Options2UI); |
106 }; | 109 }; |
107 | 110 |
108 #endif // CHROME_BROWSER_UI_WEBUI_OPTIONS_OPTIONS_UI_H_ | 111 #endif // CHROME_BROWSER_UI_WEBUI_OPTIONS2_OPTIONS_UI_H_ |
OLD | NEW |