| OLD | NEW |
| 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/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" |
| 11 #include "chrome/browser/chromeos/proxy_config_service_impl.h" |
| 11 #include "chrome/browser/profiles/profile.h" | 12 #include "chrome/browser/profiles/profile.h" |
| 12 #include "chrome/browser/ui/webui/chrome_url_data_manager.h" | 13 #include "chrome/browser/ui/webui/chrome_url_data_manager.h" |
| 13 #include "chrome/browser/ui/webui/options/chromeos/core_chromeos_options_handler
.h" | 14 #include "chrome/browser/ui/webui/options/chromeos/core_chromeos_options_handler
.h" |
| 14 #include "chrome/browser/ui/webui/options/chromeos/proxy_handler.h" | 15 #include "chrome/browser/ui/webui/options/chromeos/proxy_handler.h" |
| 15 #include "chrome/common/jstemplate_builder.h" | 16 #include "chrome/common/jstemplate_builder.h" |
| 16 #include "chrome/common/url_constants.h" | 17 #include "chrome/common/url_constants.h" |
| 17 #include "content/browser/tab_contents/tab_contents.h" | 18 #include "content/browser/tab_contents/tab_contents.h" |
| 18 #include "grit/browser_resources.h" | 19 #include "grit/browser_resources.h" |
| 19 #include "ui/base/resource/resource_bundle.h" | 20 #include "ui/base/resource/resource_bundle.h" |
| 20 | 21 |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 58 | 59 |
| 59 SendResponse(request_id, base::RefCountedString::TakeString(&full_html)); | 60 SendResponse(request_id, base::RefCountedString::TakeString(&full_html)); |
| 60 } | 61 } |
| 61 | 62 |
| 62 } // namespace | 63 } // namespace |
| 63 | 64 |
| 64 namespace chromeos { | 65 namespace chromeos { |
| 65 | 66 |
| 66 ProxySettingsUI::ProxySettingsUI(TabContents* contents) | 67 ProxySettingsUI::ProxySettingsUI(TabContents* contents) |
| 67 : ChromeWebUI(contents), | 68 : ChromeWebUI(contents), |
| 68 proxy_settings_(NULL), | 69 proxy_handler_(new ProxyHandler()) { |
| 69 proxy_handler_(new ProxyHandler(GetProfile())) { | |
| 70 // |localized_strings| will be owned by ProxySettingsHTMLSource. | 70 // |localized_strings| will be owned by ProxySettingsHTMLSource. |
| 71 DictionaryValue* localized_strings = new DictionaryValue(); | 71 DictionaryValue* localized_strings = new DictionaryValue(); |
| 72 | 72 |
| 73 CoreChromeOSOptionsHandler* core_handler = new CoreChromeOSOptionsHandler(); | 73 CoreChromeOSOptionsHandler* core_handler = new CoreChromeOSOptionsHandler(); |
| 74 core_handler->set_handlers_host(this); | 74 core_handler->set_handlers_host(this); |
| 75 core_handler->GetLocalizedValues(localized_strings); | 75 core_handler->GetLocalizedValues(localized_strings); |
| 76 AddMessageHandler(core_handler->Attach(this)); | 76 AddMessageHandler(core_handler->Attach(this)); |
| 77 | 77 |
| 78 proxy_handler_->GetLocalizedValues(localized_strings); | 78 proxy_handler_->GetLocalizedValues(localized_strings); |
| 79 AddMessageHandler(proxy_handler_->Attach(this)); | 79 AddMessageHandler(proxy_handler_->Attach(this)); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 94 } | 94 } |
| 95 proxy_handler_ = NULL; // Weak ptr that is owned by base class, nullify it. | 95 proxy_handler_ = NULL; // Weak ptr that is owned by base class, nullify it. |
| 96 } | 96 } |
| 97 | 97 |
| 98 void ProxySettingsUI::InitializeHandlers() { | 98 void ProxySettingsUI::InitializeHandlers() { |
| 99 std::vector<WebUIMessageHandler*>::iterator iter; | 99 std::vector<WebUIMessageHandler*>::iterator iter; |
| 100 // Skip over the generic handler. | 100 // Skip over the generic handler. |
| 101 for (iter = handlers_.begin() + 1; iter != handlers_.end(); ++iter) { | 101 for (iter = handlers_.begin() + 1; iter != handlers_.end(); ++iter) { |
| 102 (static_cast<OptionsPageUIHandler*>(*iter))->Initialize(); | 102 (static_cast<OptionsPageUIHandler*>(*iter))->Initialize(); |
| 103 } | 103 } |
| 104 if (proxy_settings()) { | 104 PrefProxyConfigTracker* proxy_tracker = GetProfile()->GetProxyConfigTracker(); |
| 105 proxy_settings()->MakeActiveNetworkCurrent(); | 105 proxy_tracker->UIMakeActiveNetworkCurrent(); |
| 106 std::string network_name; | 106 std::string network_name; |
| 107 GetProfile()->GetProxyConfigTracker()->UIGetCurrentNetworkName( | 107 proxy_tracker->UIGetCurrentNetworkName(&network_name); |
| 108 &network_name); | 108 proxy_handler_->SetNetworkName(network_name); |
| 109 proxy_handler_->SetNetworkName(network_name); | |
| 110 } | |
| 111 } | |
| 112 | |
| 113 chromeos::ProxyCrosSettingsProvider* ProxySettingsUI::proxy_settings() { | |
| 114 if (!proxy_settings_) { | |
| 115 proxy_settings_ = static_cast<chromeos::ProxyCrosSettingsProvider*>( | |
| 116 chromeos::CrosSettings::Get()->GetProvider("cros.session.proxy")); | |
| 117 if (!proxy_settings_) | |
| 118 NOTREACHED() << "Error getting access to proxy cros settings provider"; | |
| 119 } | |
| 120 return proxy_settings_; | |
| 121 } | 109 } |
| 122 | 110 |
| 123 } // namespace chromeos | 111 } // namespace chromeos |
| OLD | NEW |