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_OPTIONS2_OPTIONS_UI2_H_ | 5 #ifndef CHROME_BROWSER_UI_WEBUI_OPTIONS2_OPTIONS_UI2_H_ |
6 #define CHROME_BROWSER_UI_WEBUI_OPTIONS2_OPTIONS_UI2_H_ | 6 #define CHROME_BROWSER_UI_WEBUI_OPTIONS2_OPTIONS_UI2_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <string> | 9 #include <string> |
| 10 #include <vector> |
10 | 11 |
11 #include "base/compiler_specific.h" | 12 #include "base/compiler_specific.h" |
12 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
13 #include "chrome/browser/ui/webui/chrome_url_data_manager.h" | 14 #include "chrome/browser/ui/webui/chrome_url_data_manager.h" |
14 #include "content/browser/webui/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 #include "content/public/browser/web_ui_controller.h" | 18 #include "content/public/browser/web_ui_controller.h" |
19 #include "content/public/browser/web_ui_message_handler.h" | 19 #include "content/public/browser/web_ui_message_handler.h" |
20 | 20 |
21 namespace options2 { | 21 namespace options2 { |
22 | 22 |
23 // The base class handler of Javascript messages of options pages. | 23 // The base class handler of Javascript messages of options pages. |
24 class OptionsPageUIHandler : public content::WebUIMessageHandler, | 24 class OptionsPageUIHandler : public content::WebUIMessageHandler, |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 // should provide. | 75 // should provide. |
76 class OptionsPageUIHandlerHost { | 76 class OptionsPageUIHandlerHost { |
77 public: | 77 public: |
78 virtual void InitializeHandlers() = 0; | 78 virtual void InitializeHandlers() = 0; |
79 | 79 |
80 protected: | 80 protected: |
81 virtual ~OptionsPageUIHandlerHost() {} | 81 virtual ~OptionsPageUIHandlerHost() {} |
82 }; | 82 }; |
83 | 83 |
84 // The WebUI for chrome:settings-frame. | 84 // The WebUI for chrome:settings-frame. |
85 class OptionsUI : public WebUI, public content::WebUIController, | 85 class OptionsUI : public content::WebUIController, |
86 public OptionsPageUIHandlerHost { | 86 public OptionsPageUIHandlerHost { |
87 public: | 87 public: |
88 explicit OptionsUI(content::WebContents* contents); | 88 explicit OptionsUI(WebUI* web_ui); |
89 virtual ~OptionsUI(); | 89 virtual ~OptionsUI(); |
90 | 90 |
91 static RefCountedMemory* GetFaviconResourceBytes(); | 91 static RefCountedMemory* GetFaviconResourceBytes(); |
92 | 92 |
93 // WebUIController implementation. | 93 // WebUIController implementation. |
94 virtual void RenderViewCreated(RenderViewHost* render_view_host) OVERRIDE; | 94 virtual void RenderViewCreated(RenderViewHost* render_view_host) OVERRIDE; |
95 virtual void RenderViewReused(RenderViewHost* render_view_host) OVERRIDE; | 95 virtual void RenderViewReused(RenderViewHost* render_view_host) OVERRIDE; |
96 virtual void DidBecomeActiveForReusedRenderView() OVERRIDE; | 96 virtual void DidBecomeActiveForReusedRenderView() OVERRIDE; |
97 | 97 |
98 // Overridden from OptionsPageUIHandlerHost: | 98 // Overridden from OptionsPageUIHandlerHost: |
99 virtual void InitializeHandlers() OVERRIDE; | 99 virtual void InitializeHandlers() OVERRIDE; |
100 | 100 |
101 private: | 101 private: |
102 // Adds OptionsPageUiHandler to the handlers list if handler is enabled. | 102 // Adds OptionsPageUiHandler to the handlers list if handler is enabled. |
103 void AddOptionsPageUIHandler(base::DictionaryValue* localized_strings, | 103 void AddOptionsPageUIHandler(base::DictionaryValue* localized_strings, |
104 OptionsPageUIHandler* handler); | 104 OptionsPageUIHandler* handler); |
105 | 105 |
106 // Sets the WebUI CommandLineString property with arguments passed while | 106 // Sets the WebUI CommandLineString property with arguments passed while |
107 // launching chrome. | 107 // launching chrome. |
108 void SetCommandLineString(RenderViewHost* render_view_host); | 108 void SetCommandLineString(RenderViewHost* render_view_host); |
109 | 109 |
110 bool initialized_handlers_; | 110 bool initialized_handlers_; |
111 | 111 |
| 112 std::vector<OptionsPageUIHandler*> handlers_; |
| 113 |
112 DISALLOW_COPY_AND_ASSIGN(OptionsUI); | 114 DISALLOW_COPY_AND_ASSIGN(OptionsUI); |
113 }; | 115 }; |
114 | 116 |
115 } // namespace options2 | 117 } // namespace options2 |
116 | 118 |
117 #endif // CHROME_BROWSER_UI_WEBUI_OPTIONS2_OPTIONS_UI2_H_ | 119 #endif // CHROME_BROWSER_UI_WEBUI_OPTIONS2_OPTIONS_UI2_H_ |
OLD | NEW |