Commit 48f62a44 authored by csilv@chromium.org's avatar csilv@chromium.org

dom-ui options: Setup proxy settings UI accordingly if an Extension is managing proxies.

BUG=51376
TEST=Verify proxy settings UI matches proposal when proxy settings are managed by an extension.
Review URL: http://codereview.chromium.org/3132030

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@56940 0039d316-1c4b-4281-b951-d872f2087c98
parent 6d87d61d
......@@ -6069,6 +6069,12 @@ Keep your key file in a safe place. You will need it to create new versions of y
<message name="IDS_OPTIONS_PROXIES_LABEL" desc="The info label for the 'Proxy settings' button">
Set up a proxy to connect to the network.
</message>
<message name="IDS_OPTIONS_SYSTEM_PROXIES_LABEL" desc="The info label for the 'Proxy settings' button when managed by the system.">
<ph name="PRODUCT_NAME">$1<ex>Google Chrome</ex></ph> is using your computer's system proxy settings to connect to the network.
</message>
<message name="IDS_OPTIONS_EXTENSION_PROXIES_LABEL" desc="The info label for the 'Proxy settings' button when managed by an extension.">
Your network proxy settings are being managed by an extension.
</message>
<message name="IDS_OPTIONS_PROXIES_CONFIGURE_BUTTON" desc="The label of the 'Configure proxy settings' button">
Change proxy settings
</message>
......
......@@ -128,7 +128,7 @@ void AdvancedOptionsHandler::GetLocalizedValues(
void AdvancedOptionsHandler::Initialize() {
SetupDownloadLocationPath();
SetupAutoOpenFileTypesDisabledAttribute();
SetupProxySettingsDisabledAttribute();
SetupProxySettingsSection();
#if defined(OS_WIN)
SetupSSLConfigSettings();
#endif
......@@ -197,6 +197,9 @@ void AdvancedOptionsHandler::Observe(NotificationType type,
SetupDownloadLocationPath();
} else if (*pref_name == prefs::kDownloadExtensionsToOpen) {
SetupAutoOpenFileTypesDisabledAttribute();
} else {
// Assume that one of the proxy settings may have changed.
SetupProxySettingsSection();
}
}
}
......@@ -277,12 +280,29 @@ void AdvancedOptionsHandler::SetupAutoOpenFileTypesDisabledAttribute() {
L"options.AdvancedOptions.SetAutoOpenFileTypesDisabledAttribute", value);
}
void AdvancedOptionsHandler::SetupProxySettingsDisabledAttribute() {
// Set the enabled state for the proxy settings button.
// We enable the button if proxy settings are not managed by a sysadmin.
FundamentalValue value(proxy_prefs_->IsManaged());
void AdvancedOptionsHandler::SetupProxySettingsSection() {
// Disable the button if proxy settings are managed by a sysadmin or
// overridden by an extension.
PrefService* pref_service = dom_ui_->GetProfile()->GetPrefs();
const PrefService::Preference* proxy_server =
pref_service->FindPreference(prefs::kProxyServer);
DCHECK(proxy_server);
FundamentalValue disabled(proxy_prefs_->IsManaged() ||
proxy_server->IsExtensionControlled());
// Get the appropriate info string to describe the button.
string16 label_str;
if (proxy_server->IsExtensionControlled()) {
label_str = l10n_util::GetStringUTF16(IDS_OPTIONS_EXTENSION_PROXIES_LABEL);
} else {
label_str = l10n_util::GetStringFUTF16(IDS_OPTIONS_SYSTEM_PROXIES_LABEL,
l10n_util::GetStringUTF16(IDS_PRODUCT_NAME));
}
StringValue label(label_str);
dom_ui_->CallJavascriptFunction(
L"options.AdvancedOptions.SetProxySettingsDisabledAttribute", value);
L"options.AdvancedOptions.SetupProxySettingsSection", disabled, label);
}
#if defined(OS_WIN)
......
......@@ -75,8 +75,8 @@ class AdvancedOptionsHandler
// Setup the enabled state of the reset button.
void SetupAutoOpenFileTypesDisabledAttribute();
// Setup the enabled state of the proxy settings button.
void SetupProxySettingsDisabledAttribute();
// Setup the proxy settings section UI.
void SetupProxySettingsSection();
#if defined(OS_WIN)
// Setup the checked state SSL related checkboxes.
......
......@@ -35,7 +35,7 @@
<section>
<h3 i18n-content="advancedSectionTitleNetwork"></h3>
<div>
<div i18n-content="proxiesLabel"></div>
<div id="proxiesLabel"></div>
<button id="proxiesConfigureButton"
i18n-content="proxiesConfigureButton"></button>
</div>
......
......@@ -85,19 +85,20 @@ var OptionsPage = options.OptionsPage;
//
// Set the download path.
AdvancedOptions.SetDownloadLocationPath = function (path) {
AdvancedOptions.SetDownloadLocationPath = function(path) {
if (!cr.isChromeOS)
$('downloadLocationPath').value = path;
};
// Set the enabled state for the autoOpenFileTypesResetToDefault button.
AdvancedOptions.SetAutoOpenFileTypesDisabledAttribute = function (disabled) {
AdvancedOptions.SetAutoOpenFileTypesDisabledAttribute = function(disabled) {
$('autoOpenFileTypesResetToDefault').disabled = disabled;
};
// Set the enabled state for the proxy settings button.
AdvancedOptions.SetProxySettingsDisabledAttribute = function (disabled) {
AdvancedOptions.SetupProxySettingsSection = function(disabled, label) {
$('proxiesConfigureButton').disabled = disabled;
$('proxiesLabel').textContent = label;
};
// Set the checked state for the sslCheckRevocation checkbox.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment