OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 | 7 |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 24 matching lines...) Expand all Loading... |
35 | 35 |
36 namespace options { | 36 namespace options { |
37 | 37 |
38 // The base class handler of Javascript messages of options pages. | 38 // The base class handler of Javascript messages of options pages. |
39 class OptionsPageUIHandler : public content::WebUIMessageHandler { | 39 class OptionsPageUIHandler : public content::WebUIMessageHandler { |
40 public: | 40 public: |
41 // Key for identifying the Settings App localized_strings in loadTimeData. | 41 // Key for identifying the Settings App localized_strings in loadTimeData. |
42 static const char kSettingsAppKey[]; | 42 static const char kSettingsAppKey[]; |
43 | 43 |
44 OptionsPageUIHandler(); | 44 OptionsPageUIHandler(); |
45 virtual ~OptionsPageUIHandler(); | 45 ~OptionsPageUIHandler() override; |
46 | 46 |
47 // Is this handler enabled? | 47 // Is this handler enabled? |
48 virtual bool IsEnabled(); | 48 virtual bool IsEnabled(); |
49 | 49 |
50 // Collects localized strings for options page. | 50 // Collects localized strings for options page. |
51 virtual void GetLocalizedValues(base::DictionaryValue* localized_strings) = 0; | 51 virtual void GetLocalizedValues(base::DictionaryValue* localized_strings) = 0; |
52 | 52 |
53 virtual void PageLoadStarted() {} | 53 virtual void PageLoadStarted() {} |
54 | 54 |
55 // Will be called only once in the life time of the handler. Generally used to | 55 // Will be called only once in the life time of the handler. Generally used to |
56 // add observers, initializes preferences, or start asynchronous calls from | 56 // add observers, initializes preferences, or start asynchronous calls from |
57 // various services. | 57 // various services. |
58 virtual void InitializeHandler() {} | 58 virtual void InitializeHandler() {} |
59 | 59 |
60 // Initialize the page. Called once the DOM is available for manipulation. | 60 // Initialize the page. Called once the DOM is available for manipulation. |
61 // This will be called when a RenderView is re-used (when navigated to with | 61 // This will be called when a RenderView is re-used (when navigated to with |
62 // back/forward or session restored in some cases) or when created. | 62 // back/forward or session restored in some cases) or when created. |
63 virtual void InitializePage() {} | 63 virtual void InitializePage() {} |
64 | 64 |
65 // Uninitializes the page. Called just before the object is destructed. | 65 // Uninitializes the page. Called just before the object is destructed. |
66 virtual void Uninitialize() {} | 66 virtual void Uninitialize() {} |
67 | 67 |
68 // WebUIMessageHandler implementation. | 68 // WebUIMessageHandler implementation. |
69 virtual void RegisterMessages() override {} | 69 void RegisterMessages() override {} |
70 | 70 |
71 protected: | 71 protected: |
72 struct OptionsStringResource { | 72 struct OptionsStringResource { |
73 // The name of the resource in templateData. | 73 // The name of the resource in templateData. |
74 const char* name; | 74 const char* name; |
75 // The .grd ID for the resource (IDS_*). | 75 // The .grd ID for the resource (IDS_*). |
76 int id; | 76 int id; |
77 // The .grd ID of the string to replace $1 in |id|'s string. If zero or | 77 // The .grd ID of the string to replace $1 in |id|'s string. If zero or |
78 // omitted (default initialized), no substitution is attempted. | 78 // omitted (default initialized), no substitution is attempted. |
79 int substitution_id; | 79 int substitution_id; |
(...skipping 28 matching lines...) Expand all Loading... |
108 }; | 108 }; |
109 | 109 |
110 // The WebUI for chrome:settings-frame. | 110 // The WebUI for chrome:settings-frame. |
111 class OptionsUI : public content::WebUIController, | 111 class OptionsUI : public content::WebUIController, |
112 public content::WebContentsObserver, | 112 public content::WebContentsObserver, |
113 public OptionsPageUIHandlerHost { | 113 public OptionsPageUIHandlerHost { |
114 public: | 114 public: |
115 typedef base::CallbackList<void()> OnFinishedLoadingCallbackList; | 115 typedef base::CallbackList<void()> OnFinishedLoadingCallbackList; |
116 | 116 |
117 explicit OptionsUI(content::WebUI* web_ui); | 117 explicit OptionsUI(content::WebUI* web_ui); |
118 virtual ~OptionsUI(); | 118 ~OptionsUI() override; |
119 | 119 |
120 // Registers a callback to be called once the settings frame has finished | 120 // Registers a callback to be called once the settings frame has finished |
121 // loading on the HTML/JS side. | 121 // loading on the HTML/JS side. |
122 scoped_ptr<OnFinishedLoadingCallbackList::Subscription> | 122 scoped_ptr<OnFinishedLoadingCallbackList::Subscription> |
123 RegisterOnFinishedLoadingCallback(const base::Closure& callback); | 123 RegisterOnFinishedLoadingCallback(const base::Closure& callback); |
124 | 124 |
125 // Takes the suggestions from |result| and adds them to |suggestions| so that | 125 // Takes the suggestions from |result| and adds them to |suggestions| so that |
126 // they can be passed to a JavaScript function. | 126 // they can be passed to a JavaScript function. |
127 static void ProcessAutocompleteSuggestions( | 127 static void ProcessAutocompleteSuggestions( |
128 const AutocompleteResult& result, | 128 const AutocompleteResult& result, |
129 base::ListValue* const suggestions); | 129 base::ListValue* const suggestions); |
130 | 130 |
131 static base::RefCountedMemory* GetFaviconResourceBytes( | 131 static base::RefCountedMemory* GetFaviconResourceBytes( |
132 ui::ScaleFactor scale_factor); | 132 ui::ScaleFactor scale_factor); |
133 | 133 |
134 // Overridden from content::WebContentsObserver: | 134 // Overridden from content::WebContentsObserver: |
135 virtual void DidStartProvisionalLoadForFrame( | 135 void DidStartProvisionalLoadForFrame( |
136 content::RenderFrameHost* render_frame_host, | 136 content::RenderFrameHost* render_frame_host, |
137 const GURL& validated_url, | 137 const GURL& validated_url, |
138 bool is_error_page, | 138 bool is_error_page, |
139 bool is_iframe_srcdoc) override; | 139 bool is_iframe_srcdoc) override; |
140 | 140 |
141 // Overridden from OptionsPageUIHandlerHost: | 141 // Overridden from OptionsPageUIHandlerHost: |
142 virtual void InitializeHandlers() override; | 142 void InitializeHandlers() override; |
143 virtual void OnFinishedLoading() override; | 143 void OnFinishedLoading() override; |
144 | 144 |
145 private: | 145 private: |
146 // Adds OptionsPageUiHandler to the handlers list if handler is enabled. | 146 // Adds OptionsPageUiHandler to the handlers list if handler is enabled. |
147 void AddOptionsPageUIHandler(base::DictionaryValue* localized_strings, | 147 void AddOptionsPageUIHandler(base::DictionaryValue* localized_strings, |
148 OptionsPageUIHandler* handler); | 148 OptionsPageUIHandler* handler); |
149 | 149 |
150 bool initialized_handlers_; | 150 bool initialized_handlers_; |
151 | 151 |
152 std::vector<OptionsPageUIHandler*> handlers_; | 152 std::vector<OptionsPageUIHandler*> handlers_; |
153 OnFinishedLoadingCallbackList on_finished_loading_callbacks_; | 153 OnFinishedLoadingCallbackList on_finished_loading_callbacks_; |
154 | 154 |
155 #if defined(OS_CHROMEOS) | 155 #if defined(OS_CHROMEOS) |
156 scoped_ptr<chromeos::system::PointerDeviceObserver> | 156 scoped_ptr<chromeos::system::PointerDeviceObserver> |
157 pointer_device_observer_; | 157 pointer_device_observer_; |
158 #endif | 158 #endif |
159 | 159 |
160 DISALLOW_COPY_AND_ASSIGN(OptionsUI); | 160 DISALLOW_COPY_AND_ASSIGN(OptionsUI); |
161 }; | 161 }; |
162 | 162 |
163 } // namespace options | 163 } // namespace options |
164 | 164 |
165 #endif // CHROME_BROWSER_UI_WEBUI_OPTIONS_OPTIONS_UI_H_ | 165 #endif // CHROME_BROWSER_UI_WEBUI_OPTIONS_OPTIONS_UI_H_ |
OLD | NEW |