Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(32)

Side by Side Diff: chrome/browser/ui/webui/options2/options_ui2.cc

Issue 9188056: Start splitting out WebUI into an implementation class and an interface that each page implements... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 8 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/ui/webui/options2/options_ui2.h ('k') | chrome/browser/ui/webui/plugins_ui.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #include "chrome/browser/ui/webui/options2/options_ui2.h" 5 #include "chrome/browser/ui/webui/options2/options_ui2.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/callback.h" 10 #include "base/callback.h"
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 l10n_util::GetStringUTF16(title_id))); 189 l10n_util::GetStringUTF16(title_id)));
190 } 190 }
191 191
192 //////////////////////////////////////////////////////////////////////////////// 192 ////////////////////////////////////////////////////////////////////////////////
193 // 193 //
194 // OptionsUI 194 // OptionsUI
195 // 195 //
196 //////////////////////////////////////////////////////////////////////////////// 196 ////////////////////////////////////////////////////////////////////////////////
197 197
198 OptionsUI::OptionsUI(WebContents* contents) 198 OptionsUI::OptionsUI(WebContents* contents)
199 : WebUI(contents), 199 : WebUI(contents, this),
200 initialized_handlers_(false) { 200 initialized_handlers_(false) {
201 DictionaryValue* localized_strings = new DictionaryValue(); 201 DictionaryValue* localized_strings = new DictionaryValue();
202 202
203 CoreOptionsHandler* core_handler; 203 CoreOptionsHandler* core_handler;
204 #if defined(OS_CHROMEOS) 204 #if defined(OS_CHROMEOS)
205 core_handler = new chromeos::options2::CoreChromeOSOptionsHandler(); 205 core_handler = new chromeos::options2::CoreChromeOSOptionsHandler();
206 #else 206 #else
207 core_handler = new CoreOptionsHandler(); 207 core_handler = new CoreOptionsHandler();
208 #endif 208 #endif
209 core_handler->set_handlers_host(this); 209 core_handler->set_handlers_host(this);
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
288 OptionsUI::~OptionsUI() { 288 OptionsUI::~OptionsUI() {
289 // Uninitialize all registered handlers. The base class owns them and it will 289 // Uninitialize all registered handlers. The base class owns them and it will
290 // eventually delete them. Skip over the generic handler. 290 // eventually delete them. Skip over the generic handler.
291 for (std::vector<WebUIMessageHandler*>::iterator iter = handlers_.begin() + 1; 291 for (std::vector<WebUIMessageHandler*>::iterator iter = handlers_.begin() + 1;
292 iter != handlers_.end(); 292 iter != handlers_.end();
293 ++iter) { 293 ++iter) {
294 static_cast<OptionsPageUIHandler*>(*iter)->Uninitialize(); 294 static_cast<OptionsPageUIHandler*>(*iter)->Uninitialize();
295 } 295 }
296 } 296 }
297 297
298 // Override.
299 void OptionsUI::RenderViewCreated(RenderViewHost* render_view_host) { 298 void OptionsUI::RenderViewCreated(RenderViewHost* render_view_host) {
300 SetCommandLineString(render_view_host); 299 SetCommandLineString(render_view_host);
301 WebUI::RenderViewCreated(render_view_host);
302 } 300 }
303 301
304 void OptionsUI::RenderViewReused(RenderViewHost* render_view_host) { 302 void OptionsUI::RenderViewReused(RenderViewHost* render_view_host) {
305 SetCommandLineString(render_view_host); 303 SetCommandLineString(render_view_host);
306 WebUI::RenderViewReused(render_view_host);
307 } 304 }
308 305
309 void OptionsUI::DidBecomeActiveForReusedRenderView() { 306 void OptionsUI::DidBecomeActiveForReusedRenderView() {
310 // When the renderer is re-used (e.g., for back/forward navigation within 307 // When the renderer is re-used (e.g., for back/forward navigation within
311 // options), the handlers are torn down and rebuilt, so are no longer 308 // options), the handlers are torn down and rebuilt, so are no longer
312 // initialized, but the web page's DOM may remain intact, in which case onload 309 // initialized, but the web page's DOM may remain intact, in which case onload
313 // won't fire to initilize the handlers. To make sure initialization always 310 // won't fire to initilize the handlers. To make sure initialization always
314 // happens, call reinitializeCore (which is a no-op unless the DOM was already 311 // happens, call reinitializeCore (which is a no-op unless the DOM was already
315 // initialized). 312 // initialized).
316 CallJavascriptFunction("OptionsPage.reinitializeCore"); 313 CallJavascriptFunction("OptionsPage.reinitializeCore");
317
318 WebUI::DidBecomeActiveForReusedRenderView();
319 } 314 }
320 315
321 // static 316 // static
322 RefCountedMemory* OptionsUI::GetFaviconResourceBytes() { 317 RefCountedMemory* OptionsUI::GetFaviconResourceBytes() {
323 return ResourceBundle::GetSharedInstance(). 318 return ResourceBundle::GetSharedInstance().
324 LoadDataResourceBytes(IDR_SETTINGS_FAVICON); 319 LoadDataResourceBytes(IDR_SETTINGS_FAVICON);
325 } 320 }
326 321
327 void OptionsUI::InitializeHandlers() { 322 void OptionsUI::InitializeHandlers() {
328 Profile* profile = 323 Profile* profile =
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
364 WideToASCII(CommandLine::ForCurrentProcess()->GetCommandLineString()); 359 WideToASCII(CommandLine::ForCurrentProcess()->GetCommandLineString());
365 #else 360 #else
366 command_line_string = 361 command_line_string =
367 CommandLine::ForCurrentProcess()->GetCommandLineString(); 362 CommandLine::ForCurrentProcess()->GetCommandLineString();
368 #endif 363 #endif
369 364
370 render_view_host->SetWebUIProperty("commandLineString", command_line_string); 365 render_view_host->SetWebUIProperty("commandLineString", command_line_string);
371 } 366 }
372 367
373 } // namespace options2 368 } // namespace options2
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/options2/options_ui2.h ('k') | chrome/browser/ui/webui/plugins_ui.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698