Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4922)

Unified Diff: chrome/browser/ui/webui/options/managed_user_settings_handler.cc

Issue 11783008: Add a lock to the managed user settings page and require authentication for unlocking. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix problem with some WebUI tests. Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/webui/options/managed_user_settings_handler.cc
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 0af71b88b3e3f4d9aab78df9fb74211cef3d1932..db6459bab24a4c1387556135bc6b0b3316dc8f3a 100644
--- a/chrome/browser/ui/webui/options/managed_user_settings_handler.cc
+++ b/chrome/browser/ui/webui/options/managed_user_settings_handler.cc
@@ -8,10 +8,13 @@
#include "base/command_line.h"
#include "base/logging.h"
#include "base/metrics/histogram.h"
+#include "base/prefs/pref_service.h"
#include "base/time.h"
#include "base/values.h"
#include "chrome/browser/first_run/first_run.h"
+#include "chrome/browser/profiles/profile.h"
#include "chrome/common/chrome_switches.h"
+#include "chrome/common/pref_names.h"
#include "content/public/browser/user_metrics.h"
#include "content/public/browser/web_ui.h"
#include "grit/generated_resources.h"
@@ -27,9 +30,26 @@ 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() {
start_time_ = base::TimeTicks::Now();
content::RecordAction(UserMetricsAction("ManagedMode_OpenSettings"));
+ if (CommandLine::ForCurrentProcess()->HasSwitch(
+ switches::kEnableManagedUsers)) {
+ PrefService* pref_service = Profile::FromWebUI(web_ui())->GetPrefs();
+ base::FundamentalValue is_passphrase_set(!pref_service->GetString(
+ prefs::kManagedModeLocalPassphrase).empty());
+ web_ui()->CallJavascriptFunction(
+ "ManagedUserSettings.initializeSetPassphraseButton",
+ is_passphrase_set);
+ }
}
void ManagedUserSettingsHandler::GetLocalizedValues(
@@ -37,6 +57,8 @@ void ManagedUserSettingsHandler::GetLocalizedValues(
DCHECK(localized_strings);
static OptionsStringResource resources[] = {
+ // Unlock the settings page to allow editing.
+ { "unlockSettings", IDS_UNLOCK_PASSPHRASE_BUTTON },
// Installed content packs.
{ "installedContentPacks", IDS_INSTALLED_CONTENT_PACKS_LABEL },
{ "getContentPacks", IDS_GET_CONTENT_PACKS_BUTTON },
@@ -82,4 +104,12 @@ 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);
+}
+
} // namespace options

Powered by Google App Engine
This is Rietveld 408576698