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

Side by Side Diff: chrome/browser/ui/webui/chromeos/proxy_settings_ui.cc

Issue 9994005: Separate handler initialization from page initialization (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: move anything that indirectly calls JS to InitializePage 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/chromeos/proxy_settings_ui.h" 5 #include "chrome/browser/ui/webui/chromeos/proxy_settings_ui.h"
6 6
7 #include "base/memory/scoped_ptr.h" 7 #include "base/memory/scoped_ptr.h"
8 #include "base/message_loop.h" 8 #include "base/message_loop.h"
9 #include "base/values.h" 9 #include "base/values.h"
10 #include "chrome/browser/chromeos/cros_settings.h" 10 #include "chrome/browser/chromeos/cros_settings.h"
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 ProxySettingsUI::ProxySettingsUI(content::WebUI* web_ui) 72 ProxySettingsUI::ProxySettingsUI(content::WebUI* web_ui)
73 : WebUIController(web_ui), 73 : WebUIController(web_ui),
74 proxy_handler_(new options2::ProxyHandler()), 74 proxy_handler_(new options2::ProxyHandler()),
75 core_handler_(new options2::CoreChromeOSOptionsHandler()) { 75 core_handler_(new options2::CoreChromeOSOptionsHandler()) {
76 // |localized_strings| will be owned by ProxySettingsHTMLSource. 76 // |localized_strings| will be owned by ProxySettingsHTMLSource.
77 DictionaryValue* localized_strings = new DictionaryValue(); 77 DictionaryValue* localized_strings = new DictionaryValue();
78 78
79 core_handler_->set_handlers_host(this); 79 core_handler_->set_handlers_host(this);
80 core_handler_->GetLocalizedValues(localized_strings); 80 core_handler_->GetLocalizedValues(localized_strings);
81 web_ui->AddMessageHandler(core_handler_); 81 web_ui->AddMessageHandler(core_handler_);
82 core_handler_->InitializeHandler();
82 83
83 proxy_handler_->GetLocalizedValues(localized_strings); 84 proxy_handler_->GetLocalizedValues(localized_strings);
84 web_ui->AddMessageHandler(proxy_handler_); 85 web_ui->AddMessageHandler(proxy_handler_);
86 proxy_handler_->InitializeHandler();
85 87
86 ProxySettingsHTMLSource* source = 88 ProxySettingsHTMLSource* source =
87 new ProxySettingsHTMLSource(localized_strings); 89 new ProxySettingsHTMLSource(localized_strings);
88 Profile* profile = Profile::FromWebUI(web_ui); 90 Profile* profile = Profile::FromWebUI(web_ui);
89 profile->GetChromeURLDataManager()->AddDataSource(source); 91 profile->GetChromeURLDataManager()->AddDataSource(source);
92
93 PrefProxyConfigTracker* proxy_tracker = profile->GetProxyConfigTracker();
94 proxy_tracker->UIMakeActiveNetworkCurrent();
95
96 std::string network_name;
97 proxy_tracker->UIGetCurrentNetworkName(&network_name);
98 proxy_handler_->SetNetworkName(network_name);
90 } 99 }
91 100
92 ProxySettingsUI::~ProxySettingsUI() { 101 ProxySettingsUI::~ProxySettingsUI() {
93 // Uninitialize all registered handlers. The base class owns them and it will 102 // Uninitialize all registered handlers. The base class owns them and it will
94 // eventually delete them. 103 // eventually delete them.
95 core_handler_->Uninitialize(); 104 core_handler_->Uninitialize();
96 proxy_handler_->Uninitialize(); 105 proxy_handler_->Uninitialize();
97 } 106 }
98 107
99 void ProxySettingsUI::InitializeHandlers() { 108 void ProxySettingsUI::InitializePages() {
100 core_handler_->InitializeHandler();
101 proxy_handler_->InitializeHandler();
102 core_handler_->InitializePage(); 109 core_handler_->InitializePage();
103 proxy_handler_->InitializePage(); 110 proxy_handler_->InitializePage();
104 Profile* profile = Profile::FromWebUI(web_ui());
105 PrefProxyConfigTracker* proxy_tracker = profile->GetProxyConfigTracker();
106 proxy_tracker->UIMakeActiveNetworkCurrent();
107 std::string network_name;
108 proxy_tracker->UIGetCurrentNetworkName(&network_name);
109 proxy_handler_->SetNetworkName(network_name);
110 } 111 }
111 112
112 } // namespace chromeos 113 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698