diff options
author | kuan@chromium.org <kuan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-08-22 16:21:15 +0000 |
---|---|---|
committer | kuan@chromium.org <kuan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-08-22 16:21:15 +0000 |
commit | 805b852f88b709ff63825bcc90c74a58f46f4c8d (patch) | |
tree | d75cceedf42f61a2b69d7d1f8b9787cfcc5977dd | |
parent | e021a4f0f69430178bcda21c370692e559918d6b (diff) | |
download | chromium_src-805b852f88b709ff63825bcc90c74a58f46f4c8d.zip chromium_src-805b852f88b709ff63825bcc90c74a58f46f4c8d.tar.gz chromium_src-805b852f88b709ff63825bcc90c74a58f46f4c8d.tar.bz2 |
chromeos proxy ui enhancements
- implement checking of policy/extension-managed proxy in ui and
display reason when network proxy is not configurable.
- update instructions on how to disable proxy server when it's is not reachable
- update strings for proxy-related settings
BUG=chromium-os:18010,chromium-os:8513,chromium-os:18108
TEST=verify per bug reports.
Review URL: http://codereview.chromium.org/7644001
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@97654 0039d316-1c4b-4281-b951-d872f2087c98
8 files changed, 154 insertions, 41 deletions
diff --git a/chrome/app/generated_resources.grd b/chrome/app/generated_resources.grd index 46f28ff..437f565 100644 --- a/chrome/app/generated_resources.grd +++ b/chrome/app/generated_resources.grd @@ -6428,8 +6428,26 @@ Keep your key file in a safe place. You will need it to create new versions of y and deselect any proxies that have been selected. </message> </if> - <if expr="is_posix and not is_macosx"> - <message name="IDS_ERRORPAGES_SUGGESTION_PROXY_DISABLE_PLATFORM" desc="Linux and ChromeOS instructions for disabling use of a proxy server."> + <if expr="pp_ifdef('chromeos')"> + <message name="IDS_ERRORPAGES_SUGGESTION_PROXY_DISABLE_PLATFORM" desc="ChromeOS instructions for disabling use of a proxy server."> + Go to + <ph name="BEGIN_BOLD"><strong></ph> + the wrench menu > + <ph name="SETTINGS_TITLE"><span jscontent="settingsTitle"></span><ex>Settings</ex></ph> + > + <ph name="INTERNET_TITLE"><span jscontent="internetTitle"></span><ex>Internet</ex></ph> + > + <ph name="OPTIONS_BUTTON"><span jscontent="optionsButton"></span><ex>Options...</ex></ph> + of connected network > + <ph name="NETWORK_TAB"><span jscontent="networkTab"></span><ex>Network</ex></ph> + tab > + <ph name="PROXY_BUTTON"><span jscontent="proxyButton"></span><ex>Change proxy settings...</ex></ph> + <ph name="END_BOLD"></strong></ph> + and make sure your configuration is set to "Direct". + </message> + </if> + <if expr="not pp_ifdef('chromeos') and is_posix and not is_macosx"> + <message name="IDS_ERRORPAGES_SUGGESTION_PROXY_DISABLE_PLATFORM" desc="Linux instructions for disabling use of a proxy server."> Go to <ph name="BEGIN_BOLD"><strong></ph> the wrench menu > @@ -10895,8 +10913,8 @@ Keep your key file in a safe place. You will need it to create new versions of y <message name="IDS_OPTIONS_SETTINGS_ADD_VPN" desc="In the settings tab, the text on the button to add a private network."> Add private network </message> - <message name="IDS_OPTIONS_SETTINGS_USE_SHARED_PROXIES" desc="In the settings tab, the text next to the checkbox for using shared proxies."> - Use shared proxies + <message name="IDS_OPTIONS_SETTINGS_USE_SHARED_PROXIES" desc="In the settings tab, the text next to the checkbox for allowing proxy settings for shared networks."> + Allow proxies for shared networks </message> <message name="IDS_OPTIONS_SETTINGS_ENABLE_DATA_ROAMING" desc="In the settings tab, the text next to the checkbox for data roaming."> Allow mobile data roaming @@ -11139,7 +11157,16 @@ Keep your key file in a safe place. You will need it to create new versions of y Change proxy settings... </message> <message name="IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_ENABLE_SHARED_PROXIES_HINT" desc="In settings Internet options, when proxy can't be changed, the hint for user to do so by enabling the setting for IDS_OPTIONS_SETTINGS_USE_SHARED_PROXIES."> - To change proxy settings, enable "Use shared proxies" setting. + To change proxy settings, enable "<ph name="USE_SHARED_PROXIES">$1<ex>Allow proxies for shared networks</ex></ph>" setting. + </message> + <message name="IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_POLICY_MANAGED_PROXY_TEXT" desc="In settings Internet options, the text to display when proxy is policy-managed and user won't be able to change."> + Proxy settings have been disabled by your administrator. + </message> + <message name="IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_EXTENSION_MANAGED_PROXY_TEXT" desc="In settings Internet options, the text to display when proxy is extension-managed and user won't be able to change."> + Proxy settings are being managed by an extension. + </message> + <message name="IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_UNMODIFIABLE_PROXY_TEXT" desc="In settings Internet options, the text to display when proxy is not modifiable by user."> + Proxy settings cannot be modified by user. </message> <message name="IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_HARDWARE_ADDRESS" desc="In settings Internet options, the label hardware address."> Hardware address: diff --git a/chrome/browser/chromeos/proxy_cros_settings_provider.cc b/chrome/browser/chromeos/proxy_cros_settings_provider.cc index 2d03a0ed..59a2394 100644 --- a/chrome/browser/chromeos/proxy_cros_settings_provider.cc +++ b/chrome/browser/chromeos/proxy_cros_settings_provider.cc @@ -4,12 +4,10 @@ #include "chrome/browser/chromeos/proxy_cros_settings_provider.h" -#include "base/command_line.h" #include "base/string_util.h" #include "chrome/browser/browser_process.h" #include "chrome/browser/chromeos/cros_settings.h" #include "chrome/browser/ui/browser_list.h" -#include "chrome/common/chrome_switches.h" namespace chromeos { diff --git a/chrome/browser/chromeos/status/network_menu.cc b/chrome/browser/chromeos/status/network_menu.cc index 830e24a..7aeb2db 100644 --- a/chrome/browser/chromeos/status/network_menu.cc +++ b/chrome/browser/chromeos/status/network_menu.cc @@ -17,11 +17,14 @@ #include "chrome/browser/chromeos/sim_dialog_delegate.h" #include "chrome/browser/chromeos/status/network_menu_icon.h" #include "chrome/browser/defaults.h" +#include "chrome/browser/prefs/pref_service.h" +#include "chrome/browser/profiles/profile_manager.h" #include "chrome/browser/ui/browser.h" #include "chrome/browser/ui/browser_list.h" #include "chrome/browser/ui/views/window.h" #include "chrome/common/url_constants.h" #include "chrome/common/chrome_switches.h" +#include "chrome/common/pref_names.h" #include "content/browser/browser_thread.h" #include "grit/generated_resources.h" #include "grit/theme_resources.h" @@ -937,20 +940,35 @@ void MoreMenuModel::InitMenuItems( bool oobe = !should_open_button_options; // we don't show options for OOBE. bool connected = cros->Connected(); // always call for test expectations. if (!oobe) { - string16 label; - bool add_item = true; + int flags = FLAG_OPTIONS; + int message_id = -1; if (is_browser_mode) { - label = l10n_util::GetStringUTF16( - IDS_STATUSBAR_NETWORK_OPEN_OPTIONS_DIALOG); + message_id = IDS_STATUSBAR_NETWORK_OPEN_OPTIONS_DIALOG; } else if (connected) { - label = l10n_util::GetStringUTF16( - IDS_STATUSBAR_NETWORK_OPEN_PROXY_SETTINGS_DIALOG); - } else { - add_item = false; + const PrefService::Preference* proxy_pref = + ProfileManager::GetDefaultProfile()->GetPrefs()->FindPreference( + prefs::kProxy); + if (proxy_pref && (!proxy_pref->IsUserModifiable() || + proxy_pref->HasUserSetting())) { + flags |= FLAG_DISABLED; + if (proxy_pref->IsManaged()) { + message_id = + IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_POLICY_MANAGED_PROXY_TEXT; + } else if (proxy_pref->IsExtensionControlled()) { + message_id = + IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_EXTENSION_MANAGED_PROXY_TEXT; + } else { + message_id = + IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_UNMODIFIABLE_PROXY_TEXT; + } + } else { + message_id = IDS_STATUSBAR_NETWORK_OPEN_PROXY_SETTINGS_DIALOG; + } } - if (add_item) { - link_items.push_back(MenuItem(ui::MenuModel::TYPE_COMMAND, label, - SkBitmap(), std::string(), FLAG_OPTIONS)); + if (message_id != -1) { + link_items.push_back(MenuItem(ui::MenuModel::TYPE_COMMAND, + l10n_util::GetStringUTF16(message_id), + SkBitmap(), std::string(), flags)); } } diff --git a/chrome/browser/resources/options/chromeos/internet_detail.html b/chrome/browser/resources/options/chromeos/internet_detail.html index f98fb04..4211549 100644 --- a/chrome/browser/resources/options/chromeos/internet_detail.html +++ b/chrome/browser/resources/options/chromeos/internet_detail.html @@ -313,9 +313,7 @@ <button id="change-proxy-button" i18n-content="changeProxyButton"> </button> </div> - <div id="enable-shared-proxies-hint" - i18n-content="enableSharedProxiesHint" hidden> - </div> + <div id="change-proxy-text" hidden></div> </section> </div> <div id="security-tab" diff --git a/chrome/browser/resources/options/chromeos/internet_options.js b/chrome/browser/resources/options/chromeos/internet_options.js index df6ea25..209fe61 100644 --- a/chrome/browser/resources/options/chromeos/internet_options.js +++ b/chrome/browser/resources/options/chromeos/internet_options.js @@ -450,11 +450,18 @@ cr.define('options', function() { // Hide change-proxy-button if proxy is not configurable. $('change-proxy-button').hidden = !data.proxyConfigurable; - // Hide enable-shared-proxies-hint if proxy configuration cannot be enabled. - $('enable-shared-proxies-hint').hidden = !data.showSharedProxiesHint; - // Hide change-proxy-section if both button and hint are hidden. + // If necessary, set text for change-proxy-text and show it. + var changeProxyText = $('change-proxy-text'); + if (data.changeProxyText != '') { + changeProxyText.textContent = + localStrings.getString(data.changeProxyText); + changeProxyText.hidden = false; + } else { + changeProxyText.hidden = true; + } + // Hide change-proxy-section if button and text are hidden. $('change-proxy-section').hidden = !data.proxyConfigurable && - !data.showSharedProxiesHint; + changeProxyText.hidden; var ipConfigList = $('ipConfigList'); ipConfigList.disabled = $('ipTypeDHCP').checked || !data.showStaticIPConfig; diff --git a/chrome/browser/ui/webui/options/chromeos/internet_options_handler.cc b/chrome/browser/ui/webui/options/chromeos/internet_options_handler.cc index 3a2fdb7..40d7e15 100644 --- a/chrome/browser/ui/webui/options/chromeos/internet_options_handler.cc +++ b/chrome/browser/ui/webui/options/chromeos/internet_options_handler.cc @@ -118,8 +118,18 @@ void InternetOptionsHandler::GetLocalizedValues( l10n_util::GetStringUTF16( IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_CHANGE_PROXY_BUTTON)); localized_strings->SetString("enableSharedProxiesHint", + l10n_util::GetStringFUTF16( + IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_ENABLE_SHARED_PROXIES_HINT, + l10n_util::GetStringUTF16(IDS_OPTIONS_SETTINGS_USE_SHARED_PROXIES))); + localized_strings->SetString("policyManagedProxyText", + l10n_util::GetStringUTF16( + IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_POLICY_MANAGED_PROXY_TEXT)); + localized_strings->SetString("extensionManagedProxyText", l10n_util::GetStringUTF16( - IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_ENABLE_SHARED_PROXIES_HINT)); + IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_EXTENSION_MANAGED_PROXY_TEXT)); + localized_strings->SetString("unmodifiableProxyText", + l10n_util::GetStringUTF16( + IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_UNMODIFIABLE_PROXY_TEXT)); localized_strings->SetString("wifiNetworkTabLabel", l10n_util::GetStringUTF16( @@ -351,7 +361,7 @@ void InternetOptionsHandler::GetLocalizedValues( chromeos::UserCrosSettingsProvider::cached_owner())); FillNetworkInfo(localized_strings); - } +} void InternetOptionsHandler::Initialize() { cros_->RequestNetworkScan(); @@ -690,15 +700,41 @@ void InternetOptionsHandler::PopulateDictionaryDetails( dictionary.SetBoolean("connecting", network->connecting()); dictionary.SetBoolean("connected", network->connected()); dictionary.SetString("connectionState", network->GetStateString()); - bool remembered = (network->profile_type() != chromeos::PROFILE_NONE); - bool proxy_configurable = - (remembered && (network->profile_type() == chromeos::PROFILE_USER || - use_shared_proxies)) || - (type == chromeos::TYPE_ETHERNET && use_shared_proxies); + + // Determine if proxy is configurable. + // First check proxy prefs. + bool proxy_configurable = true; + std::string change_proxy_text; + if (web_ui_) { + const PrefService::Preference* proxy_pref = + Profile::FromWebUI(web_ui_)->GetPrefs()->FindPreference(prefs::kProxy); + if (proxy_pref && (!proxy_pref->IsUserModifiable() || + proxy_pref->HasUserSetting())) { + proxy_configurable = false; + // Provide reason that proxy is managed by admin or extension. + if (proxy_pref->IsManaged()) + change_proxy_text = "policyManagedProxyText"; + else if (proxy_pref->IsExtensionControlled()) + change_proxy_text = "extensionManagedProxyText"; + else + change_proxy_text = "unmodifiableProxyText"; + } + } + // Next check network type and use-shared-proxies. + chromeos::NetworkProfileType profile = network->profile_type(); + bool shared_network = type == chromeos::TYPE_ETHERNET || + profile == chromeos::PROFILE_SHARED; + if (proxy_configurable) { // Only check more if proxy is still configurable. + proxy_configurable = profile == chromeos::PROFILE_USER || + (shared_network && use_shared_proxies); + } + // If no reason has been set yet, provide hint to configure shared proxy. + if (change_proxy_text.empty() && shared_network && !use_shared_proxies) + change_proxy_text = "enableSharedProxiesHint"; + // Lastly, store proxy-configurable flag and, if available, text to display. dictionary.SetBoolean("proxyConfigurable", proxy_configurable); - dictionary.SetBoolean("showSharedProxiesHint", - !proxy_configurable && !use_shared_proxies && - (remembered || type == chromeos::TYPE_ETHERNET)); + if (!change_proxy_text.empty()) + dictionary.SetString("changeProxyText", change_proxy_text); // Hide the dhcp/static radio if not ethernet or wifi (or if not enabled) bool staticIPConfig = CommandLine::ForCurrentProcess()->HasSwitch( diff --git a/chrome/browser/ui/webui/options/core_options_handler.cc b/chrome/browser/ui/webui/options/core_options_handler.cc index b0853c4..53cd3f4 100644 --- a/chrome/browser/ui/webui/options/core_options_handler.cc +++ b/chrome/browser/ui/webui/options/core_options_handler.cc @@ -29,15 +29,26 @@ namespace { -DictionaryValue* CreateValueForPref(const PrefService::Preference* pref) { +DictionaryValue* CreateValueForPref(const PrefService* pref_service, + const PrefService::Preference* pref) { DictionaryValue* dict = new DictionaryValue; dict->Set("value", pref->GetValue()->DeepCopy()); - if (pref->IsManaged()) { + const PrefService::Preference* controlling_pref = pref; +#if defined(OS_CHROMEOS) + // For use-shared-proxies pref, the proxy pref determines if the former is + // modifiable or managed by policy/extension. + if (pref->name() == prefs::kUseSharedProxies) { + controlling_pref = pref_service->FindPreference(prefs::kProxy); + if (!controlling_pref) + return dict; + } +#endif // defined(OS_CHROMEOS) + if (controlling_pref->IsManaged()) { dict->SetString("controlledBy", "policy"); - } else if (pref->IsExtensionControlled()) { + } else if (controlling_pref->IsExtensionControlled()) { dict->SetString("controlledBy", "extension"); } - dict->SetBoolean("disabled", !pref->IsUserModifiable()); + dict->SetBoolean("disabled", !controlling_pref->IsUserModifiable()); return dict; } @@ -159,7 +170,7 @@ Value* CoreOptionsHandler::FetchPref(const std::string& pref_name) { if (!pref) return Value::CreateNullValue(); - return CreateValueForPref(pref); + return CreateValueForPref(pref_service, pref); } void CoreOptionsHandler::ObservePref(const std::string& pref_name) { @@ -392,7 +403,7 @@ void CoreOptionsHandler::NotifyPrefChanged(const std::string* pref_name) { ListValue result_value; result_value.Append(Value::CreateStringValue(pref_name->c_str())); - result_value.Append(CreateValueForPref(pref)); + result_value.Append(CreateValueForPref(pref_service, pref)); web_ui_->CallJavascriptFunction(WideToASCII(callback_function), result_value); diff --git a/chrome/renderer/localized_error.cc b/chrome/renderer/localized_error.cc index 65d89bd..8d14b02 100644 --- a/chrome/renderer/localized_error.cc +++ b/chrome/renderer/localized_error.cc @@ -542,13 +542,31 @@ void LocalizedError::GetStrings(const WebKit::WebURLError& error, } if (options.suggestions & SUGGEST_PROXY_CONFIG) { +#if defined(OS_CHROMEOS) + DictionaryValue* suggest_proxy_config = new DictionaryValue(); +#else DictionaryValue* suggest_proxy_config = GetStandardMenuItemsText(); +#endif // defined(OS_CHROMEOS) suggest_proxy_config->SetString("msg", l10n_util::GetStringFUTF16(IDS_ERRORPAGES_SUGGESTION_PROXY_CONFIG, l10n_util::GetStringUTF16( IDS_ERRORPAGES_SUGGESTION_PROXY_DISABLE_PLATFORM))); +#if defined(OS_CHROMEOS) + suggest_proxy_config->SetString("settingsTitle", + l10n_util::GetStringUTF16(IDS_SETTINGS_TITLE)); + suggest_proxy_config->SetString("internetTitle", + l10n_util::GetStringUTF16(IDS_OPTIONS_INTERNET_TAB_LABEL)); + suggest_proxy_config->SetString("optionsButton", + l10n_util::GetStringUTF16(IDS_OPTIONS_SETTINGS_OPTIONS)); + suggest_proxy_config->SetString("networkTab", + l10n_util::GetStringUTF16(IDS_OPTIONS_SETTINGS_INTERNET_TAB_NETWORK)); + suggest_proxy_config->SetString("proxyButton", + l10n_util::GetStringUTF16( + IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_CHANGE_PROXY_BUTTON)); +#else suggest_proxy_config->SetString("proxyTitle", l10n_util::GetStringUTF16(IDS_OPTIONS_PROXIES_CONFIGURE_BUTTON)); +#endif // defined(OS_CHROMEOS) error_strings->Set("suggestionsProxyConfig", suggest_proxy_config); } |