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

Side by Side Diff: chrome/browser/ui/webui/options/options_ui.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
OLDNEW
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 #include "chrome/browser/ui/webui/options/options_ui.h" 5 #include "chrome/browser/ui/webui/options/options_ui.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 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 l10n_util::GetStringUTF16(title_id))); 192 l10n_util::GetStringUTF16(title_id)));
193 } 193 }
194 194
195 //////////////////////////////////////////////////////////////////////////////// 195 ////////////////////////////////////////////////////////////////////////////////
196 // 196 //
197 // OptionsUI 197 // OptionsUI
198 // 198 //
199 //////////////////////////////////////////////////////////////////////////////// 199 ////////////////////////////////////////////////////////////////////////////////
200 200
201 OptionsUI::OptionsUI(WebContents* contents) 201 OptionsUI::OptionsUI(WebContents* contents)
202 : WebUI(contents), 202 : WebUI(contents, this),
203 initialized_handlers_(false) { 203 initialized_handlers_(false) {
204 DictionaryValue* localized_strings = new DictionaryValue(); 204 DictionaryValue* localized_strings = new DictionaryValue();
205 205
206 CoreOptionsHandler* core_handler; 206 CoreOptionsHandler* core_handler;
207 #if defined(OS_CHROMEOS) 207 #if defined(OS_CHROMEOS)
208 core_handler = new chromeos::CoreChromeOSOptionsHandler(); 208 core_handler = new chromeos::CoreChromeOSOptionsHandler();
209 #else 209 #else
210 core_handler = new CoreOptionsHandler(); 210 core_handler = new CoreOptionsHandler();
211 #endif 211 #endif
212 core_handler->set_handlers_host(this); 212 core_handler->set_handlers_host(this);
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
295 for (std::vector<WebUIMessageHandler*>::iterator iter = handlers_.begin() + 1; 295 for (std::vector<WebUIMessageHandler*>::iterator iter = handlers_.begin() + 1;
296 iter != handlers_.end(); 296 iter != handlers_.end();
297 ++iter) { 297 ++iter) {
298 static_cast<OptionsPageUIHandler*>(*iter)->Uninitialize(); 298 static_cast<OptionsPageUIHandler*>(*iter)->Uninitialize();
299 } 299 }
300 } 300 }
301 301
302 // Override. 302 // Override.
303 void OptionsUI::RenderViewCreated(RenderViewHost* render_view_host) { 303 void OptionsUI::RenderViewCreated(RenderViewHost* render_view_host) {
304 SetCommandLineString(render_view_host); 304 SetCommandLineString(render_view_host);
305 WebUI::RenderViewCreated(render_view_host);
306 } 305 }
307 306
308 void OptionsUI::RenderViewReused(RenderViewHost* render_view_host) { 307 void OptionsUI::RenderViewReused(RenderViewHost* render_view_host) {
309 SetCommandLineString(render_view_host); 308 SetCommandLineString(render_view_host);
310 WebUI::RenderViewReused(render_view_host);
311 } 309 }
312 310
313 void OptionsUI::DidBecomeActiveForReusedRenderView() { 311 void OptionsUI::DidBecomeActiveForReusedRenderView() {
314 // When the renderer is re-used (e.g., for back/forward navigation within 312 // When the renderer is re-used (e.g., for back/forward navigation within
315 // options), the handlers are torn down and rebuilt, so are no longer 313 // options), the handlers are torn down and rebuilt, so are no longer
316 // initialized, but the web page's DOM may remain intact, in which case onload 314 // initialized, but the web page's DOM may remain intact, in which case onload
317 // won't fire to initilize the handlers. To make sure initialization always 315 // won't fire to initilize the handlers. To make sure initialization always
318 // happens, call reinitializeCore (which is a no-op unless the DOM was already 316 // happens, call reinitializeCore (which is a no-op unless the DOM was already
319 // initialized). 317 // initialized).
320 CallJavascriptFunction("OptionsPage.reinitializeCore"); 318 CallJavascriptFunction("OptionsPage.reinitializeCore");
321
322 WebUI::DidBecomeActiveForReusedRenderView();
323 } 319 }
324 320
325 // static 321 // static
326 RefCountedMemory* OptionsUI::GetFaviconResourceBytes() { 322 RefCountedMemory* OptionsUI::GetFaviconResourceBytes() {
327 return ResourceBundle::GetSharedInstance(). 323 return ResourceBundle::GetSharedInstance().
328 LoadDataResourceBytes(IDR_SETTINGS_FAVICON); 324 LoadDataResourceBytes(IDR_SETTINGS_FAVICON);
329 } 325 }
330 326
331 void OptionsUI::InitializeHandlers() { 327 void OptionsUI::InitializeHandlers() {
332 Profile* profile = 328 Profile* profile =
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
366 #if defined(OS_WIN) 362 #if defined(OS_WIN)
367 command_line_string = 363 command_line_string =
368 WideToASCII(CommandLine::ForCurrentProcess()->GetCommandLineString()); 364 WideToASCII(CommandLine::ForCurrentProcess()->GetCommandLineString());
369 #else 365 #else
370 command_line_string = 366 command_line_string =
371 CommandLine::ForCurrentProcess()->GetCommandLineString(); 367 CommandLine::ForCurrentProcess()->GetCommandLineString();
372 #endif 368 #endif
373 369
374 render_view_host->SetWebUIProperty("commandLineString", command_line_string); 370 render_view_host->SetWebUIProperty("commandLineString", command_line_string);
375 } 371 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/options/options_ui.h ('k') | chrome/browser/ui/webui/options2/options_ui2.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698