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

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

Issue 8467012: Refactor proxy handling for ChromeOS to not go through the CrosSettings interface. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Centralized the proxy change notification. Created 9 years, 1 month 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) 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/options/chromeos/internet_options_handler.h" 5 #include "chrome/browser/ui/webui/options/chromeos/internet_options_handler.h"
6 6
7 #include <ctype.h> 7 #include <ctype.h>
8 8
9 #include <map> 9 #include <map>
10 #include <string> 10 #include <string>
(...skipping 11 matching lines...) Expand all
22 #include "base/time.h" 22 #include "base/time.h"
23 #include "base/utf_string_conversions.h" 23 #include "base/utf_string_conversions.h"
24 #include "base/values.h" 24 #include "base/values.h"
25 #include "chrome/browser/browser_process.h" 25 #include "chrome/browser/browser_process.h"
26 #include "chrome/browser/chromeos/choose_mobile_network_dialog.h" 26 #include "chrome/browser/chromeos/choose_mobile_network_dialog.h"
27 #include "chrome/browser/chromeos/cros/cros_library.h" 27 #include "chrome/browser/chromeos/cros/cros_library.h"
28 #include "chrome/browser/chromeos/cros_settings.h" 28 #include "chrome/browser/chromeos/cros_settings.h"
29 #include "chrome/browser/chromeos/login/user_manager.h" 29 #include "chrome/browser/chromeos/login/user_manager.h"
30 #include "chrome/browser/chromeos/mobile_config.h" 30 #include "chrome/browser/chromeos/mobile_config.h"
31 #include "chrome/browser/chromeos/options/network_config_view.h" 31 #include "chrome/browser/chromeos/options/network_config_view.h"
32 #include "chrome/browser/chromeos/proxy_config_service_impl.h"
32 #include "chrome/browser/chromeos/sim_dialog_delegate.h" 33 #include "chrome/browser/chromeos/sim_dialog_delegate.h"
33 #include "chrome/browser/chromeos/status/network_menu_icon.h" 34 #include "chrome/browser/chromeos/status/network_menu_icon.h"
34 #include "chrome/browser/chromeos/user_cros_settings_provider.h" 35 #include "chrome/browser/chromeos/user_cros_settings_provider.h"
36 #include "chrome/browser/net/pref_proxy_config_tracker.h"
35 #include "chrome/browser/profiles/profile.h" 37 #include "chrome/browser/profiles/profile.h"
36 #include "chrome/browser/ui/browser.h" 38 #include "chrome/browser/ui/browser.h"
37 #include "chrome/browser/ui/browser_list.h" 39 #include "chrome/browser/ui/browser_list.h"
38 #include "chrome/browser/ui/browser_window.h" 40 #include "chrome/browser/ui/browser_window.h"
39 #include "chrome/browser/ui/views/window.h" 41 #include "chrome/browser/ui/views/window.h"
40 #include "chrome/browser/ui/webui/web_ui_util.h" 42 #include "chrome/browser/ui/webui/web_ui_util.h"
41 #include "chrome/common/chrome_notification_types.h" 43 #include "chrome/common/chrome_notification_types.h"
42 #include "chrome/common/chrome_switches.h" 44 #include "chrome/common/chrome_switches.h"
43 #include "chrome/common/time_format.h" 45 #include "chrome/common/time_format.h"
44 #include "content/public/browser/notification_service.h" 46 #include "content/public/browser/notification_service.h"
45 #include "grit/chromium_strings.h" 47 #include "grit/chromium_strings.h"
46 #include "grit/generated_resources.h" 48 #include "grit/generated_resources.h"
47 #include "grit/locale_settings.h" 49 #include "grit/locale_settings.h"
48 #include "grit/theme_resources.h" 50 #include "grit/theme_resources.h"
49 #include "third_party/skia/include/core/SkBitmap.h" 51 #include "third_party/skia/include/core/SkBitmap.h"
50 #include "ui/base/l10n/l10n_util.h" 52 #include "ui/base/l10n/l10n_util.h"
51 #include "ui/base/resource/resource_bundle.h" 53 #include "ui/base/resource/resource_bundle.h"
52 #include "views/widget/widget.h" 54 #include "views/widget/widget.h"
53 55
54 static const char kOtherNetworksFakePath[] = "?"; 56 static const char kOtherNetworksFakePath[] = "?";
55 57
56 InternetOptionsHandler::InternetOptionsHandler() 58 InternetOptionsHandler::InternetOptionsHandler()
57 : chromeos::CrosOptionsPageUIHandler(NULL), 59 : chromeos::CrosOptionsPageUIHandler(NULL) {
58 proxy_settings_(NULL) {
59 registrar_.Add(this, chrome::NOTIFICATION_REQUIRE_PIN_SETTING_CHANGE_ENDED, 60 registrar_.Add(this, chrome::NOTIFICATION_REQUIRE_PIN_SETTING_CHANGE_ENDED,
60 content::NotificationService::AllSources()); 61 content::NotificationService::AllSources());
61 registrar_.Add(this, chrome::NOTIFICATION_ENTER_PIN_ENDED, 62 registrar_.Add(this, chrome::NOTIFICATION_ENTER_PIN_ENDED,
62 content::NotificationService::AllSources()); 63 content::NotificationService::AllSources());
63 cros_ = chromeos::CrosLibrary::Get()->GetNetworkLibrary(); 64 cros_ = chromeos::CrosLibrary::Get()->GetNetworkLibrary();
64 if (cros_) { 65 if (cros_) {
65 cros_->AddNetworkManagerObserver(this); 66 cros_->AddNetworkManagerObserver(this);
66 cros_->AddCellularDataPlanObserver(this); 67 cros_->AddCellularDataPlanObserver(this);
67 MonitorNetworks(); 68 MonitorNetworks();
68 } 69 }
(...skipping 614 matching lines...) Expand 10 before | Expand all | Expand 10 after
683 684
684 cros_->SetIPConfig(chromeos::NetworkIPConfig(network->device_path(), 685 cros_->SetIPConfig(chromeos::NetworkIPConfig(network->device_path(),
685 dhcp_str == "true" ? chromeos::IPCONFIG_TYPE_DHCP : 686 dhcp_str == "true" ? chromeos::IPCONFIG_TYPE_DHCP :
686 chromeos::IPCONFIG_TYPE_IPV4, 687 chromeos::IPCONFIG_TYPE_IPV4,
687 address, netmask, gateway, name_servers)); 688 address, netmask, gateway, name_servers));
688 } 689 }
689 690
690 void InternetOptionsHandler::PopulateDictionaryDetails( 691 void InternetOptionsHandler::PopulateDictionaryDetails(
691 const chromeos::Network* network) { 692 const chromeos::Network* network) {
692 DCHECK(network); 693 DCHECK(network);
693 if (proxy_settings()) 694
694 proxy_settings()->SetCurrentNetwork(network->service_path()); 695 Profile::FromWebUI(web_ui_)->GetProxyConfigTracker()->UISetCurrentNetwork(
696 network->service_path());
697
695 DictionaryValue dictionary; 698 DictionaryValue dictionary;
696 std::string hardware_address; 699 std::string hardware_address;
697 chromeos::NetworkIPConfigVector ipconfigs = cros_->GetIPConfigs( 700 chromeos::NetworkIPConfigVector ipconfigs = cros_->GetIPConfigs(
698 network->device_path(), &hardware_address, 701 network->device_path(), &hardware_address,
699 chromeos::NetworkLibrary::FORMAT_COLON_SEPARATED_HEX); 702 chromeos::NetworkLibrary::FORMAT_COLON_SEPARATED_HEX);
700 if (!hardware_address.empty()) 703 if (!hardware_address.empty())
701 dictionary.SetString("hardwareAddress", hardware_address); 704 dictionary.SetString("hardwareAddress", hardware_address);
702 for (chromeos::NetworkIPConfigVector::const_iterator it = ipconfigs.begin(); 705 for (chromeos::NetworkIPConfigVector::const_iterator it = ipconfigs.begin();
703 it != ipconfigs.end(); ++it) { 706 it != ipconfigs.end(); ++it) {
704 const chromeos::NetworkIPConfig& ipconfig = *it; 707 const chromeos::NetworkIPConfig& ipconfig = *it;
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
768 PopulateVPNDetails(vpn, &dictionary); 771 PopulateVPNDetails(vpn, &dictionary);
769 } 772 }
770 } else if (type == chromeos::TYPE_ETHERNET) { 773 } else if (type == chromeos::TYPE_ETHERNET) {
771 dictionary.SetBoolean("deviceConnected", cros_->ethernet_connected()); 774 dictionary.SetBoolean("deviceConnected", cros_->ethernet_connected());
772 } 775 }
773 776
774 web_ui_->CallJavascriptFunction( 777 web_ui_->CallJavascriptFunction(
775 "options.InternetOptions.showDetailedInfo", dictionary); 778 "options.InternetOptions.showDetailedInfo", dictionary);
776 } 779 }
777 780
778 chromeos::ProxyCrosSettingsProvider* InternetOptionsHandler::proxy_settings() {
779 if (!proxy_settings_) {
780 proxy_settings_ = static_cast<chromeos::ProxyCrosSettingsProvider*>(
781 chromeos::CrosSettings::Get()->GetProvider("cros.session.proxy"));
782 if (!proxy_settings_)
783 NOTREACHED() << "Error getting access to proxy cros settings provider";
784 }
785 return proxy_settings_;
786 }
787
788 void InternetOptionsHandler::PopulateWifiDetails( 781 void InternetOptionsHandler::PopulateWifiDetails(
789 const chromeos::WifiNetwork* wifi, 782 const chromeos::WifiNetwork* wifi,
790 DictionaryValue* dictionary) { 783 DictionaryValue* dictionary) {
791 dictionary->SetString("ssid", wifi->name()); 784 dictionary->SetString("ssid", wifi->name());
792 bool remembered = (wifi->profile_type() != chromeos::PROFILE_NONE); 785 bool remembered = (wifi->profile_type() != chromeos::PROFILE_NONE);
793 dictionary->SetBoolean("remembered", remembered); 786 dictionary->SetBoolean("remembered", remembered);
794 dictionary->SetBoolean("encrypted", wifi->encrypted()); 787 dictionary->SetBoolean("encrypted", wifi->encrypted());
795 bool shared = wifi->profile_type() == chromeos::PROFILE_SHARED; 788 bool shared = wifi->profile_type() == chromeos::PROFILE_SHARED;
796 dictionary->SetBoolean("shared", shared); 789 dictionary->SetBoolean("shared", shared);
797 } 790 }
(...skipping 498 matching lines...) Expand 10 before | Expand all | Expand 10 after
1296 dictionary->Set("wirelessList", GetWirelessList()); 1289 dictionary->Set("wirelessList", GetWirelessList());
1297 dictionary->Set("vpnList", GetVPNList()); 1290 dictionary->Set("vpnList", GetVPNList());
1298 dictionary->Set("rememberedList", GetRememberedList()); 1291 dictionary->Set("rememberedList", GetRememberedList());
1299 dictionary->SetBoolean("wifiAvailable", cros_->wifi_available()); 1292 dictionary->SetBoolean("wifiAvailable", cros_->wifi_available());
1300 dictionary->SetBoolean("wifiBusy", cros_->wifi_busy()); 1293 dictionary->SetBoolean("wifiBusy", cros_->wifi_busy());
1301 dictionary->SetBoolean("wifiEnabled", cros_->wifi_enabled()); 1294 dictionary->SetBoolean("wifiEnabled", cros_->wifi_enabled());
1302 dictionary->SetBoolean("cellularAvailable", cros_->cellular_available()); 1295 dictionary->SetBoolean("cellularAvailable", cros_->cellular_available());
1303 dictionary->SetBoolean("cellularBusy", cros_->cellular_busy()); 1296 dictionary->SetBoolean("cellularBusy", cros_->cellular_busy());
1304 dictionary->SetBoolean("cellularEnabled", cros_->cellular_enabled()); 1297 dictionary->SetBoolean("cellularEnabled", cros_->cellular_enabled());
1305 } 1298 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698