| 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/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 Loading... |
| 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 Loading... |
| 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 content::NotificationService::current()->Notify( |
| 698 chrome::NOTIFICATION_CURRENT_NETWORK_CHANGED, |
| 699 content::NotificationService::AllSources(), |
| 700 content::NotificationService::NoDetails()); |
| 701 |
| 695 DictionaryValue dictionary; | 702 DictionaryValue dictionary; |
| 696 std::string hardware_address; | 703 std::string hardware_address; |
| 697 chromeos::NetworkIPConfigVector ipconfigs = cros_->GetIPConfigs( | 704 chromeos::NetworkIPConfigVector ipconfigs = cros_->GetIPConfigs( |
| 698 network->device_path(), &hardware_address, | 705 network->device_path(), &hardware_address, |
| 699 chromeos::NetworkLibrary::FORMAT_COLON_SEPARATED_HEX); | 706 chromeos::NetworkLibrary::FORMAT_COLON_SEPARATED_HEX); |
| 700 if (!hardware_address.empty()) | 707 if (!hardware_address.empty()) |
| 701 dictionary.SetString("hardwareAddress", hardware_address); | 708 dictionary.SetString("hardwareAddress", hardware_address); |
| 702 for (chromeos::NetworkIPConfigVector::const_iterator it = ipconfigs.begin(); | 709 for (chromeos::NetworkIPConfigVector::const_iterator it = ipconfigs.begin(); |
| 703 it != ipconfigs.end(); ++it) { | 710 it != ipconfigs.end(); ++it) { |
| 704 const chromeos::NetworkIPConfig& ipconfig = *it; | 711 const chromeos::NetworkIPConfig& ipconfig = *it; |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 768 PopulateVPNDetails(vpn, &dictionary); | 775 PopulateVPNDetails(vpn, &dictionary); |
| 769 } | 776 } |
| 770 } else if (type == chromeos::TYPE_ETHERNET) { | 777 } else if (type == chromeos::TYPE_ETHERNET) { |
| 771 dictionary.SetBoolean("deviceConnected", cros_->ethernet_connected()); | 778 dictionary.SetBoolean("deviceConnected", cros_->ethernet_connected()); |
| 772 } | 779 } |
| 773 | 780 |
| 774 web_ui_->CallJavascriptFunction( | 781 web_ui_->CallJavascriptFunction( |
| 775 "options.InternetOptions.showDetailedInfo", dictionary); | 782 "options.InternetOptions.showDetailedInfo", dictionary); |
| 776 } | 783 } |
| 777 | 784 |
| 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( | 785 void InternetOptionsHandler::PopulateWifiDetails( |
| 789 const chromeos::WifiNetwork* wifi, | 786 const chromeos::WifiNetwork* wifi, |
| 790 DictionaryValue* dictionary) { | 787 DictionaryValue* dictionary) { |
| 791 dictionary->SetString("ssid", wifi->name()); | 788 dictionary->SetString("ssid", wifi->name()); |
| 792 bool remembered = (wifi->profile_type() != chromeos::PROFILE_NONE); | 789 bool remembered = (wifi->profile_type() != chromeos::PROFILE_NONE); |
| 793 dictionary->SetBoolean("remembered", remembered); | 790 dictionary->SetBoolean("remembered", remembered); |
| 794 dictionary->SetBoolean("encrypted", wifi->encrypted()); | 791 dictionary->SetBoolean("encrypted", wifi->encrypted()); |
| 795 bool shared = wifi->profile_type() == chromeos::PROFILE_SHARED; | 792 bool shared = wifi->profile_type() == chromeos::PROFILE_SHARED; |
| 796 dictionary->SetBoolean("shared", shared); | 793 dictionary->SetBoolean("shared", shared); |
| 797 } | 794 } |
| (...skipping 498 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1296 dictionary->Set("wirelessList", GetWirelessList()); | 1293 dictionary->Set("wirelessList", GetWirelessList()); |
| 1297 dictionary->Set("vpnList", GetVPNList()); | 1294 dictionary->Set("vpnList", GetVPNList()); |
| 1298 dictionary->Set("rememberedList", GetRememberedList()); | 1295 dictionary->Set("rememberedList", GetRememberedList()); |
| 1299 dictionary->SetBoolean("wifiAvailable", cros_->wifi_available()); | 1296 dictionary->SetBoolean("wifiAvailable", cros_->wifi_available()); |
| 1300 dictionary->SetBoolean("wifiBusy", cros_->wifi_busy()); | 1297 dictionary->SetBoolean("wifiBusy", cros_->wifi_busy()); |
| 1301 dictionary->SetBoolean("wifiEnabled", cros_->wifi_enabled()); | 1298 dictionary->SetBoolean("wifiEnabled", cros_->wifi_enabled()); |
| 1302 dictionary->SetBoolean("cellularAvailable", cros_->cellular_available()); | 1299 dictionary->SetBoolean("cellularAvailable", cros_->cellular_available()); |
| 1303 dictionary->SetBoolean("cellularBusy", cros_->cellular_busy()); | 1300 dictionary->SetBoolean("cellularBusy", cros_->cellular_busy()); |
| 1304 dictionary->SetBoolean("cellularEnabled", cros_->cellular_enabled()); | 1301 dictionary->SetBoolean("cellularEnabled", cros_->cellular_enabled()); |
| 1305 } | 1302 } |
| OLD | NEW |