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