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