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

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: Rebase to ToT and address review comments. 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 passphrase_.Init(
35 prefs::kManagedModeLocalPassphrase,
36 Profile::FromWebUI(web_ui())->GetPrefs(),
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 PrefService* pref_service = Profile::FromWebUI(web_ui())->GetPrefs();
45 base::FundamentalValue is_passphrase_set(!pref_service->GetString(
46 prefs::kManagedModeLocalPassphrase).empty());
47 web_ui()->CallJavascriptFunction(
48 "ManagedUserSettings.initializeSetPassphraseButton",
49 is_passphrase_set);
33 } 50 }
34 51
35 void ManagedUserSettingsHandler::GetLocalizedValues( 52 void ManagedUserSettingsHandler::GetLocalizedValues(
36 base::DictionaryValue* localized_strings) { 53 base::DictionaryValue* localized_strings) {
37 DCHECK(localized_strings); 54 DCHECK(localized_strings);
38 55
39 static OptionsStringResource resources[] = { 56 static OptionsStringResource resources[] = {
57 // Unlock the settings page to allow editing.
58 { "unlockSettings", IDS_UNLOCK_PASSPHRASE_BUTTON },
40 // Installed content packs. 59 // Installed content packs.
41 { "installedContentPacks", IDS_INSTALLED_CONTENT_PACKS_LABEL }, 60 { "installedContentPacks", IDS_INSTALLED_CONTENT_PACKS_LABEL },
42 { "getContentPacks", IDS_GET_CONTENT_PACKS_BUTTON }, 61 { "getContentPacks", IDS_GET_CONTENT_PACKS_BUTTON },
43 { "getContentPacksURL", IDS_GET_CONTENT_PACKS_URL }, 62 { "getContentPacksURL", IDS_GET_CONTENT_PACKS_URL },
44 // Content pack restriction options. 63 // Content pack restriction options.
45 { "contentPackSettings", IDS_CONTENT_PACK_SETTINGS_LABEL }, 64 { "contentPackSettings", IDS_CONTENT_PACK_SETTINGS_LABEL },
46 { "outsideContentPacksAllow", IDS_OUTSIDE_CONTENT_PACKS_ALLOW_RADIO }, 65 { "outsideContentPacksAllow", IDS_OUTSIDE_CONTENT_PACKS_ALLOW_RADIO },
47 { "outsideContentPacksWarn", IDS_OUTSIDE_CONTENT_PACKS_WARN_RADIO }, 66 { "outsideContentPacksWarn", IDS_OUTSIDE_CONTENT_PACKS_WARN_RADIO },
48 { "outsideContentPacksBlock", IDS_OUTSIDE_CONTENT_PACKS_BLOCK_RADIO }, 67 { "outsideContentPacksBlock", IDS_OUTSIDE_CONTENT_PACKS_BLOCK_RADIO },
49 // Other managed user settings 68 // Other managed user settings
(...skipping 25 matching lines...) Expand all
75 void ManagedUserSettingsHandler::SaveMetrics(const ListValue* args) { 94 void ManagedUserSettingsHandler::SaveMetrics(const ListValue* args) {
76 if (first_run::IsChromeFirstRun()) { 95 if (first_run::IsChromeFirstRun()) {
77 UMA_HISTOGRAM_LONG_TIMES("ManagedMode.UserSettingsFirstRunTime", 96 UMA_HISTOGRAM_LONG_TIMES("ManagedMode.UserSettingsFirstRunTime",
78 base::TimeTicks::Now() - start_time_); 97 base::TimeTicks::Now() - start_time_);
79 } else { 98 } else {
80 UMA_HISTOGRAM_LONG_TIMES("ManagedMode.UserSettingsModifyTime", 99 UMA_HISTOGRAM_LONG_TIMES("ManagedMode.UserSettingsModifyTime",
81 base::TimeTicks::Now() - start_time_); 100 base::TimeTicks::Now() - start_time_);
82 } 101 }
83 } 102 }
84 103
104 void ManagedUserSettingsHandler::OnLocalPassphraseChanged() {
105 base::FundamentalValue is_passphrase_set(!passphrase_.GetValue().empty());
106 web_ui()->CallJavascriptFunction("ManagedUserSettings.passphraseChanged",
107 is_passphrase_set);
108 }
109
85 } // namespace options 110 } // namespace options
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698