| 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/public/browser/notification_service.h" | 44 #include "content/public/browser/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 531 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 677 | 662 |
| 678 cros_->SetIPConfig(chromeos::NetworkIPConfig(network->device_path(), | 663 cros_->SetIPConfig(chromeos::NetworkIPConfig(network->device_path(), |
| 679 dhcp_str == "true" ? chromeos::IPCONFIG_TYPE_DHCP : | 664 dhcp_str == "true" ? chromeos::IPCONFIG_TYPE_DHCP : |
| 680 chromeos::IPCONFIG_TYPE_IPV4, | 665 chromeos::IPCONFIG_TYPE_IPV4, |
| 681 address, netmask, gateway, name_servers)); | 666 address, netmask, gateway, name_servers)); |
| 682 } | 667 } |
| 683 | 668 |
| 684 void InternetOptionsHandler::PopulateDictionaryDetails( | 669 void InternetOptionsHandler::PopulateDictionaryDetails( |
| 685 const chromeos::Network* network) { | 670 const chromeos::Network* network) { |
| 686 DCHECK(network); | 671 DCHECK(network); |
| 687 bool use_shared_proxies = false; | 672 if (proxy_settings()) |
| 688 if (proxy_settings()) { | |
| 689 proxy_settings()->SetCurrentNetwork(network->service_path()); | 673 proxy_settings()->SetCurrentNetwork(network->service_path()); |
| 690 use_shared_proxies = proxy_settings()->IsUsingSharedProxies(); | |
| 691 } | |
| 692 DictionaryValue dictionary; | 674 DictionaryValue dictionary; |
| 693 std::string hardware_address; | 675 std::string hardware_address; |
| 694 chromeos::NetworkIPConfigVector ipconfigs = cros_->GetIPConfigs( | 676 chromeos::NetworkIPConfigVector ipconfigs = cros_->GetIPConfigs( |
| 695 network->device_path(), &hardware_address, | 677 network->device_path(), &hardware_address, |
| 696 chromeos::NetworkLibrary::FORMAT_COLON_SEPARATED_HEX); | 678 chromeos::NetworkLibrary::FORMAT_COLON_SEPARATED_HEX); |
| 697 if (!hardware_address.empty()) | 679 if (!hardware_address.empty()) |
| 698 dictionary.SetString("hardwareAddress", hardware_address); | 680 dictionary.SetString("hardwareAddress", hardware_address); |
| 699 for (chromeos::NetworkIPConfigVector::const_iterator it = ipconfigs.begin(); | 681 for (chromeos::NetworkIPConfigVector::const_iterator it = ipconfigs.begin(); |
| 700 it != ipconfigs.end(); ++it) { | 682 it != ipconfigs.end(); ++it) { |
| 701 const chromeos::NetworkIPConfig& ipconfig = *it; | 683 const chromeos::NetworkIPConfig& ipconfig = *it; |
| 702 scoped_ptr<DictionaryValue> ipconfig_dict(new DictionaryValue()); | 684 scoped_ptr<DictionaryValue> ipconfig_dict(new DictionaryValue()); |
| 703 ipconfig_dict->SetString("address", ipconfig.address); | 685 ipconfig_dict->SetString("address", ipconfig.address); |
| 704 ipconfig_dict->SetString("subnetAddress", ipconfig.netmask); | 686 ipconfig_dict->SetString("subnetAddress", ipconfig.netmask); |
| 705 ipconfig_dict->SetString("gateway", ipconfig.gateway); | 687 ipconfig_dict->SetString("gateway", ipconfig.gateway); |
| 706 ipconfig_dict->SetString("dns", ipconfig.name_servers); | 688 ipconfig_dict->SetString("dns", ipconfig.name_servers); |
| 707 if (ipconfig.type == chromeos::IPCONFIG_TYPE_DHCP) | 689 if (ipconfig.type == chromeos::IPCONFIG_TYPE_DHCP) |
| 708 dictionary.Set("ipconfigDHCP", ipconfig_dict.release()); | 690 dictionary.Set("ipconfigDHCP", ipconfig_dict.release()); |
| 709 else if (ipconfig.type == chromeos::IPCONFIG_TYPE_IPV4) | 691 else if (ipconfig.type == chromeos::IPCONFIG_TYPE_IPV4) |
| 710 dictionary.Set("ipconfigStatic", ipconfig_dict.release()); | 692 dictionary.Set("ipconfigStatic", ipconfig_dict.release()); |
| 711 } | 693 } |
| 712 | 694 |
| 713 chromeos::ConnectionType type = network->type(); | 695 chromeos::ConnectionType type = network->type(); |
| 714 dictionary.SetInteger("type", type); | 696 dictionary.SetInteger("type", type); |
| 715 dictionary.SetString("servicePath", network->service_path()); | 697 dictionary.SetString("servicePath", network->service_path()); |
| 716 dictionary.SetBoolean("connecting", network->connecting()); | 698 dictionary.SetBoolean("connecting", network->connecting()); |
| 717 dictionary.SetBoolean("connected", network->connected()); | 699 dictionary.SetBoolean("connected", network->connected()); |
| 718 dictionary.SetString("connectionState", network->GetStateString()); | 700 dictionary.SetString("connectionState", network->GetStateString()); |
| 719 | 701 |
| 720 // Determine if proxy is configurable. | 702 // Only show proxy for remembered networks. |
| 721 // First check proxy prefs. | 703 chromeos::NetworkProfileType network_profile = network->profile_type(); |
| 722 bool proxy_configurable = true; | 704 dictionary.SetBoolean("showProxy", network_profile != chromeos::PROFILE_NONE); |
| 723 std::string change_proxy_text; | |
| 724 if (web_ui_) { | |
| 725 const PrefService::Preference* proxy_pref = | |
| 726 Profile::FromWebUI(web_ui_)->GetPrefs()->FindPreference(prefs::kProxy); | |
| 727 if (proxy_pref && (!proxy_pref->IsUserModifiable() || | |
| 728 proxy_pref->HasUserSetting())) { | |
| 729 proxy_configurable = false; | |
| 730 // Provide reason that proxy is managed by admin or extension. | |
| 731 if (proxy_pref->IsManaged()) | |
| 732 change_proxy_text = "policyManagedProxyText"; | |
| 733 else if (proxy_pref->IsExtensionControlled()) | |
| 734 change_proxy_text = "extensionManagedProxyText"; | |
| 735 else | |
| 736 change_proxy_text = "unmodifiableProxyText"; | |
| 737 } | |
| 738 } | |
| 739 // Next check network type and use-shared-proxies. | |
| 740 chromeos::NetworkProfileType profile = network->profile_type(); | |
| 741 bool shared_network = type == chromeos::TYPE_ETHERNET || | |
| 742 profile == chromeos::PROFILE_SHARED; | |
| 743 if (proxy_configurable) { // Only check more if proxy is still configurable. | |
| 744 proxy_configurable = profile == chromeos::PROFILE_USER || | |
| 745 (shared_network && use_shared_proxies); | |
| 746 } | |
| 747 // If no reason has been set yet, provide hint to configure shared proxy. | |
| 748 if (change_proxy_text.empty() && shared_network && !use_shared_proxies) | |
| 749 change_proxy_text = "enableSharedProxiesHint"; | |
| 750 // Lastly, store proxy-configurable flag and, if available, text to display. | |
| 751 dictionary.SetBoolean("proxyConfigurable", proxy_configurable); | |
| 752 if (!change_proxy_text.empty()) | |
| 753 dictionary.SetString("changeProxyText", change_proxy_text); | |
| 754 | 705 |
| 755 // Hide the dhcp/static radio if not ethernet or wifi (or if not enabled) | 706 // Hide the dhcp/static radio if not ethernet or wifi (or if not enabled) |
| 756 bool staticIPConfig = CommandLine::ForCurrentProcess()->HasSwitch( | 707 bool staticIPConfig = CommandLine::ForCurrentProcess()->HasSwitch( |
| 757 switches::kEnableStaticIPConfig); | 708 switches::kEnableStaticIPConfig); |
| 758 dictionary.SetBoolean("showStaticIPConfig", staticIPConfig && | 709 dictionary.SetBoolean("showStaticIPConfig", staticIPConfig && |
| 759 (type == chromeos::TYPE_WIFI || type == chromeos::TYPE_ETHERNET)); | 710 (type == chromeos::TYPE_WIFI || type == chromeos::TYPE_ETHERNET)); |
| 760 | 711 |
| 761 if (network->profile_type() == chromeos::PROFILE_USER) { | 712 if (network_profile == chromeos::PROFILE_USER) { |
| 762 dictionary.SetBoolean("showPreferred", true); | 713 dictionary.SetBoolean("showPreferred", true); |
| 763 dictionary.SetBoolean("preferred", network->preferred()); | 714 dictionary.SetBoolean("preferred", network->preferred()); |
| 764 } else { | 715 } else { |
| 765 dictionary.SetBoolean("showPreferred", false); | 716 dictionary.SetBoolean("showPreferred", false); |
| 766 dictionary.SetBoolean("preferred", false); | 717 dictionary.SetBoolean("preferred", false); |
| 767 } | 718 } |
| 768 dictionary.SetBoolean("autoConnect", network->auto_connect()); | 719 dictionary.SetBoolean("autoConnect", network->auto_connect()); |
| 769 | 720 |
| 770 if (type == chromeos::TYPE_WIFI) { | 721 if (type == chromeos::TYPE_WIFI) { |
| 771 dictionary.SetBoolean("deviceConnected", cros_->wifi_connected()); | 722 dictionary.SetBoolean("deviceConnected", cros_->wifi_connected()); |
| (...skipping 552 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1324 dictionary->Set("wirelessList", GetWirelessList()); | 1275 dictionary->Set("wirelessList", GetWirelessList()); |
| 1325 dictionary->Set("vpnList", GetVPNList()); | 1276 dictionary->Set("vpnList", GetVPNList()); |
| 1326 dictionary->Set("rememberedList", GetRememberedList()); | 1277 dictionary->Set("rememberedList", GetRememberedList()); |
| 1327 dictionary->SetBoolean("wifiAvailable", cros_->wifi_available()); | 1278 dictionary->SetBoolean("wifiAvailable", cros_->wifi_available()); |
| 1328 dictionary->SetBoolean("wifiBusy", cros_->wifi_busy()); | 1279 dictionary->SetBoolean("wifiBusy", cros_->wifi_busy()); |
| 1329 dictionary->SetBoolean("wifiEnabled", cros_->wifi_enabled()); | 1280 dictionary->SetBoolean("wifiEnabled", cros_->wifi_enabled()); |
| 1330 dictionary->SetBoolean("cellularAvailable", cros_->cellular_available()); | 1281 dictionary->SetBoolean("cellularAvailable", cros_->cellular_available()); |
| 1331 dictionary->SetBoolean("cellularBusy", cros_->cellular_busy()); | 1282 dictionary->SetBoolean("cellularBusy", cros_->cellular_busy()); |
| 1332 dictionary->SetBoolean("cellularEnabled", cros_->cellular_enabled()); | 1283 dictionary->SetBoolean("cellularEnabled", cros_->cellular_enabled()); |
| 1333 } | 1284 } |
| OLD | NEW |