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 552 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
698 | 683 |
699 cros_->SetIPConfig(chromeos::NetworkIPConfig(network->device_path(), | 684 cros_->SetIPConfig(chromeos::NetworkIPConfig(network->device_path(), |
700 dhcp_str == "true" ? chromeos::IPCONFIG_TYPE_DHCP : | 685 dhcp_str == "true" ? chromeos::IPCONFIG_TYPE_DHCP : |
701 chromeos::IPCONFIG_TYPE_IPV4, | 686 chromeos::IPCONFIG_TYPE_IPV4, |
702 address, netmask, gateway, name_servers)); | 687 address, netmask, gateway, name_servers)); |
703 } | 688 } |
704 | 689 |
705 void InternetOptionsHandler::PopulateDictionaryDetails( | 690 void InternetOptionsHandler::PopulateDictionaryDetails( |
706 const chromeos::Network* network) { | 691 const chromeos::Network* network) { |
707 DCHECK(network); | 692 DCHECK(network); |
708 bool use_shared_proxies = false; | 693 if (proxy_settings()) |
709 if (proxy_settings()) { | |
710 proxy_settings()->SetCurrentNetwork(network->service_path()); | 694 proxy_settings()->SetCurrentNetwork(network->service_path()); |
711 use_shared_proxies = proxy_settings()->IsUsingSharedProxies(); | |
712 } | |
713 DictionaryValue dictionary; | 695 DictionaryValue dictionary; |
714 std::string hardware_address; | 696 std::string hardware_address; |
715 chromeos::NetworkIPConfigVector ipconfigs = cros_->GetIPConfigs( | 697 chromeos::NetworkIPConfigVector ipconfigs = cros_->GetIPConfigs( |
716 network->device_path(), &hardware_address, | 698 network->device_path(), &hardware_address, |
717 chromeos::NetworkLibrary::FORMAT_COLON_SEPARATED_HEX); | 699 chromeos::NetworkLibrary::FORMAT_COLON_SEPARATED_HEX); |
718 if (!hardware_address.empty()) | 700 if (!hardware_address.empty()) |
719 dictionary.SetString("hardwareAddress", hardware_address); | 701 dictionary.SetString("hardwareAddress", hardware_address); |
720 for (chromeos::NetworkIPConfigVector::const_iterator it = ipconfigs.begin(); | 702 for (chromeos::NetworkIPConfigVector::const_iterator it = ipconfigs.begin(); |
721 it != ipconfigs.end(); ++it) { | 703 it != ipconfigs.end(); ++it) { |
722 const chromeos::NetworkIPConfig& ipconfig = *it; | 704 const chromeos::NetworkIPConfig& ipconfig = *it; |
723 scoped_ptr<DictionaryValue> ipconfig_dict(new DictionaryValue()); | 705 scoped_ptr<DictionaryValue> ipconfig_dict(new DictionaryValue()); |
724 ipconfig_dict->SetString("address", ipconfig.address); | 706 ipconfig_dict->SetString("address", ipconfig.address); |
725 ipconfig_dict->SetString("subnetAddress", ipconfig.netmask); | 707 ipconfig_dict->SetString("subnetAddress", ipconfig.netmask); |
726 ipconfig_dict->SetString("gateway", ipconfig.gateway); | 708 ipconfig_dict->SetString("gateway", ipconfig.gateway); |
727 ipconfig_dict->SetString("dns", ipconfig.name_servers); | 709 ipconfig_dict->SetString("dns", ipconfig.name_servers); |
728 if (ipconfig.type == chromeos::IPCONFIG_TYPE_DHCP) | 710 if (ipconfig.type == chromeos::IPCONFIG_TYPE_DHCP) |
729 dictionary.Set("ipconfigDHCP", ipconfig_dict.release()); | 711 dictionary.Set("ipconfigDHCP", ipconfig_dict.release()); |
730 else if (ipconfig.type == chromeos::IPCONFIG_TYPE_IPV4) | 712 else if (ipconfig.type == chromeos::IPCONFIG_TYPE_IPV4) |
731 dictionary.Set("ipconfigStatic", ipconfig_dict.release()); | 713 dictionary.Set("ipconfigStatic", ipconfig_dict.release()); |
732 } | 714 } |
733 | 715 |
734 chromeos::ConnectionType type = network->type(); | 716 chromeos::ConnectionType type = network->type(); |
735 dictionary.SetInteger("type", type); | 717 dictionary.SetInteger("type", type); |
736 dictionary.SetString("servicePath", network->service_path()); | 718 dictionary.SetString("servicePath", network->service_path()); |
737 dictionary.SetBoolean("connecting", network->connecting()); | 719 dictionary.SetBoolean("connecting", network->connecting()); |
738 dictionary.SetBoolean("connected", network->connected()); | 720 dictionary.SetBoolean("connected", network->connected()); |
739 dictionary.SetString("connectionState", network->GetStateString()); | 721 dictionary.SetString("connectionState", network->GetStateString()); |
740 | 722 |
741 // Determine if proxy is configurable. | 723 // Only show proxy for remembered networks. |
742 // First check proxy prefs. | 724 chromeos::NetworkProfileType network_profile = network->profile_type(); |
743 bool proxy_configurable = true; | 725 dictionary.SetBoolean("showProxy", network_profile != chromeos::PROFILE_NONE); |
744 std::string change_proxy_text; | |
745 if (web_ui_) { | |
746 const PrefService::Preference* proxy_pref = | |
747 Profile::FromWebUI(web_ui_)->GetPrefs()->FindPreference(prefs::kProxy); | |
748 if (proxy_pref && (!proxy_pref->IsUserModifiable() || | |
749 proxy_pref->HasUserSetting())) { | |
750 proxy_configurable = false; | |
751 // Provide reason that proxy is managed by admin or extension. | |
752 if (proxy_pref->IsManaged()) | |
753 change_proxy_text = "policyManagedProxyText"; | |
754 else if (proxy_pref->IsExtensionControlled()) | |
755 change_proxy_text = "extensionManagedProxyText"; | |
756 else | |
757 change_proxy_text = "unmodifiableProxyText"; | |
758 } | |
759 } | |
760 // Next check network type and use-shared-proxies. | |
761 chromeos::NetworkProfileType profile = network->profile_type(); | |
762 bool shared_network = type == chromeos::TYPE_ETHERNET || | |
763 profile == chromeos::PROFILE_SHARED; | |
764 if (proxy_configurable) { // Only check more if proxy is still configurable. | |
765 proxy_configurable = profile == chromeos::PROFILE_USER || | |
766 (shared_network && use_shared_proxies); | |
767 } | |
768 // If no reason has been set yet, provide hint to configure shared proxy. | |
769 if (change_proxy_text.empty() && shared_network && !use_shared_proxies) | |
770 change_proxy_text = "enableSharedProxiesHint"; | |
771 // Lastly, store proxy-configurable flag and, if available, text to display. | |
772 dictionary.SetBoolean("proxyConfigurable", proxy_configurable); | |
773 if (!change_proxy_text.empty()) | |
774 dictionary.SetString("changeProxyText", change_proxy_text); | |
775 | 726 |
776 // Hide the dhcp/static radio if not ethernet or wifi (or if not enabled) | 727 // Hide the dhcp/static radio if not ethernet or wifi (or if not enabled) |
777 bool staticIPConfig = CommandLine::ForCurrentProcess()->HasSwitch( | 728 bool staticIPConfig = CommandLine::ForCurrentProcess()->HasSwitch( |
778 switches::kEnableStaticIPConfig); | 729 switches::kEnableStaticIPConfig); |
779 dictionary.SetBoolean("showStaticIPConfig", staticIPConfig && | 730 dictionary.SetBoolean("showStaticIPConfig", staticIPConfig && |
780 (type == chromeos::TYPE_WIFI || type == chromeos::TYPE_ETHERNET)); | 731 (type == chromeos::TYPE_WIFI || type == chromeos::TYPE_ETHERNET)); |
781 | 732 |
782 if (network->profile_type() == chromeos::PROFILE_USER) { | 733 if (network_profile == chromeos::PROFILE_USER) { |
783 dictionary.SetBoolean("showPreferred", true); | 734 dictionary.SetBoolean("showPreferred", true); |
784 dictionary.SetBoolean("preferred", network->preferred()); | 735 dictionary.SetBoolean("preferred", network->preferred()); |
785 } else { | 736 } else { |
786 dictionary.SetBoolean("showPreferred", false); | 737 dictionary.SetBoolean("showPreferred", false); |
787 dictionary.SetBoolean("preferred", false); | 738 dictionary.SetBoolean("preferred", false); |
788 } | 739 } |
789 dictionary.SetBoolean("autoConnect", network->auto_connect()); | 740 dictionary.SetBoolean("autoConnect", network->auto_connect()); |
790 | 741 |
791 if (type == chromeos::TYPE_WIFI) { | 742 if (type == chromeos::TYPE_WIFI) { |
792 dictionary.SetBoolean("deviceConnected", cros_->wifi_connected()); | 743 dictionary.SetBoolean("deviceConnected", cros_->wifi_connected()); |
(...skipping 552 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1345 dictionary->Set("wirelessList", GetWirelessList()); | 1296 dictionary->Set("wirelessList", GetWirelessList()); |
1346 dictionary->Set("vpnList", GetVPNList()); | 1297 dictionary->Set("vpnList", GetVPNList()); |
1347 dictionary->Set("rememberedList", GetRememberedList()); | 1298 dictionary->Set("rememberedList", GetRememberedList()); |
1348 dictionary->SetBoolean("wifiAvailable", cros_->wifi_available()); | 1299 dictionary->SetBoolean("wifiAvailable", cros_->wifi_available()); |
1349 dictionary->SetBoolean("wifiBusy", cros_->wifi_busy()); | 1300 dictionary->SetBoolean("wifiBusy", cros_->wifi_busy()); |
1350 dictionary->SetBoolean("wifiEnabled", cros_->wifi_enabled()); | 1301 dictionary->SetBoolean("wifiEnabled", cros_->wifi_enabled()); |
1351 dictionary->SetBoolean("cellularAvailable", cros_->cellular_available()); | 1302 dictionary->SetBoolean("cellularAvailable", cros_->cellular_available()); |
1352 dictionary->SetBoolean("cellularBusy", cros_->cellular_busy()); | 1303 dictionary->SetBoolean("cellularBusy", cros_->cellular_busy()); |
1353 dictionary->SetBoolean("cellularEnabled", cros_->cellular_enabled()); | 1304 dictionary->SetBoolean("cellularEnabled", cros_->cellular_enabled()); |
1354 } | 1305 } |
OLD | NEW |