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 #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 // The base class handler of Javascript messages of options pages. | 21 // The base class handler of Javascript messages of options pages. |
22 class OptionsPageUIHandler : public content::WebUIMessageHandler, | 22 class OptionsPageUIHandler : public content::WebUIMessageHandler, |
23 public content::NotificationObserver { | 23 public content::NotificationObserver { |
24 public: | 24 public: |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
73 // should provide. | 73 // should provide. |
74 class OptionsPageUIHandlerHost { | 74 class OptionsPageUIHandlerHost { |
75 public: | 75 public: |
76 virtual void InitializeHandlers() = 0; | 76 virtual void InitializeHandlers() = 0; |
77 | 77 |
78 protected: | 78 protected: |
79 virtual ~OptionsPageUIHandlerHost() {} | 79 virtual ~OptionsPageUIHandlerHost() {} |
80 }; | 80 }; |
81 | 81 |
82 // The WebUI for chrome:settings. | 82 // The WebUI for chrome:settings. |
83 class OptionsUI : public WebUI, public content::WebUIController, | 83 class OptionsUI : public content::WebUIController, |
84 public OptionsPageUIHandlerHost { | 84 public OptionsPageUIHandlerHost { |
85 public: | 85 public: |
86 explicit OptionsUI(content::WebContents* contents); | 86 explicit OptionsUI(WebUI* web_ui); |
87 virtual ~OptionsUI(); | 87 virtual ~OptionsUI(); |
88 | 88 |
89 static RefCountedMemory* GetFaviconResourceBytes(); | 89 static RefCountedMemory* GetFaviconResourceBytes(); |
90 | 90 |
91 // WebUIController implementation. | 91 // WebUIController implementation. |
92 virtual void RenderViewCreated(RenderViewHost* render_view_host) OVERRIDE; | 92 virtual void RenderViewCreated(RenderViewHost* render_view_host) OVERRIDE; |
93 virtual void RenderViewReused(RenderViewHost* render_view_host) OVERRIDE; | 93 virtual void RenderViewReused(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(base::DictionaryValue* localized_strings, | 101 void AddOptionsPageUIHandler(base::DictionaryValue* localized_strings, |
102 OptionsPageUIHandler* handler); | 102 OptionsPageUIHandler* handler); |
103 | 103 |
104 // Sets the WebUI CommandLineString property with arguments passed while | 104 // Sets the WebUI CommandLineString property with arguments passed while |
105 // launching chrome. | 105 // launching chrome. |
106 void SetCommandLineString(RenderViewHost* render_view_host); | 106 void SetCommandLineString(RenderViewHost* render_view_host); |
107 | 107 |
108 bool initialized_handlers_; | 108 bool initialized_handlers_; |
109 | 109 |
| 110 std::vector<OptionsPageUIHandler*> handlers_; |
| 111 |
110 DISALLOW_COPY_AND_ASSIGN(OptionsUI); | 112 DISALLOW_COPY_AND_ASSIGN(OptionsUI); |
111 }; | 113 }; |
112 | 114 |
113 #endif // CHROME_BROWSER_UI_WEBUI_OPTIONS_OPTIONS_UI_H_ | 115 #endif // CHROME_BROWSER_UI_WEBUI_OPTIONS_OPTIONS_UI_H_ |
OLD | NEW |