Chromium Code Reviews| 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 #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 357 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 368 DCHECK(!profile->IsOffTheRecord() || Profile::IsGuestSession()); | 368 DCHECK(!profile->IsOffTheRecord() || Profile::IsGuestSession()); |
| 369 | 369 |
| 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 } |
|
Dan Beam
2012/04/05 17:58:35
nit: \n
| |
| 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) | 379 #if defined(OS_CHROMEOS) |
| 386 pointer_device_observer_->Init(); | 380 pointer_device_observer_->Init(); |
| 387 #endif | 381 #endif |
| 388 } | 382 } |
| 389 | 383 |
| 384 void OptionsUI::InitializePages() { | |
| 385 // Always initialize the page as when handlers are left over we still need to | |
| 386 // do various things like show/hide sections and send data to the Javascript. | |
| 387 for (size_t i = 0; i < handlers_.size(); ++i) | |
| 388 handlers_[i]->InitializePage(); | |
| 389 } | |
| 390 | |
| 390 void OptionsUI::AddOptionsPageUIHandler(DictionaryValue* localized_strings, | 391 void OptionsUI::AddOptionsPageUIHandler(DictionaryValue* localized_strings, |
| 391 OptionsPageUIHandler* handler_raw) { | 392 OptionsPageUIHandler* handler_raw) { |
| 392 scoped_ptr<OptionsPageUIHandler> handler(handler_raw); | 393 scoped_ptr<OptionsPageUIHandler> handler(handler_raw); |
| 393 DCHECK(handler.get()); | 394 DCHECK(handler.get()); |
| 394 // Add only if handler's service is enabled. | 395 // Add only if handler's service is enabled. |
| 395 if (handler->IsEnabled()) { | 396 if (handler->IsEnabled()) { |
| 396 // Add handler to the list and also pass the ownership. | 397 // Add handler to the list and also pass the ownership. |
| 397 web_ui()->AddMessageHandler(handler.release()); | 398 web_ui()->AddMessageHandler(handler.release()); |
| 398 handler_raw->GetLocalizedValues(localized_strings); | 399 handler_raw->GetLocalizedValues(localized_strings); |
| 399 handlers_.push_back(handler_raw); | 400 handlers_.push_back(handler_raw); |
| 400 } | 401 } |
| 401 } | 402 } |
| 402 | 403 |
| 403 void OptionsUI::SetCommandLineString(RenderViewHost* render_view_host) { | 404 void OptionsUI::SetCommandLineString(RenderViewHost* render_view_host) { |
| 404 std::string command_line_string; | 405 std::string command_line_string; |
| 405 | 406 |
| 406 #if defined(OS_WIN) | 407 #if defined(OS_WIN) |
| 407 command_line_string = | 408 command_line_string = |
| 408 WideToASCII(CommandLine::ForCurrentProcess()->GetCommandLineString()); | 409 WideToASCII(CommandLine::ForCurrentProcess()->GetCommandLineString()); |
| 409 #else | 410 #else |
| 410 command_line_string = | 411 command_line_string = |
| 411 CommandLine::ForCurrentProcess()->GetCommandLineString(); | 412 CommandLine::ForCurrentProcess()->GetCommandLineString(); |
| 412 #endif | 413 #endif |
| 413 | 414 |
| 414 render_view_host->SetWebUIProperty("commandLineString", command_line_string); | 415 render_view_host->SetWebUIProperty("commandLineString", command_line_string); |
| 415 } | 416 } |
| 416 | 417 |
| 417 } // namespace options2 | 418 } // namespace options2 |
| OLD | NEW |