| OLD | NEW |
| 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 <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| 11 #include "base/logging.h" | 11 #include "base/logging.h" |
| 12 #include "base/metrics/histogram.h" | 12 #include "base/metrics/histogram.h" |
| 13 #include "base/prefs/pref_service.h" | 13 #include "base/prefs/pref_service.h" |
| 14 #include "base/time.h" | 14 #include "base/time.h" |
| 15 #include "base/values.h" | 15 #include "base/values.h" |
| 16 #include "chrome/browser/first_run/first_run.h" | |
| 17 #include "chrome/browser/managed_mode/managed_mode_navigation_observer.h" | 16 #include "chrome/browser/managed_mode/managed_mode_navigation_observer.h" |
| 18 #include "chrome/browser/managed_mode/managed_user_service.h" | 17 #include "chrome/browser/managed_mode/managed_user_service.h" |
| 19 #include "chrome/browser/managed_mode/managed_user_service_factory.h" | 18 #include "chrome/browser/managed_mode/managed_user_service_factory.h" |
| 20 #include "chrome/browser/profiles/profile.h" | 19 #include "chrome/browser/profiles/profile.h" |
| 21 #include "chrome/common/chrome_switches.h" | 20 #include "chrome/common/chrome_switches.h" |
| 22 #include "chrome/common/pref_names.h" | 21 #include "chrome/common/pref_names.h" |
| 23 #include "content/public/browser/user_metrics.h" | 22 #include "content/public/browser/user_metrics.h" |
| 24 #include "content/public/browser/web_ui.h" | 23 #include "content/public/browser/web_ui.h" |
| 25 #include "googleurl/src/url_canon.h" | 24 #include "googleurl/src/url_canon.h" |
| 26 #include "grit/chromium_strings.h" | 25 #include "grit/chromium_strings.h" |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 105 base::Bind(&ManagedUserSettingsHandler::OnLocalPassphraseChanged, | 104 base::Bind(&ManagedUserSettingsHandler::OnLocalPassphraseChanged, |
| 106 base::Unretained(this))); | 105 base::Unretained(this))); |
| 107 } | 106 } |
| 108 | 107 |
| 109 void ManagedUserSettingsHandler::InitializePage() { | 108 void ManagedUserSettingsHandler::InitializePage() { |
| 110 if (!CommandLine::ForCurrentProcess()->HasSwitch( | 109 if (!CommandLine::ForCurrentProcess()->HasSwitch( |
| 111 switches::kEnableManagedUsers)) { | 110 switches::kEnableManagedUsers)) { |
| 112 return; | 111 return; |
| 113 } | 112 } |
| 114 PrefService* pref_service = Profile::FromWebUI(web_ui())->GetPrefs(); | 113 PrefService* pref_service = Profile::FromWebUI(web_ui())->GetPrefs(); |
| 115 base::FundamentalValue is_passphrase_set(!pref_service->GetString( | 114 bool passphrase_empty = |
| 116 prefs::kManagedModeLocalPassphrase).empty()); | 115 pref_service->GetString(prefs::kManagedModeLocalPassphrase).empty(); |
| 116 base::FundamentalValue is_passphrase_set(!passphrase_empty); |
| 117 web_ui()->CallJavascriptFunction( | 117 web_ui()->CallJavascriptFunction( |
| 118 "ManagedUserSettings.passphraseChanged", | 118 "ManagedUserSettings.passphraseChanged", |
| 119 is_passphrase_set); | 119 is_passphrase_set); |
| 120 if ((first_run::IsChromeFirstRun() && | |
| 121 !CommandLine::ForCurrentProcess()->HasSwitch(switches::kNoFirstRun)) || | |
| 122 CommandLine::ForCurrentProcess()->HasSwitch( | |
| 123 switches::kResetLocalPassphrase)) { | |
| 124 ManagedModeNavigationObserver::FromWebContents( | |
| 125 web_ui()->GetWebContents())->set_elevated(true); | |
| 126 } | |
| 127 | 120 |
| 128 // Populate the list. | 121 // Populate the list. |
| 129 UpdateViewFromModel(); | 122 UpdateViewFromModel(); |
| 130 } | 123 } |
| 131 | 124 |
| 132 void ManagedUserSettingsHandler::HandlePageOpened(const base::ListValue* args) { | 125 void ManagedUserSettingsHandler::HandlePageOpened(const base::ListValue* args) { |
| 133 start_time_ = base::TimeTicks::Now(); | 126 start_time_ = base::TimeTicks::Now(); |
| 134 content::RecordAction(UserMetricsAction("ManagedMode_OpenSettings")); | 127 content::RecordAction(UserMetricsAction("ManagedMode_OpenSettings")); |
| 135 if (ManagedModeNavigationObserver::FromWebContents( | 128 if (ManagedModeNavigationObserver::FromWebContents( |
| 136 web_ui()->GetWebContents())->is_elevated()) { | 129 web_ui()->GetWebContents())->is_elevated()) { |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 199 base::Unretained(this))); | 192 base::Unretained(this))); |
| 200 web_ui()->RegisterMessageCallback("setManualException", | 193 web_ui()->RegisterMessageCallback("setManualException", |
| 201 base::Bind(&ManagedUserSettingsHandler::SetManualException, | 194 base::Bind(&ManagedUserSettingsHandler::SetManualException, |
| 202 base::Unretained(this))); | 195 base::Unretained(this))); |
| 203 web_ui()->RegisterMessageCallback("checkManualExceptionValidity", | 196 web_ui()->RegisterMessageCallback("checkManualExceptionValidity", |
| 204 base::Bind( | 197 base::Bind( |
| 205 &ManagedUserSettingsHandler::CheckManualExceptionValidity, | 198 &ManagedUserSettingsHandler::CheckManualExceptionValidity, |
| 206 base::Unretained(this))); | 199 base::Unretained(this))); |
| 207 } | 200 } |
| 208 | 201 |
| 202 bool ManagedUserSettingsHandler::HasSeenSetupDialog() { |
| 203 PrefService* pref_service = Profile::FromWebUI(web_ui())->GetPrefs(); |
| 204 return pref_service->GetBoolean(prefs::kManagedModeHasSeenSetupDialog); |
| 205 } |
| 206 |
| 209 void ManagedUserSettingsHandler::SaveMetrics(const ListValue* args) { | 207 void ManagedUserSettingsHandler::SaveMetrics(const ListValue* args) { |
| 210 if (first_run::IsChromeFirstRun()) { | 208 if (!HasSeenSetupDialog()) { |
| 209 PrefService* pref_service = Profile::FromWebUI(web_ui())->GetPrefs(); |
| 210 pref_service->SetBoolean(prefs::kManagedModeHasSeenSetupDialog, true); |
| 211 UMA_HISTOGRAM_LONG_TIMES("ManagedMode.UserSettingsFirstRunTime", | 211 UMA_HISTOGRAM_LONG_TIMES("ManagedMode.UserSettingsFirstRunTime", |
| 212 base::TimeTicks::Now() - start_time_); | 212 base::TimeTicks::Now() - start_time_); |
| 213 } else { | 213 } else { |
| 214 UMA_HISTOGRAM_LONG_TIMES("ManagedMode.UserSettingsModifyTime", | 214 UMA_HISTOGRAM_LONG_TIMES("ManagedMode.UserSettingsModifyTime", |
| 215 base::TimeTicks::Now() - start_time_); | 215 base::TimeTicks::Now() - start_time_); |
| 216 } | 216 } |
| 217 } | 217 } |
| 218 | 218 |
| 219 void ManagedUserSettingsHandler::OnLocalPassphraseChanged() { | 219 void ManagedUserSettingsHandler::OnLocalPassphraseChanged() { |
| 220 PrefService* pref_service = Profile::FromWebUI(web_ui())->GetPrefs(); | 220 PrefService* pref_service = Profile::FromWebUI(web_ui())->GetPrefs(); |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 310 void ManagedUserSettingsHandler::UpdateViewFromModel() { | 310 void ManagedUserSettingsHandler::UpdateViewFromModel() { |
| 311 ListValue entries; | 311 ListValue entries; |
| 312 AddCurrentURLEntries(web_ui(), &entries); | 312 AddCurrentURLEntries(web_ui(), &entries); |
| 313 | 313 |
| 314 web_ui()->CallJavascriptFunction( | 314 web_ui()->CallJavascriptFunction( |
| 315 "ManagedUserSettings.setManualExceptions", | 315 "ManagedUserSettings.setManualExceptions", |
| 316 entries); | 316 entries); |
| 317 } | 317 } |
| 318 | 318 |
| 319 } // namespace options | 319 } // namespace options |
| OLD | NEW |