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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/managed_user_settings_handler.h" 5 #include "chrome/browser/ui/webui/options/managed_user_settings_handler.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/metrics/histogram.h" 10 #include "base/metrics/histogram.h"
11 #include "base/prefs/pref_service.h"
11 #include "base/time.h" 12 #include "base/time.h"
12 #include "base/values.h" 13 #include "base/values.h"
13 #include "chrome/browser/first_run/first_run.h" 14 #include "chrome/browser/first_run/first_run.h"
15 #include "chrome/browser/profiles/profile.h"
14 #include "chrome/common/chrome_switches.h" 16 #include "chrome/common/chrome_switches.h"
17 #include "chrome/common/pref_names.h"
15 #include "content/public/browser/user_metrics.h" 18 #include "content/public/browser/user_metrics.h"
16 #include "content/public/browser/web_ui.h" 19 #include "content/public/browser/web_ui.h"
17 #include "grit/generated_resources.h" 20 #include "grit/generated_resources.h"
18 #include "grit/locale_settings.h" 21 #include "grit/locale_settings.h"
19 22
20 using content::UserMetricsAction; 23 using content::UserMetricsAction;
21 24
22 namespace options { 25 namespace options {
23 26
24 ManagedUserSettingsHandler::ManagedUserSettingsHandler() { 27 ManagedUserSettingsHandler::ManagedUserSettingsHandler() {
25 } 28 }
26 29
27 ManagedUserSettingsHandler::~ManagedUserSettingsHandler() { 30 ManagedUserSettingsHandler::~ManagedUserSettingsHandler() {
28 } 31 }
29 32
33 void ManagedUserSettingsHandler::InitializeHandler() {
34 pref_change_registrar_.Init(Profile::FromWebUI(web_ui())->GetPrefs());
35 pref_change_registrar_.Add(
36 prefs::kManagedModeLocalPassphrase,
37 base::Bind(&ManagedUserSettingsHandler::OnLocalPassphraseChanged,
38 base::Unretained(this)));
39 }
40
30 void ManagedUserSettingsHandler::InitializePage() { 41 void ManagedUserSettingsHandler::InitializePage() {
31 start_time_ = base::TimeTicks::Now(); 42 start_time_ = base::TimeTicks::Now();
32 content::RecordAction(UserMetricsAction("ManagedMode_OpenSettings")); 43 content::RecordAction(UserMetricsAction("ManagedMode_OpenSettings"));
44 if (CommandLine::ForCurrentProcess()->HasSwitch(
45 switches::kEnableManagedUsers)) {
46 PrefService* pref_service = Profile::FromWebUI(web_ui())->GetPrefs();
47 base::FundamentalValue is_passphrase_set(!pref_service->GetString(
48 prefs::kManagedModeLocalPassphrase).empty());
49 web_ui()->CallJavascriptFunction(
50 "ManagedUserSettings.initializeSetPassphraseButton",
51 is_passphrase_set);
52 }
33 } 53 }
34 54
35 void ManagedUserSettingsHandler::GetLocalizedValues( 55 void ManagedUserSettingsHandler::GetLocalizedValues(
36 base::DictionaryValue* localized_strings) { 56 base::DictionaryValue* localized_strings) {
37 DCHECK(localized_strings); 57 DCHECK(localized_strings);
38 58
39 static OptionsStringResource resources[] = { 59 static OptionsStringResource resources[] = {
60 // Unlock the settings page to allow editing.
61 { "unlockSettings", IDS_UNLOCK_PASSPHRASE_BUTTON },
40 // Installed content packs. 62 // Installed content packs.
41 { "installedContentPacks", IDS_INSTALLED_CONTENT_PACKS_LABEL }, 63 { "installedContentPacks", IDS_INSTALLED_CONTENT_PACKS_LABEL },
42 { "getContentPacks", IDS_GET_CONTENT_PACKS_BUTTON }, 64 { "getContentPacks", IDS_GET_CONTENT_PACKS_BUTTON },
43 { "getContentPacksURL", IDS_GET_CONTENT_PACKS_URL }, 65 { "getContentPacksURL", IDS_GET_CONTENT_PACKS_URL },
44 // Content pack restriction options. 66 // Content pack restriction options.
45 { "contentPackSettings", IDS_CONTENT_PACK_SETTINGS_LABEL }, 67 { "contentPackSettings", IDS_CONTENT_PACK_SETTINGS_LABEL },
46 { "outsideContentPacksAllow", IDS_OUTSIDE_CONTENT_PACKS_ALLOW_RADIO }, 68 { "outsideContentPacksAllow", IDS_OUTSIDE_CONTENT_PACKS_ALLOW_RADIO },
47 { "outsideContentPacksWarn", IDS_OUTSIDE_CONTENT_PACKS_WARN_RADIO }, 69 { "outsideContentPacksWarn", IDS_OUTSIDE_CONTENT_PACKS_WARN_RADIO },
48 { "outsideContentPacksBlock", IDS_OUTSIDE_CONTENT_PACKS_BLOCK_RADIO }, 70 { "outsideContentPacksBlock", IDS_OUTSIDE_CONTENT_PACKS_BLOCK_RADIO },
49 // Other managed user settings 71 // Other managed user settings
(...skipping 25 matching lines...) Expand all
75 void ManagedUserSettingsHandler::SaveMetrics(const ListValue* args) { 97 void ManagedUserSettingsHandler::SaveMetrics(const ListValue* args) {
76 if (first_run::IsChromeFirstRun()) { 98 if (first_run::IsChromeFirstRun()) {
77 UMA_HISTOGRAM_LONG_TIMES("ManagedMode.UserSettingsFirstRunTime", 99 UMA_HISTOGRAM_LONG_TIMES("ManagedMode.UserSettingsFirstRunTime",
78 base::TimeTicks::Now() - start_time_); 100 base::TimeTicks::Now() - start_time_);
79 } else { 101 } else {
80 UMA_HISTOGRAM_LONG_TIMES("ManagedMode.UserSettingsModifyTime", 102 UMA_HISTOGRAM_LONG_TIMES("ManagedMode.UserSettingsModifyTime",
81 base::TimeTicks::Now() - start_time_); 103 base::TimeTicks::Now() - start_time_);
82 } 104 }
83 } 105 }
84 106
107 void ManagedUserSettingsHandler::OnLocalPassphraseChanged() {
108 PrefService* pref_service = Profile::FromWebUI(web_ui())->GetPrefs();
109 base::FundamentalValue is_passphrase_set(!pref_service->GetString(
110 prefs::kManagedModeLocalPassphrase).empty());
111 web_ui()->CallJavascriptFunction("ManagedUserSettings.passphraseChanged",
112 is_passphrase_set);
113 }
114
85 } // namespace options 115 } // namespace options
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698