| 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 14 matching lines...) Expand all Loading... |
| 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/sim_dialog_delegate.h" | 32 #include "chrome/browser/chromeos/sim_dialog_delegate.h" |
| 33 #include "chrome/browser/chromeos/status/network_menu_icon.h" | 33 #include "chrome/browser/chromeos/status/network_menu_icon.h" |
| 34 #include "chrome/browser/chromeos/user_cros_settings_provider.h" | 34 #include "chrome/browser/chromeos/user_cros_settings_provider.h" |
| 35 #include "chrome/browser/prefs/pref_service.h" | |
| 36 #include "chrome/browser/profiles/profile.h" | 35 #include "chrome/browser/profiles/profile.h" |
| 37 #include "chrome/browser/ui/browser.h" | 36 #include "chrome/browser/ui/browser.h" |
| 38 #include "chrome/browser/ui/browser_list.h" | 37 #include "chrome/browser/ui/browser_list.h" |
| 39 #include "chrome/browser/ui/browser_window.h" | 38 #include "chrome/browser/ui/browser_window.h" |
| 40 #include "chrome/browser/ui/views/window.h" | 39 #include "chrome/browser/ui/views/window.h" |
| 41 #include "chrome/browser/ui/webui/web_ui_util.h" | 40 #include "chrome/browser/ui/webui/web_ui_util.h" |
| 42 #include "chrome/common/chrome_notification_types.h" | 41 #include "chrome/common/chrome_notification_types.h" |
| 43 #include "chrome/common/chrome_switches.h" | 42 #include "chrome/common/chrome_switches.h" |
| 44 #include "chrome/common/pref_names.h" | |
| 45 #include "chrome/common/time_format.h" | 43 #include "chrome/common/time_format.h" |
| 46 #include "content/common/notification_service.h" | 44 #include "content/common/notification_service.h" |
| 47 #include "grit/chromium_strings.h" | 45 #include "grit/chromium_strings.h" |
| 48 #include "grit/generated_resources.h" | 46 #include "grit/generated_resources.h" |
| 49 #include "grit/locale_settings.h" | 47 #include "grit/locale_settings.h" |
| 50 #include "grit/theme_resources.h" | 48 #include "grit/theme_resources.h" |
| 51 #include "third_party/skia/include/core/SkBitmap.h" | 49 #include "third_party/skia/include/core/SkBitmap.h" |
| 52 #include "ui/base/l10n/l10n_util.h" | 50 #include "ui/base/l10n/l10n_util.h" |
| 53 #include "ui/base/resource/resource_bundle.h" | 51 #include "ui/base/resource/resource_bundle.h" |
| 54 #include "views/widget/widget.h" | 52 #include "views/widget/widget.h" |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 113 localized_strings->SetString("activate_button", | 111 localized_strings->SetString("activate_button", |
| 114 l10n_util::GetStringUTF16( | 112 l10n_util::GetStringUTF16( |
| 115 IDS_OPTIONS_SETTINGS_ACTIVATE)); | 113 IDS_OPTIONS_SETTINGS_ACTIVATE)); |
| 116 localized_strings->SetString("buyplan_button", | 114 localized_strings->SetString("buyplan_button", |
| 117 l10n_util::GetStringUTF16( | 115 l10n_util::GetStringUTF16( |
| 118 IDS_OPTIONS_SETTINGS_BUY_PLAN)); | 116 IDS_OPTIONS_SETTINGS_BUY_PLAN)); |
| 119 | 117 |
| 120 localized_strings->SetString("changeProxyButton", | 118 localized_strings->SetString("changeProxyButton", |
| 121 l10n_util::GetStringUTF16( | 119 l10n_util::GetStringUTF16( |
| 122 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_CHANGE_PROXY_BUTTON)); | 120 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_CHANGE_PROXY_BUTTON)); |
| 123 localized_strings->SetString("enableSharedProxiesHint", | |
| 124 l10n_util::GetStringFUTF16( | |
| 125 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_ENABLE_SHARED_PROXIES_HINT, | |
| 126 l10n_util::GetStringUTF16(IDS_OPTIONS_SETTINGS_USE_SHARED_PROXIES))); | |
| 127 localized_strings->SetString("policyManagedProxyText", | |
| 128 l10n_util::GetStringUTF16( | |
| 129 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_POLICY_MANAGED_PROXY_TEXT)); | |
| 130 localized_strings->SetString("extensionManagedProxyText", | |
| 131 l10n_util::GetStringUTF16( | |
| 132 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_EXTENSION_MANAGED_PROXY_TEXT)); | |
| 133 localized_strings->SetString("unmodifiableProxyText", | |
| 134 l10n_util::GetStringUTF16( | |
| 135 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_UNMODIFIABLE_PROXY_TEXT)); | |
| 136 | 121 |
| 137 localized_strings->SetString("wifiNetworkTabLabel", | 122 localized_strings->SetString("wifiNetworkTabLabel", |
| 138 l10n_util::GetStringUTF16( | 123 l10n_util::GetStringUTF16( |
| 139 IDS_OPTIONS_SETTINGS_INTERNET_TAB_WIFI)); | 124 IDS_OPTIONS_SETTINGS_INTERNET_TAB_WIFI)); |
| 140 localized_strings->SetString("vpnTabLabel", | 125 localized_strings->SetString("vpnTabLabel", |
| 141 l10n_util::GetStringUTF16( | 126 l10n_util::GetStringUTF16( |
| 142 IDS_OPTIONS_SETTINGS_INTERNET_TAB_VPN)); | 127 IDS_OPTIONS_SETTINGS_INTERNET_TAB_VPN)); |
| 143 localized_strings->SetString("cellularPlanTabLabel", | 128 localized_strings->SetString("cellularPlanTabLabel", |
| 144 l10n_util::GetStringUTF16( | 129 l10n_util::GetStringUTF16( |
| 145 IDS_OPTIONS_SETTINGS_INTERNET_TAB_PLAN)); | 130 IDS_OPTIONS_SETTINGS_INTERNET_TAB_PLAN)); |
| (...skipping 530 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 676 | 661 |
| 677 cros_->SetIPConfig(chromeos::NetworkIPConfig(network->device_path(), | 662 cros_->SetIPConfig(chromeos::NetworkIPConfig(network->device_path(), |
| 678 dhcp_str == "true" ? chromeos::IPCONFIG_TYPE_DHCP : | 663 dhcp_str == "true" ? chromeos::IPCONFIG_TYPE_DHCP : |
| 679 chromeos::IPCONFIG_TYPE_IPV4, | 664 chromeos::IPCONFIG_TYPE_IPV4, |
| 680 address, netmask, gateway, name_servers)); | 665 address, netmask, gateway, name_servers)); |
| 681 } | 666 } |
| 682 | 667 |
| 683 void InternetOptionsHandler::PopulateDictionaryDetails( | 668 void InternetOptionsHandler::PopulateDictionaryDetails( |
| 684 const chromeos::Network* network) { | 669 const chromeos::Network* network) { |
| 685 DCHECK(network); | 670 DCHECK(network); |
| 686 bool use_shared_proxies = false; | 671 if (proxy_settings()) |
| 687 if (proxy_settings()) { | |
| 688 proxy_settings()->SetCurrentNetwork(network->service_path()); | 672 proxy_settings()->SetCurrentNetwork(network->service_path()); |
| 689 use_shared_proxies = proxy_settings()->IsUsingSharedProxies(); | |
| 690 } | |
| 691 DictionaryValue dictionary; | 673 DictionaryValue dictionary; |
| 692 std::string hardware_address; | 674 std::string hardware_address; |
| 693 chromeos::NetworkIPConfigVector ipconfigs = cros_->GetIPConfigs( | 675 chromeos::NetworkIPConfigVector ipconfigs = cros_->GetIPConfigs( |
| 694 network->device_path(), &hardware_address, | 676 network->device_path(), &hardware_address, |
| 695 chromeos::NetworkLibrary::FORMAT_COLON_SEPARATED_HEX); | 677 chromeos::NetworkLibrary::FORMAT_COLON_SEPARATED_HEX); |
| 696 if (!hardware_address.empty()) | 678 if (!hardware_address.empty()) |
| 697 dictionary.SetString("hardwareAddress", hardware_address); | 679 dictionary.SetString("hardwareAddress", hardware_address); |
| 698 for (chromeos::NetworkIPConfigVector::const_iterator it = ipconfigs.begin(); | 680 for (chromeos::NetworkIPConfigVector::const_iterator it = ipconfigs.begin(); |
| 699 it != ipconfigs.end(); ++it) { | 681 it != ipconfigs.end(); ++it) { |
| 700 const chromeos::NetworkIPConfig& ipconfig = *it; | 682 const chromeos::NetworkIPConfig& ipconfig = *it; |
| 701 scoped_ptr<DictionaryValue> ipconfig_dict(new DictionaryValue()); | 683 scoped_ptr<DictionaryValue> ipconfig_dict(new DictionaryValue()); |
| 702 ipconfig_dict->SetString("address", ipconfig.address); | 684 ipconfig_dict->SetString("address", ipconfig.address); |
| 703 ipconfig_dict->SetString("subnetAddress", ipconfig.netmask); | 685 ipconfig_dict->SetString("subnetAddress", ipconfig.netmask); |
| 704 ipconfig_dict->SetString("gateway", ipconfig.gateway); | 686 ipconfig_dict->SetString("gateway", ipconfig.gateway); |
| 705 ipconfig_dict->SetString("dns", ipconfig.name_servers); | 687 ipconfig_dict->SetString("dns", ipconfig.name_servers); |
| 706 if (ipconfig.type == chromeos::IPCONFIG_TYPE_DHCP) | 688 if (ipconfig.type == chromeos::IPCONFIG_TYPE_DHCP) |
| 707 dictionary.Set("ipconfigDHCP", ipconfig_dict.release()); | 689 dictionary.Set("ipconfigDHCP", ipconfig_dict.release()); |
| 708 else if (ipconfig.type == chromeos::IPCONFIG_TYPE_IPV4) | 690 else if (ipconfig.type == chromeos::IPCONFIG_TYPE_IPV4) |
| 709 dictionary.Set("ipconfigStatic", ipconfig_dict.release()); | 691 dictionary.Set("ipconfigStatic", ipconfig_dict.release()); |
| 710 } | 692 } |
| 711 | 693 |
| 712 chromeos::ConnectionType type = network->type(); | 694 chromeos::ConnectionType type = network->type(); |
| 713 dictionary.SetInteger("type", type); | 695 dictionary.SetInteger("type", type); |
| 714 dictionary.SetString("servicePath", network->service_path()); | 696 dictionary.SetString("servicePath", network->service_path()); |
| 715 dictionary.SetBoolean("connecting", network->connecting()); | 697 dictionary.SetBoolean("connecting", network->connecting()); |
| 716 dictionary.SetBoolean("connected", network->connected()); | 698 dictionary.SetBoolean("connected", network->connected()); |
| 717 dictionary.SetString("connectionState", network->GetStateString()); | 699 dictionary.SetString("connectionState", network->GetStateString()); |
| 718 | 700 |
| 719 // Determine if proxy is configurable. | 701 // Only show proxy for remembered networks. |
| 720 // First check proxy prefs. | 702 chromeos::NetworkProfileType network_profile = network->profile_type(); |
| 721 bool proxy_configurable = true; | 703 dictionary.SetBoolean("showProxy", network_profile != chromeos::PROFILE_NONE); |
| 722 std::string change_proxy_text; | |
| 723 if (web_ui_) { | |
| 724 const PrefService::Preference* proxy_pref = | |
| 725 Profile::FromWebUI(web_ui_)->GetPrefs()->FindPreference(prefs::kProxy); | |
| 726 if (proxy_pref && (!proxy_pref->IsUserModifiable() || | |
| 727 proxy_pref->HasUserSetting())) { | |
| 728 proxy_configurable = false; | |
| 729 // Provide reason that proxy is managed by admin or extension. | |
| 730 if (proxy_pref->IsManaged()) | |
| 731 change_proxy_text = "policyManagedProxyText"; | |
| 732 else if (proxy_pref->IsExtensionControlled()) | |
| 733 change_proxy_text = "extensionManagedProxyText"; | |
| 734 else | |
| 735 change_proxy_text = "unmodifiableProxyText"; | |
| 736 } | |
| 737 } | |
| 738 // Next check network type and use-shared-proxies. | |
| 739 chromeos::NetworkProfileType profile = network->profile_type(); | |
| 740 bool shared_network = type == chromeos::TYPE_ETHERNET || | |
| 741 profile == chromeos::PROFILE_SHARED; | |
| 742 if (proxy_configurable) { // Only check more if proxy is still configurable. | |
| 743 proxy_configurable = profile == chromeos::PROFILE_USER || | |
| 744 (shared_network && use_shared_proxies); | |
| 745 } | |
| 746 // If no reason has been set yet, provide hint to configure shared proxy. | |
| 747 if (change_proxy_text.empty() && shared_network && !use_shared_proxies) | |
| 748 change_proxy_text = "enableSharedProxiesHint"; | |
| 749 // Lastly, store proxy-configurable flag and, if available, text to display. | |
| 750 dictionary.SetBoolean("proxyConfigurable", proxy_configurable); | |
| 751 if (!change_proxy_text.empty()) | |
| 752 dictionary.SetString("changeProxyText", change_proxy_text); | |
| 753 | 704 |
| 754 // Hide the dhcp/static radio if not ethernet or wifi (or if not enabled) | 705 // Hide the dhcp/static radio if not ethernet or wifi (or if not enabled) |
| 755 bool staticIPConfig = CommandLine::ForCurrentProcess()->HasSwitch( | 706 bool staticIPConfig = CommandLine::ForCurrentProcess()->HasSwitch( |
| 756 switches::kEnableStaticIPConfig); | 707 switches::kEnableStaticIPConfig); |
| 757 dictionary.SetBoolean("showStaticIPConfig", staticIPConfig && | 708 dictionary.SetBoolean("showStaticIPConfig", staticIPConfig && |
| 758 (type == chromeos::TYPE_WIFI || type == chromeos::TYPE_ETHERNET)); | 709 (type == chromeos::TYPE_WIFI || type == chromeos::TYPE_ETHERNET)); |
| 759 | 710 |
| 760 if (network->profile_type() == chromeos::PROFILE_USER) { | 711 if (network_profile == chromeos::PROFILE_USER) { |
| 761 dictionary.SetBoolean("showPreferred", true); | 712 dictionary.SetBoolean("showPreferred", true); |
| 762 dictionary.SetBoolean("preferred", network->preferred()); | 713 dictionary.SetBoolean("preferred", network->preferred()); |
| 763 } else { | 714 } else { |
| 764 dictionary.SetBoolean("showPreferred", false); | 715 dictionary.SetBoolean("showPreferred", false); |
| 765 dictionary.SetBoolean("preferred", false); | 716 dictionary.SetBoolean("preferred", false); |
| 766 } | 717 } |
| 767 dictionary.SetBoolean("autoConnect", network->auto_connect()); | 718 dictionary.SetBoolean("autoConnect", network->auto_connect()); |
| 768 | 719 |
| 769 if (type == chromeos::TYPE_WIFI) { | 720 if (type == chromeos::TYPE_WIFI) { |
| 770 dictionary.SetBoolean("deviceConnected", cros_->wifi_connected()); | 721 dictionary.SetBoolean("deviceConnected", cros_->wifi_connected()); |
| (...skipping 552 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1323 dictionary->Set("wirelessList", GetWirelessList()); | 1274 dictionary->Set("wirelessList", GetWirelessList()); |
| 1324 dictionary->Set("vpnList", GetVPNList()); | 1275 dictionary->Set("vpnList", GetVPNList()); |
| 1325 dictionary->Set("rememberedList", GetRememberedList()); | 1276 dictionary->Set("rememberedList", GetRememberedList()); |
| 1326 dictionary->SetBoolean("wifiAvailable", cros_->wifi_available()); | 1277 dictionary->SetBoolean("wifiAvailable", cros_->wifi_available()); |
| 1327 dictionary->SetBoolean("wifiBusy", cros_->wifi_busy()); | 1278 dictionary->SetBoolean("wifiBusy", cros_->wifi_busy()); |
| 1328 dictionary->SetBoolean("wifiEnabled", cros_->wifi_enabled()); | 1279 dictionary->SetBoolean("wifiEnabled", cros_->wifi_enabled()); |
| 1329 dictionary->SetBoolean("cellularAvailable", cros_->cellular_available()); | 1280 dictionary->SetBoolean("cellularAvailable", cros_->cellular_available()); |
| 1330 dictionary->SetBoolean("cellularBusy", cros_->cellular_busy()); | 1281 dictionary->SetBoolean("cellularBusy", cros_->cellular_busy()); |
| 1331 dictionary->SetBoolean("cellularEnabled", cros_->cellular_enabled()); | 1282 dictionary->SetBoolean("cellularEnabled", cros_->cellular_enabled()); |
| 1332 } | 1283 } |
| OLD | NEW |