| 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 "base/bind.h" |
| 7 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 8 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/metrics/histogram.h" |
| 11 #include "base/time.h" |
| 9 #include "base/values.h" | 12 #include "base/values.h" |
| 13 #include "chrome/browser/first_run/first_run.h" |
| 10 #include "chrome/common/chrome_switches.h" | 14 #include "chrome/common/chrome_switches.h" |
| 15 #include "content/public/browser/user_metrics.h" |
| 16 #include "content/public/browser/web_ui.h" |
| 11 #include "grit/generated_resources.h" | 17 #include "grit/generated_resources.h" |
| 12 #include "grit/locale_settings.h" | 18 #include "grit/locale_settings.h" |
| 13 | 19 |
| 20 using content::UserMetricsAction; |
| 21 |
| 14 namespace options { | 22 namespace options { |
| 15 | 23 |
| 16 ManagedUserSettingsHandler::ManagedUserSettingsHandler() { | 24 ManagedUserSettingsHandler::ManagedUserSettingsHandler() { |
| 17 } | 25 } |
| 18 | 26 |
| 19 ManagedUserSettingsHandler::~ManagedUserSettingsHandler() { | 27 ManagedUserSettingsHandler::~ManagedUserSettingsHandler() { |
| 20 } | 28 } |
| 21 | 29 |
| 30 void ManagedUserSettingsHandler::InitializePage() { |
| 31 start_time_ = base::TimeTicks::Now(); |
| 32 content::RecordAction(UserMetricsAction("ManagedMode_OpenSettings")); |
| 33 } |
| 34 |
| 22 void ManagedUserSettingsHandler::GetLocalizedValues( | 35 void ManagedUserSettingsHandler::GetLocalizedValues( |
| 23 base::DictionaryValue* localized_strings) { | 36 base::DictionaryValue* localized_strings) { |
| 24 DCHECK(localized_strings); | 37 DCHECK(localized_strings); |
| 25 | 38 |
| 26 static OptionsStringResource resources[] = { | 39 static OptionsStringResource resources[] = { |
| 27 // Installed content packs. | 40 // Installed content packs. |
| 28 { "installedContentPacks", IDS_INSTALLED_CONTENT_PACKS_LABEL }, | 41 { "installedContentPacks", IDS_INSTALLED_CONTENT_PACKS_LABEL }, |
| 29 { "getContentPacks", IDS_GET_CONTENT_PACKS_BUTTON }, | 42 { "getContentPacks", IDS_GET_CONTENT_PACKS_BUTTON }, |
| 30 { "getContentPacksURL", IDS_GET_CONTENT_PACKS_URL }, | 43 { "getContentPacksURL", IDS_GET_CONTENT_PACKS_URL }, |
| 31 // Content pack restriction options. | 44 // Content pack restriction options. |
| (...skipping 13 matching lines...) Expand all Loading... |
| 45 RegisterStrings(localized_strings, resources, arraysize(resources)); | 58 RegisterStrings(localized_strings, resources, arraysize(resources)); |
| 46 RegisterTitle(localized_strings, "managedUserSettingsPage", | 59 RegisterTitle(localized_strings, "managedUserSettingsPage", |
| 47 IDS_MANAGED_USER_SETTINGS_TITLE); | 60 IDS_MANAGED_USER_SETTINGS_TITLE); |
| 48 | 61 |
| 49 localized_strings->SetBoolean( | 62 localized_strings->SetBoolean( |
| 50 "managedUsersEnabled", | 63 "managedUsersEnabled", |
| 51 CommandLine::ForCurrentProcess()->HasSwitch( | 64 CommandLine::ForCurrentProcess()->HasSwitch( |
| 52 switches::kEnableManagedUsers)); | 65 switches::kEnableManagedUsers)); |
| 53 } | 66 } |
| 54 | 67 |
| 68 void ManagedUserSettingsHandler::RegisterMessages() { |
| 69 web_ui()->RegisterMessageCallback("confirmManagedUserSettings", |
| 70 base::Bind(&ManagedUserSettingsHandler::ConfirmChanges, |
| 71 base::Unretained(this))); |
| 72 web_ui()->RegisterMessageCallback("cancelManagedUserSettings", |
| 73 base::Bind(&ManagedUserSettingsHandler::CancelChanges, |
| 74 base::Unretained(this))); |
| 75 } |
| 76 |
| 77 void ManagedUserSettingsHandler::ConfirmChanges(const ListValue* args) { |
| 78 // TODO(pamg): Is there any way we can distinguish an initial configuration |
| 79 // step from later adjustments? |
| 80 if (first_run::IsChromeFirstRun()) { |
| 81 UMA_HISTOGRAM_LONG_TIMES("ManagedMode.UserSettingsFirstRunTime", |
| 82 base::TimeTicks::Now() - start_time_); |
| 83 } else { |
| 84 UMA_HISTOGRAM_LONG_TIMES("ManagedMode.UserSettingsModifyTime", |
| 85 base::TimeTicks::Now() - start_time_); |
| 86 } |
| 87 } |
| 88 |
| 89 void ManagedUserSettingsHandler::CancelChanges(const ListValue* args) { |
| 90 content::RecordAction(UserMetricsAction("ManagedMode_CancelSettings")); |
| 91 } |
| 92 |
| 55 } // namespace options | 93 } // namespace options |
| OLD | NEW |