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

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

Issue 9994005: Separate handler initialization from page initialization (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: \n nits Created 8 years, 8 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) 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 359 matching lines...) Expand 10 before | Expand all | Expand 10 after
370 // The reinitialize call from DidBecomeActiveForReusedRenderView end up being 370 // The reinitialize call from DidBecomeActiveForReusedRenderView end up being
371 // delivered after a new web page DOM has been brought up in an existing 371 // delivered after a new web page DOM has been brought up in an existing
372 // renderer (due to IPC delays), causing this method to be called twice. If 372 // renderer (due to IPC delays), causing this method to be called twice. If
373 // that happens, ignore the second call. 373 // that happens, ignore the second call.
374 if (!initialized_handlers_) { 374 if (!initialized_handlers_) {
375 for (size_t i = 0; i < handlers_.size(); ++i) 375 for (size_t i = 0; i < handlers_.size(); ++i)
376 handlers_[i]->InitializeHandler(); 376 handlers_[i]->InitializeHandler();
377 initialized_handlers_ = true; 377 initialized_handlers_ = true;
378 } 378 }
379 379
380 // Always initialize the page as when handlers are left over we still need to
381 // do various things like show/hide sections and send data to the Javascript.
382 for (size_t i = 0; i < handlers_.size(); ++i)
383 handlers_[i]->InitializePage();
384
385 #if defined(OS_CHROMEOS) 380 #if defined(OS_CHROMEOS)
386 pointer_device_observer_->Init(); 381 pointer_device_observer_->Init();
387 #endif 382 #endif
388 } 383 }
389 384
385 void OptionsUI::InitializePages() {
386 // Always initialize the page as when handlers are left over we still need to
387 // do various things like show/hide sections and send data to the Javascript.
388 for (size_t i = 0; i < handlers_.size(); ++i)
389 handlers_[i]->InitializePage();
390 }
391
390 void OptionsUI::AddOptionsPageUIHandler(DictionaryValue* localized_strings, 392 void OptionsUI::AddOptionsPageUIHandler(DictionaryValue* localized_strings,
391 OptionsPageUIHandler* handler_raw) { 393 OptionsPageUIHandler* handler_raw) {
392 scoped_ptr<OptionsPageUIHandler> handler(handler_raw); 394 scoped_ptr<OptionsPageUIHandler> handler(handler_raw);
393 DCHECK(handler.get()); 395 DCHECK(handler.get());
394 // Add only if handler's service is enabled. 396 // Add only if handler's service is enabled.
395 if (handler->IsEnabled()) { 397 if (handler->IsEnabled()) {
396 // Add handler to the list and also pass the ownership. 398 // Add handler to the list and also pass the ownership.
397 web_ui()->AddMessageHandler(handler.release()); 399 web_ui()->AddMessageHandler(handler.release());
398 handler_raw->GetLocalizedValues(localized_strings); 400 handler_raw->GetLocalizedValues(localized_strings);
399 handlers_.push_back(handler_raw); 401 handlers_.push_back(handler_raw);
400 } 402 }
401 } 403 }
402 404
403 void OptionsUI::SetCommandLineString(RenderViewHost* render_view_host) { 405 void OptionsUI::SetCommandLineString(RenderViewHost* render_view_host) {
404 std::string command_line_string; 406 std::string command_line_string;
405 407
406 #if defined(OS_WIN) 408 #if defined(OS_WIN)
407 command_line_string = 409 command_line_string =
408 WideToASCII(CommandLine::ForCurrentProcess()->GetCommandLineString()); 410 WideToASCII(CommandLine::ForCurrentProcess()->GetCommandLineString());
409 #else 411 #else
410 command_line_string = 412 command_line_string =
411 CommandLine::ForCurrentProcess()->GetCommandLineString(); 413 CommandLine::ForCurrentProcess()->GetCommandLineString();
412 #endif 414 #endif
413 415
414 render_view_host->SetWebUIProperty("commandLineString", command_line_string); 416 render_view_host->SetWebUIProperty("commandLineString", command_line_string);
415 } 417 }
416 418
417 } // namespace options2 419 } // namespace options2
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698