summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbauerb@chromium.org <bauerb@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-04-18 15:02:16 +0000
committerbauerb@chromium.org <bauerb@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-04-18 15:02:16 +0000
commit90428e0eab55a00e73d0aa7d1da60f07ecdb972b (patch)
tree97fbd9091d69d5159ef0b9248aaa5cca4d62608b
parent60b802c27e555fb85e3f14c90d1887c9daaa300c (diff)
downloadchromium_src-90428e0eab55a00e73d0aa7d1da60f07ecdb972b.zip
chromium_src-90428e0eab55a00e73d0aa7d1da60f07ecdb972b.tar.gz
chromium_src-90428e0eab55a00e73d0aa7d1da60f07ecdb972b.tar.bz2
Clean up managed user settings dialogs:
* Remove options which won't be configurable * Allow empty passphrases * Use WebUI stylesheet in passphrase dialog * JS style cleanup. BUG=231909 Review URL: https://chromiumcodereview.appspot.com/14325003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@194922 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/app/generated_resources.grd4
-rw-r--r--chrome/browser/resources/managed_user_passphrase_dialog.css15
-rw-r--r--chrome/browser/resources/managed_user_passphrase_dialog.html11
-rw-r--r--chrome/browser/resources/options/managed_user_exceptions_area.js6
-rw-r--r--chrome/browser/resources/options/managed_user_set_passphrase.html20
-rw-r--r--chrome/browser/resources/options/managed_user_set_passphrase.js9
-rw-r--r--chrome/browser/resources/options/managed_user_settings.html57
-rw-r--r--chrome/browser/resources/options/managed_user_settings.js134
-rw-r--r--chrome/browser/ui/webui/managed_user_passphrase_dialog.cc2
-rw-r--r--chrome/browser/ui/webui/options/managed_user_passphrase_handler.cc22
-rw-r--r--chrome/browser/ui/webui/options/managed_user_passphrase_handler.h8
-rw-r--r--chrome/browser/ui/webui/options/managed_user_set_passphrase_browsertest.js2
-rw-r--r--chrome/browser/ui/webui/options/managed_user_settings_browsertest.js20
-rw-r--r--chrome/browser/ui/webui/options/managed_user_settings_handler.cc45
-rw-r--r--chrome/browser/ui/webui/options/managed_user_settings_handler.h4
15 files changed, 112 insertions, 247 deletions
diff --git a/chrome/app/generated_resources.grd b/chrome/app/generated_resources.grd
index 01bc04d..1982829 100644
--- a/chrome/app/generated_resources.grd
+++ b/chrome/app/generated_resources.grd
@@ -8175,13 +8175,13 @@ The following plug-in is unresponsive: <ph name="PLUGIN_NAME">$1
Require a passphrase to modify the settings for this managed user
</message>
<message name="IDS_SET_PASSPHRASE_BUTTON" desc="A button in the Managed User Settings dialog to set the passphrase to access other profiles.">
- Set passphrase
+ Change passphrase...
</message>
<message name="IDS_SET_PASSPHRASE_TITLE" desc="A title for the Managed User Set Passphrase dialog.">
Set a passphrase
</message>
<message name="IDS_SET_PASSPHRASE_INSTRUCTIONS" desc="Text describing the set passphrase dialog.">
- You'll have to enter the passphrase to change this user's settings later
+ Enter a passphrase to change this user's settings later.
</message>
<message name="IDS_ENTER_PASSPHRASE_LABEL" desc="A label for entering a passphrase to save.">
Enter a passphrase:
diff --git a/chrome/browser/resources/managed_user_passphrase_dialog.css b/chrome/browser/resources/managed_user_passphrase_dialog.css
index 64922c4..53356d8 100644
--- a/chrome/browser/resources/managed_user_passphrase_dialog.css
+++ b/chrome/browser/resources/managed_user_passphrase_dialog.css
@@ -4,6 +4,7 @@
#managed-mode-passphrase-page {
min-width: 350px;
+ padding: 5px 15px;
}
#managed-user-logo {
@@ -12,10 +13,12 @@
width: 65px;
}
-#instructions,
-#entry,
-#incorrect-passphrase-warning {
- padding: 5px 15px;
+#entry {
+ margin: 15px 0;
+}
+
+#passphrase-entry {
+ width: 100%;
}
#buttons {
@@ -26,10 +29,6 @@ html[dir=rtl] #buttons {
float: left;
}
-#buttons {
- padding: 15px 15px;
-}
-
#incorrect-passphrase-warning {
color: red;
font-weight: bold;
diff --git a/chrome/browser/resources/managed_user_passphrase_dialog.html b/chrome/browser/resources/managed_user_passphrase_dialog.html
index 7584823..d5075ac 100644
--- a/chrome/browser/resources/managed_user_passphrase_dialog.html
+++ b/chrome/browser/resources/managed_user_passphrase_dialog.html
@@ -4,6 +4,7 @@
found in the LICENSE file. -->
<html i18n-values="dir:textdirection">
<head>
+ <link rel="stylesheet" href="chrome://resources/css/chrome_shared.css">
<link rel="stylesheet" href="managed_user_passphrase_dialog.css">
<script src="chrome://resources/js/load_time_data.js"></script>
<script src="chrome://resources/js/util.js"></script>
@@ -18,12 +19,10 @@
<h1 i18n-content="managedModePassphrasePage"></h1>
<div class="content-area">
<div id="instructions">
- <label>
- <span i18n-content="passphraseInstruction"></span>
- </label>
+ <span i18n-content="passphraseInstruction"></span>
</div>
<div id="entry">
- <input id="passphrase-entry" size="50" type="password" required>
+ <input id="passphrase-entry" type="password" required>
</div>
<div id="buttons">
<button id="cancel-passphrase-button"
@@ -34,9 +33,7 @@
</button>
</div>
<div id="incorrect-passphrase-warning" hidden>
- <label>
- <span i18n-content="incorrectPassphraseWarning"></span>
- </label>
+ <span i18n-content="incorrectPassphraseWarning"></span>
</div>
</div>
</div>
diff --git a/chrome/browser/resources/options/managed_user_exceptions_area.js b/chrome/browser/resources/options/managed_user_exceptions_area.js
index b9be5a7..b6a9e15 100644
--- a/chrome/browser/resources/options/managed_user_exceptions_area.js
+++ b/chrome/browser/resources/options/managed_user_exceptions_area.js
@@ -21,7 +21,6 @@ cr.define('options.managedUserSettings', function() {
*/
function ExceptionsListItem(exception) {
var el = cr.doc.createElement('div');
- el.contentType = 'manual-exceptions';
el.dataItem = exception;
el.__proto__ = ExceptionsListItem.prototype;
el.decorate();
@@ -441,7 +440,7 @@ cr.define('options.managedUserSettings', function() {
*/
function ManagedUserSettingsExceptionsArea() {
OptionsPage.call(this, 'manualExceptions',
- loadTimeData.getString('managedUserSettingsPageTabTitle'),
+ loadTimeData.getString('manualExceptionsTabTitle'),
'managed-user-exceptions-area');
}
@@ -464,8 +463,7 @@ cr.define('options.managedUserSettings', function() {
/** @override */
canShowPage: function() {
- return ManagedUserSettings.getInstance().authenticationState ==
- options.ManagedUserAuthentication.AUTHENTICATED;
+ return ManagedUserSettings.getInstance().isAuthenticated;
},
};
diff --git a/chrome/browser/resources/options/managed_user_set_passphrase.html b/chrome/browser/resources/options/managed_user_set_passphrase.html
index 2054dfd..65003c3 100644
--- a/chrome/browser/resources/options/managed_user_set_passphrase.html
+++ b/chrome/browser/resources/options/managed_user_set_passphrase.html
@@ -8,22 +8,22 @@
<div i18n-content="setPassphraseInstructions"></div>
<div class="managed-user-passphrase-container">
<input id="managed-user-passphrase" type="password" align="center"
- i18n-values=".placeholder:enterPassphrase" required>
+ i18n-values=".placeholder:enterPassphrase">
<div id="passphrase-mismatch" i18n-content="passphraseMismatch" hidden>
</div>
</div>
<div class="managed-user-passphrase-container">
<input id="passphrase-confirm" class="equal_passphrases" type="password"
- i18n-values=".placeholder:confirmPassphrase" required>
+ i18n-values=".placeholder:confirmPassphrase">
</div>
- <div class="action-area">
- <div class="button-strip">
- <button id="cancel-passphrase" i18n-content="cancel" type="submit">
- </button>
- <button id="save-passphrase" i18n-content="savePassphrase" type="submit"
- disabled>
- </button>
- </div>
+ </div>
+ <div class="action-area">
+ <div class="button-strip">
+ <button id="cancel-passphrase" i18n-content="cancel" type="submit">
+ </button>
+ <button id="save-passphrase" i18n-content="savePassphrase" type="submit"
+ disabled>
+ </button>
</div>
</div>
</div>
diff --git a/chrome/browser/resources/options/managed_user_set_passphrase.js b/chrome/browser/resources/options/managed_user_set_passphrase.js
index bfb8502..69c7947 100644
--- a/chrome/browser/resources/options/managed_user_set_passphrase.js
+++ b/chrome/browser/resources/options/managed_user_set_passphrase.js
@@ -31,7 +31,7 @@ cr.define('options', function() {
$('managed-user-passphrase').oninput = this.updateDisplay_;
$('passphrase-confirm').oninput = this.updateDisplay_;
- $('save-passphrase').onclick = this.setPassphrase_.bind(this);
+ $('save-passphrase').onclick = this.savePassphrase_.bind(this);
$('managed-user-passphrase').onkeypress = function(event) {
// Check if the user pressed enter and advance to the
@@ -49,7 +49,7 @@ cr.define('options', function() {
}
// Check if the user pressed enter.
if (event.keyCode == 13)
- self.setPassphrase_(event);
+ self.savePassphrase_(event);
};
$('cancel-passphrase').onclick = function(event) {
@@ -72,15 +72,14 @@ cr.define('options', function() {
* Sets the passphrase and closes the overlay.
* @param {Event} event The event that triggered the call to this function.
*/
- setPassphrase_: function(event) {
+ savePassphrase_: function(event) {
chrome.send('setPassphrase', [$('managed-user-passphrase').value]);
this.closePage();
},
/** @override */
canShowPage: function() {
- return ManagedUserSettings.getInstance().authenticationState ==
- options.ManagedUserAuthentication.AUTHENTICATED;
+ return ManagedUserSettings.getInstance().isAuthenticated;
},
/** @override */
diff --git a/chrome/browser/resources/options/managed_user_settings.html b/chrome/browser/resources/options/managed_user_settings.html
index ea8459d..7c06515 100644
--- a/chrome/browser/resources/options/managed_user_settings.html
+++ b/chrome/browser/resources/options/managed_user_settings.html
@@ -10,7 +10,6 @@
<button id="get-content-packs-button" i18n-content="getContentPacks"
disabled>
</button>
- </button>
<button id="manage-exceptions-button" i18n-content="manageExceptions">
</button>
</div>
@@ -22,27 +21,24 @@
<label>
<input type="radio" name="contentpacks" value="0"
id="contentpacks-allow"
- pref="profile.managed.default_filtering_behavior" dialog-pref>
- <span for="contentpacks-allow"
- i18n-content="outsideContentPacksAllow"></span>
+ pref="profile.managed.default_filtering_behavior">
+ <span i18n-content="outsideContentPacksAllow"></span>
</label>
</div>
<div class="radio">
<label>
<input type="radio" name="contentpacks" value="1"
id="contentpacks-warn"
- pref="profile.managed.default_filtering_behavior" dialog-pref>
- <span for="contentpacks-warn"
- i18n-content="outsideContentPacksWarn"></span>
+ pref="profile.managed.default_filtering_behavior">
+ <span i18n-content="outsideContentPacksWarn"></span>
</label>
</div>
<div class="radio">
<label>
<input type="radio" name="contentpacks" value="2"
id="contentpacks-block"
- pref="profile.managed.default_filtering_behavior" dialog-pref>
- <span for="contentpacks-block"
- i18n-content="outsideContentPacksBlock"></span>
+ pref="profile.managed.default_filtering_behavior">
+ <span i18n-content="outsideContentPacksBlock"></span>
</label>
</div>
</section>
@@ -52,39 +48,13 @@
<div class="checkbox">
<label>
<input type="checkbox" id="safe-search-checkbox"
- pref="settings.force_safesearch" dialog-pref>
- <span for="safe-search-checkbox"
- i18n-content="enableSafeSearch"></span>
- </label>
- </div>
- <div class="checkbox">
- <label>
- <input id="allow-signin-checkbox" type="checkbox"
- pref="signin.allowed" dialog-pref>
- <span for="allow-signin-checkbox"
- i18n-content="allowSignIn"></span>
+ pref="settings.force_safesearch">
+ <span i18n-content="enableSafeSearch"></span>
</label>
</div>
- <div class="checkbox">
- <label>
- <input id="disable-history-deletion-checkbox" type="checkbox"
- disabled>
- <span for="disable-history-deletion-checkbox"
- i18n-content="disableHistoryDeletion"></span>
- </label>
+ <div class="settings-row">
+ <button id="set-passphrase" i18n-content="setPassphrase"></button>
</div>
- <if expr="not pp_ifdef('chromeos')">
- <div class="checkbox">
- <label>
- <input id="use-passphrase-checkbox" type="checkbox">
- <span for="use-passphrase-checkbox"
- i18n-content="usePassphrase"></span>
- </label>
- <button id="set-passphrase" class="link-button"
- i18n-content="setPassphrase">
- </button>
- </div>
- </if>
</section>
</div>
<div class="action-area">
@@ -94,11 +64,8 @@
</if>
<div id="spacer"></div>
<div class="button-strip">
- <button id="managed-user-settings-cancel" type="submit"
- i18n-content="cancel">
- </button>
- <button id="managed-user-settings-confirm" type="submit"
- i18n-content="ok">
+ <button id="managed-user-settings-done" type="submit"
+ i18n-content="done">
</button>
</div>
</div>
diff --git a/chrome/browser/resources/options/managed_user_settings.js b/chrome/browser/resources/options/managed_user_settings.js
index 8fe468f..23ecb28 100644
--- a/chrome/browser/resources/options/managed_user_settings.js
+++ b/chrome/browser/resources/options/managed_user_settings.js
@@ -6,7 +6,6 @@ if (loadTimeData.getBoolean('managedUsersEnabled')) {
cr.define('options', function() {
/** @const */ var OptionsPage = options.OptionsPage;
- /** @const */ var SettingsDialog = options.SettingsDialog;
//////////////////////////////////////////////////////////////////////////////
// ManagedUserSettings class:
@@ -17,13 +16,11 @@ cr.define('options', function() {
* @class
*/
function ManagedUserSettings() {
- SettingsDialog.call(
+ OptionsPage.call(
this,
'manageduser',
loadTimeData.getString('managedUserSettingsPageTabTitle'),
- 'managed-user-settings-page',
- $('managed-user-settings-confirm'),
- $('managed-user-settings-cancel'));
+ 'managed-user-settings-page');
}
cr.addSingletonGetter(ManagedUserSettings);
@@ -41,32 +38,22 @@ cr.define('options', function() {
};
ManagedUserSettings.prototype = {
- // Inherit from SettingsDialog.
- __proto__: SettingsDialog.prototype,
+ // Inherit from OptionsPage.
+ __proto__: OptionsPage.prototype,
// The current authentication state of the manager of the managed account.
- authenticationState: ManagedUserAuthentication.UNAUTHENTICATED,
+ authenticationState_: ManagedUserAuthentication.UNAUTHENTICATED,
- // True if the local passphrase of the manager of the managed account is
- // set. If it is not set, no authentication is required.
- isPassphraseSet: false,
+ get isAuthenticated() {
+ return !cr.isChromeOS &&
+ (this.authenticationState_ ==
+ ManagedUserAuthentication.AUTHENTICATED);
+ },
- /**
- * Initialize the page.
- * @override
- */
+ /** @override */
initializePage: function() {
- // Call base class implementation to start preference initialization.
- SettingsDialog.prototype.initializePage.call(this);
-
$('manage-exceptions-button').onclick = function(event) {
- var page = ManagedUserSettingsExceptionsArea.getInstance();
- var url = page.name;
-
OptionsPage.navigateToPage('manualExceptions');
- uber.invokeMethodOnParent('setPath', {path: url});
- uber.invokeMethodOnParent('setTitle',
- {title: loadTimeData.getString('manualExceptionsTabTitle')});
};
$('get-content-packs-button').onclick = function(event) {
@@ -78,58 +65,57 @@ cr.define('options', function() {
OptionsPage.navigateToPage('setPassphrase');
};
- $('use-passphrase-checkbox').onclick = function() {
- $('set-passphrase').disabled = !$('use-passphrase-checkbox').checked;
- };
-
var self = this;
$('lock-settings').onclick = function() {
chrome.send('setElevated', [false]);
// The managed user is currently authenticated, so don't wait for a
// callback to set the new authentication state since a reset to not
// elevated is done without showing the passphrase dialog.
- self.authenticationState = ManagedUserAuthentication.UNAUTHENTICATED;
- self.enableControls(false);
+ self.authenticationState_ = ManagedUserAuthentication.UNAUTHENTICATED;
+ self.updateControls_();
};
$('unlock-settings').onclick = function() {
- if (self.authenticationState == ManagedUserAuthentication.CHECKING)
+ if (self.authenticationState_ == ManagedUserAuthentication.CHECKING)
return;
- self.authenticationState = ManagedUserAuthentication.CHECKING;
+
+ self.authenticationState_ = ManagedUserAuthentication.CHECKING;
chrome.send('setElevated', [true]);
};
}
- },
- /** @override */
- handleConfirm: function() {
- if (!cr.isChromeOS) {
- if ($('use-passphrase-checkbox').checked && !this.isPassphraseSet) {
- OptionsPage.navigateToPage('setPassphrase');
- return;
- }
- if (!$('use-passphrase-checkbox').checked)
- chrome.send('resetPassphrase');
- }
- SettingsDialog.prototype.handleConfirm.call(this);
+ $('managed-user-settings-done').onclick = function() {
+ OptionsPage.closeOverlay();
+ };
},
- /** Update the page according to the current authentication state */
+ /**
+ * Update the page according to the current authentication state.
+ * @override
+ */
didShowPage: function() {
- var isAuthenticated =
- this.authenticationState == ManagedUserAuthentication.AUTHENTICATED;
- this.enableControls(isAuthenticated);
+ this.updateControls_();
chrome.send('settingsPageOpened');
},
+ /**
+ * Reset the authentication to UNAUTHENTICATED when the managed user
+ * settings dialog is closed.
+ * @override
+ */
+ didClosePage: function() {
+ // Reset the authentication of the custodian.
+ this.authenticationState_ = ManagedUserAuthentication.UNAUTHENTICATED;
+ chrome.send('setElevated', [false]);
+ chrome.send('confirmManagedUserSettings');
+ },
+
// Enables or disables all controls based on the authentication state of
// the managed user. If |enable| is true, the controls will be enabled.
- enableControls: function(enable) {
- if (!cr.isChromeOS) {
- $('set-passphrase').disabled =
- !enable || !$('use-passphrase-checkbox').checked;
- $('use-passphrase-checkbox').disabled = !enable;
- }
+ updateControls_: function() {
+ var enable = this.isAuthenticated;
+
+ $('set-passphrase').disabled = !enable;
// TODO(sergiu): make $('get-content-packs-button') behave the same as
// the other controls once the button actually does something.
$('manage-exceptions-button').disabled = !enable;
@@ -138,51 +124,30 @@ cr.define('options', function() {
$('contentpacks-block').setDisabled('notManagedUserModifiable', !enable);
$('safe-search-checkbox').setDisabled('notManagedUserModifiable',
!enable);
- $('allow-signin-checkbox').setDisabled('notManagedUserModifiable',
- !enable);
- // TODO(akuegel): Add disable-history-deletion-checkbox once this feature
- // is implemented.
+
if (enable)
$('managed-user-settings-page').classList.remove('locked');
else
$('managed-user-settings-page').classList.add('locked');
},
- // Is called when the passphrase dialog is closed. |success| is true
- // if the authentication was successful.
- isAuthenticated_: function(success) {
+ // Called when the passphrase dialog is closed. |success| is true iff the
+ // authentication was successful.
+ setAuthenticated_: function(success) {
if (success) {
- this.authenticationState = ManagedUserAuthentication.AUTHENTICATED;
- this.enableControls(true);
+ this.authenticationState_ = ManagedUserAuthentication.AUTHENTICATED;
+ this.updateControls_();
} else {
- this.authenticationState = ManagedUserAuthentication.UNAUTHENTICATED;
+ this.authenticationState_ = ManagedUserAuthentication.UNAUTHENTICATED;
}
},
- // Reset the authentication to UNAUTHENTICATED when the managed user
- // settings dialog is closed.
- didClosePage: function() {
- // Reset the authentication of the custodian.
- this.authenticationState = ManagedUserAuthentication.UNAUTHENTICATED;
- chrome.send('setElevated', [false]);
- chrome.send('confirmManagedUserSettings');
- },
};
// Sets the authentication state of the managed user. |success| is true if
// the authentication was successful.
- ManagedUserSettings.isAuthenticated = function(success) {
- ManagedUserSettings.getInstance().isAuthenticated_(success);
- };
-
- // Sets the use passphrase checkbox according to if a passphrase is specified
- // or not. |hasPassphrase| is true if the local passphrase is non-empty.
- ManagedUserSettings.passphraseChanged = function(hasPassphrase) {
- var instance = ManagedUserSettings.getInstance();
- if (instance.authenticationState == ManagedUserAuthentication.AUTHENTICATED)
- $('set-passphrase').disabled = !hasPassphrase;
- $('use-passphrase-checkbox').checked = hasPassphrase;
- ManagedUserSettings.getInstance().isPassphraseSet = hasPassphrase;
+ ManagedUserSettings.setAuthenticated = function(success) {
+ ManagedUserSettings.getInstance().setAuthenticated_(success);
};
var ManagedUserSettingsForTesting = {
@@ -220,7 +185,6 @@ cr.define('options', function() {
return {
ManagedUserSettings: ManagedUserSettings,
ManagedUserSettingsForTesting: ManagedUserSettingsForTesting,
- ManagedUserAuthentication: ManagedUserAuthentication
};
});
diff --git a/chrome/browser/ui/webui/managed_user_passphrase_dialog.cc b/chrome/browser/ui/webui/managed_user_passphrase_dialog.cc
index 5d409f9..e146604 100644
--- a/chrome/browser/ui/webui/managed_user_passphrase_dialog.cc
+++ b/chrome/browser/ui/webui/managed_user_passphrase_dialog.cc
@@ -129,7 +129,7 @@ void ManagedUserPassphraseDialog::GetWebUIMessageHandlers(
void ManagedUserPassphraseDialog::GetDialogSize(gfx::Size* size) const {
const int kDialogWidth = 383;
- const int kDialogHeight = 258;
+ const int kDialogHeight = 225;
size->SetSize(kDialogWidth, kDialogHeight);
}
diff --git a/chrome/browser/ui/webui/options/managed_user_passphrase_handler.cc b/chrome/browser/ui/webui/options/managed_user_passphrase_handler.cc
index 36d2369..b2694be 100644
--- a/chrome/browser/ui/webui/options/managed_user_passphrase_handler.cc
+++ b/chrome/browser/ui/webui/options/managed_user_passphrase_handler.cc
@@ -39,10 +39,6 @@ void ManagedUserPassphraseHandler::RegisterMessages() {
"setElevated",
base::Bind(&ManagedUserPassphraseHandler::SetElevated,
weak_ptr_factory_.GetWeakPtr()));
- web_ui()->RegisterMessageCallback(
- "resetPassphrase",
- base::Bind(&ManagedUserPassphraseHandler::ResetPassphrase,
- weak_ptr_factory_.GetWeakPtr()));
}
void ManagedUserPassphraseHandler::GetLocalizedValues(
@@ -91,29 +87,29 @@ void ManagedUserPassphraseHandler::SetElevated(
weak_ptr_factory_.GetWeakPtr()));
}
-void ManagedUserPassphraseHandler::ResetPassphrase(
- const base::ListValue* args) {
- PrefService* pref_service = Profile::FromWebUI(web_ui())->GetPrefs();
- pref_service->SetString(prefs::kManagedModeLocalPassphrase, std::string());
- pref_service->SetString(prefs::kManagedModeLocalSalt, std::string());
-}
-
void ManagedUserPassphraseHandler::SetLocalPassphrase(
const base::ListValue* args) {
// Only change the passphrase if the custodian is authenticated.
if (!ManagedModeNavigationObserver::FromWebContents(
- web_ui()->GetWebContents())->is_elevated())
+ web_ui()->GetWebContents())->is_elevated()) {
return;
+ }
+ PrefService* pref_service = Profile::FromWebUI(web_ui())->GetPrefs();
std::string passphrase;
args->GetString(0, &passphrase);
+ if (passphrase.empty()) {
+ pref_service->SetString(prefs::kManagedModeLocalPassphrase, std::string());
+ pref_service->SetString(prefs::kManagedModeLocalSalt, std::string());
+ return;
+ }
+
ManagedUserPassphrase passphrase_key_generator((std::string()));
std::string encoded_passphrase_hash;
bool success = passphrase_key_generator.GenerateHashFromPassphrase(
passphrase,
&encoded_passphrase_hash);
if (success) {
- PrefService* pref_service = Profile::FromWebUI(web_ui())->GetPrefs();
pref_service->SetString(prefs::kManagedModeLocalPassphrase,
encoded_passphrase_hash);
pref_service->SetString(prefs::kManagedModeLocalSalt,
diff --git a/chrome/browser/ui/webui/options/managed_user_passphrase_handler.h b/chrome/browser/ui/webui/options/managed_user_passphrase_handler.h
index e75ed76..88df671 100644
--- a/chrome/browser/ui/webui/options/managed_user_passphrase_handler.h
+++ b/chrome/browser/ui/webui/options/managed_user_passphrase_handler.h
@@ -42,14 +42,6 @@ class ManagedUserPassphraseHandler : public OptionsPageUIHandler {
// the authentication was successful.
void PassphraseDialogCallback(bool success);
- // Checks if there is already a passphrase specified. It expects as parameter
- // the name of the Javascript function which should be called with the results
- // of this check.
- void IsPassphraseSet(const base::ListValue* args);
-
- // Resets the passphrase to the empty string.
- void ResetPassphrase(const base::ListValue* args);
-
// The name of the Javascript function which should be called after the
// passphrase has been checked.
std::string callback_function_name_;
diff --git a/chrome/browser/ui/webui/options/managed_user_set_passphrase_browsertest.js b/chrome/browser/ui/webui/options/managed_user_set_passphrase_browsertest.js
index 1ae00d6..beec4dd 100644
--- a/chrome/browser/ui/webui/options/managed_user_set_passphrase_browsertest.js
+++ b/chrome/browser/ui/webui/options/managed_user_set_passphrase_browsertest.js
@@ -87,7 +87,7 @@ TEST_F('ManagedUserSetPassphraseTest', 'EmptyPassphrase',
this.setPassphrase();
this.enterPassphrase('');
this.confirmPassphrase('');
- this.mockHandler.expects(never()).setPassphrase(ANYTHING);
+ this.mockHandler.expects(once()).setPassphrase(['']);
this.savePassphrase();
});
diff --git a/chrome/browser/ui/webui/options/managed_user_settings_browsertest.js b/chrome/browser/ui/webui/options/managed_user_settings_browsertest.js
index f791e6d..9b0d7c7 100644
--- a/chrome/browser/ui/webui/options/managed_user_settings_browsertest.js
+++ b/chrome/browser/ui/webui/options/managed_user_settings_browsertest.js
@@ -33,14 +33,11 @@ ManagedUserSettingsTest.prototype = {
};
-// Verify that the settings page is locked when a passphrase is specified.
+// Verify that the settings page is locked and can be unlocked.
TEST_F('ManagedUserSettingsTest', 'PageLocked',
function() {
- // Check that the user is not authenticated when a passphrase is set.
- ManagedUserSettings.passphraseChanged(true);
var instance = ManagedUserSettings.getInstance();
- expectEquals(instance.authenticationState,
- options.ManagedUserAuthentication.UNAUTHENTICATED);
+ expectFalse(instance.isAuthenticated);
// Now verify that the unlock button can be clicked.
var unlockButton =
options.ManagedUserSettingsForTesting.getUnlockButton();
@@ -51,16 +48,3 @@ TEST_F('ManagedUserSettingsTest', 'PageLocked',
this.mockHandler.expects(once()).setElevated([false]);
OptionsPage.closeOverlay();
});
-
-// Verify that the settings page is also locked when no passphrase is specified.
-TEST_F('ManagedUserSettingsTest', 'PageLockedNoPassphrase',
- function() {
- var instance = ManagedUserSettings.getInstance();
- expectEquals(instance.authenticationState,
- options.ManagedUserAuthentication.UNAUTHENTICATED);
- var unlockButton =
- options.ManagedUserSettingsForTesting.getUnlockButton();
- expectFalse(unlockButton.disabled);
- this.mockHandler.expects(once()).setElevated([false]);
- OptionsPage.closeOverlay();
- });
diff --git a/chrome/browser/ui/webui/options/managed_user_settings_handler.cc b/chrome/browser/ui/webui/options/managed_user_settings_handler.cc
index 8d07789..6b420d0 100644
--- a/chrome/browser/ui/webui/options/managed_user_settings_handler.cc
+++ b/chrome/browser/ui/webui/options/managed_user_settings_handler.cc
@@ -98,30 +98,12 @@ ManagedUserSettingsHandler::ManagedUserSettingsHandler()
ManagedUserSettingsHandler::~ManagedUserSettingsHandler() {
}
-void ManagedUserSettingsHandler::InitializeHandler() {
- pref_change_registrar_.Init(Profile::FromWebUI(web_ui())->GetPrefs());
- pref_change_registrar_.Add(
- prefs::kManagedModeLocalPassphrase,
- base::Bind(&ManagedUserSettingsHandler::OnLocalPassphraseChanged,
- base::Unretained(this)));
-}
-
void ManagedUserSettingsHandler::InitializePage() {
if (!CommandLine::ForCurrentProcess()->HasSwitch(
switches::kEnableManagedUsers)) {
return;
}
-#if !defined(OS_CHROMEOS)
- PrefService* pref_service = Profile::FromWebUI(web_ui())->GetPrefs();
- bool passphrase_empty =
- pref_service->GetString(prefs::kManagedModeLocalPassphrase).empty();
- base::FundamentalValue is_passphrase_set(!passphrase_empty);
- web_ui()->CallJavascriptFunction(
- "ManagedUserSettings.passphraseChanged",
- is_passphrase_set);
-#endif
-
// Populate the list.
UpdateViewFromModel();
}
@@ -146,7 +128,7 @@ void ManagedUserSettingsHandler::HandlePageOpened(const base::ListValue* args) {
}
if (observer->is_elevated()) {
- web_ui()->CallJavascriptFunction("ManagedUserSettings.isAuthenticated",
+ web_ui()->CallJavascriptFunction("ManagedUserSettings.setAuthenticated",
base::FundamentalValue(true));
}
}
@@ -180,10 +162,7 @@ void ManagedUserSettingsHandler::GetLocalizedValues(
// Other managed user settings
{ "advancedManagedUserSettings", IDS_ADVANCED_MANAGED_USER_LABEL },
{ "enableSafeSearch", IDS_SAFE_SEARCH_ENABLED },
- { "allowSignIn", IDS_SIGNIN_SYNC_ALLOWED },
- { "disableHistoryDeletion", IDS_HISTORY_DELETION_DISABLED },
- { "usePassphrase", IDS_USE_PASSPHRASE_LABEL },
- { "setPassphrase", IDS_SET_PASSPHRASE_BUTTON }
+ { "setPassphrase", IDS_SET_PASSPHRASE_BUTTON },
};
RegisterStrings(localized_strings, resources, arraysize(resources));
@@ -206,15 +185,17 @@ void ManagedUserSettingsHandler::RegisterMessages() {
"settingsPageOpened",
base::Bind(&ManagedUserSettingsHandler::HandlePageOpened,
base::Unretained(this)));
- web_ui()->RegisterMessageCallback("removeManualException",
+ web_ui()->RegisterMessageCallback(
+ "removeManualException",
base::Bind(&ManagedUserSettingsHandler::RemoveManualException,
base::Unretained(this)));
- web_ui()->RegisterMessageCallback("setManualException",
+ web_ui()->RegisterMessageCallback(
+ "setManualException",
base::Bind(&ManagedUserSettingsHandler::SetManualException,
base::Unretained(this)));
- web_ui()->RegisterMessageCallback("checkManualExceptionValidity",
- base::Bind(
- &ManagedUserSettingsHandler::CheckManualExceptionValidity,
+ web_ui()->RegisterMessageCallback(
+ "checkManualExceptionValidity",
+ base::Bind(&ManagedUserSettingsHandler::CheckManualExceptionValidity,
base::Unretained(this)));
}
@@ -229,14 +210,6 @@ void ManagedUserSettingsHandler::SaveMetrics(const ListValue* args) {
}
}
-void ManagedUserSettingsHandler::OnLocalPassphraseChanged() {
- PrefService* pref_service = Profile::FromWebUI(web_ui())->GetPrefs();
- base::FundamentalValue is_passphrase_set(!pref_service->GetString(
- prefs::kManagedModeLocalPassphrase).empty());
- web_ui()->CallJavascriptFunction("ManagedUserSettings.passphraseChanged",
- is_passphrase_set);
-}
-
void ManagedUserSettingsHandler::RemoveManualException(
const ListValue* args) {
// Check if the user is authenticated.
diff --git a/chrome/browser/ui/webui/options/managed_user_settings_handler.h b/chrome/browser/ui/webui/options/managed_user_settings_handler.h
index 988668d..eede222 100644
--- a/chrome/browser/ui/webui/options/managed_user_settings_handler.h
+++ b/chrome/browser/ui/webui/options/managed_user_settings_handler.h
@@ -22,7 +22,6 @@ class ManagedUserSettingsHandler : public OptionsPageUIHandler {
virtual void GetLocalizedValues(
base::DictionaryValue* localized_strings) OVERRIDE;
- virtual void InitializeHandler() OVERRIDE;
virtual void InitializePage() OVERRIDE;
virtual void RegisterMessages() OVERRIDE;
@@ -33,9 +32,6 @@ class ManagedUserSettingsHandler : public OptionsPageUIHandler {
// Records metric that the settings page was opened. Called from WebUI.
void HandlePageOpened(const base::ListValue* args);
- // Called when the local passphrase changes.
- void OnLocalPassphraseChanged();
-
// Decides whether a given pattern is valid, or if it should be
// rejected. Called while the user is editing an exception pattern.
void CheckManualExceptionValidity(const base::ListValue* args);