| Index: chrome/browser/ui/webui/options2/options_ui2.cc
|
| diff --git a/chrome/browser/ui/webui/options2/options_ui2.cc b/chrome/browser/ui/webui/options2/options_ui2.cc
|
| index a0adc59a37286169a8ac600891949ef6c22dfe37..562c5dbf8f86ca2a305c710954eb1fd074c8ea1f 100644
|
| --- a/chrome/browser/ui/webui/options2/options_ui2.cc
|
| +++ b/chrome/browser/ui/webui/options2/options_ui2.cc
|
| @@ -209,8 +209,7 @@ void OptionsPageUIHandler::RegisterTitle(DictionaryValue* localized_strings,
|
| ////////////////////////////////////////////////////////////////////////////////
|
|
|
| OptionsUI::OptionsUI(content::WebUI* web_ui)
|
| - : WebUIController(web_ui),
|
| - initialized_handlers_(false) {
|
| + : WebUIController(web_ui) {
|
| DictionaryValue* localized_strings = new DictionaryValue();
|
|
|
| CoreOptionsHandler* core_handler;
|
| @@ -298,6 +297,7 @@ OptionsUI::OptionsUI(content::WebUI* web_ui)
|
|
|
| // Set up the chrome://settings-frame/ source.
|
| Profile* profile = Profile::FromWebUI(web_ui);
|
| + DCHECK(!profile->IsOffTheRecord() || Profile::IsGuestSession());
|
| profile->GetChromeURLDataManager()->AddDataSource(html_source);
|
|
|
| // Set up the chrome://theme/ source.
|
| @@ -314,6 +314,7 @@ OptionsUI::OptionsUI(content::WebUI* web_ui)
|
| new chromeos::system::PointerDeviceObserver());
|
| pointer_device_observer_->AddObserver(browser_options_handler);
|
| pointer_device_observer_->AddObserver(pointer_handler);
|
| + pointer_device_observer_->Init();
|
| #endif
|
| }
|
|
|
| @@ -331,16 +332,6 @@ void OptionsUI::RenderViewReused(RenderViewHost* render_view_host) {
|
| SetCommandLineString(render_view_host);
|
| }
|
|
|
| -void OptionsUI::DidBecomeActiveForReusedRenderView() {
|
| - // When the renderer is re-used (e.g., for back/forward navigation within
|
| - // options), the handlers are torn down and rebuilt, so are no longer
|
| - // initialized, but the web page's DOM may remain intact, in which case onload
|
| - // won't fire to initilize the handlers. To make sure initialization always
|
| - // happens, call reinitializeCore (which is a no-op unless the DOM was already
|
| - // initialized).
|
| - web_ui()->CallJavascriptFunction("OptionsPage.reinitializeCore");
|
| -}
|
| -
|
| // static
|
| void OptionsUI::ProcessAutocompleteSuggestions(
|
| const AutocompleteResult& autocompleteResult,
|
| @@ -368,28 +359,16 @@ RefCountedMemory* OptionsUI::GetFaviconResourceBytes() {
|
| LoadDataResourceBytes(IDR_SETTINGS_FAVICON);
|
| }
|
|
|
| -void OptionsUI::InitializeHandlers() {
|
| - Profile* profile = Profile::FromWebUI(web_ui());
|
| - DCHECK(!profile->IsOffTheRecord() || Profile::IsGuestSession());
|
| -
|
| - // The reinitialize call from DidBecomeActiveForReusedRenderView end up being
|
| - // delivered after a new web page DOM has been brought up in an existing
|
| - // renderer (due to IPC delays), causing this method to be called twice. If
|
| - // that happens, ignore the second call.
|
| - if (!initialized_handlers_) {
|
| - for (size_t i = 0; i < handlers_.size(); ++i)
|
| - handlers_[i]->InitializeHandler();
|
| - initialized_handlers_ = true;
|
| - }
|
| -
|
| +void OptionsUI::InitializePages() {
|
| // Always initialize the page as when handlers are left over we still need to
|
| // do various things like show/hide sections and send data to the Javascript.
|
| for (size_t i = 0; i < handlers_.size(); ++i)
|
| handlers_[i]->InitializePage();
|
| +}
|
|
|
| -#if defined(OS_CHROMEOS)
|
| - pointer_device_observer_->Init();
|
| -#endif
|
| +void OptionsUI::InitializeHandlers() {
|
| + for (size_t i = 0; i < handlers_.size(); i++)
|
| + handlers_[i]->InitializeHandler();
|
| }
|
|
|
| void OptionsUI::AddOptionsPageUIHandler(DictionaryValue* localized_strings,
|
| @@ -398,10 +377,10 @@ void OptionsUI::AddOptionsPageUIHandler(DictionaryValue* localized_strings,
|
| DCHECK(handler.get());
|
| // Add only if handler's service is enabled.
|
| if (handler->IsEnabled()) {
|
| - // Add handler to the list and also pass the ownership.
|
| - web_ui()->AddMessageHandler(handler.release());
|
| - handler_raw->GetLocalizedValues(localized_strings);
|
| - handlers_.push_back(handler_raw);
|
| + // Add handler to the list
|
| + web_ui()->AddMessageHandler(handler.get());
|
| + handler->GetLocalizedValues(localized_strings);
|
| + handlers_.push_back(handler.release());
|
| }
|
| }
|
|
|
|
|