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/flags_ui.h" | 5 #include "chrome/browser/ui/webui/flags_ui.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
(...skipping 16 matching lines...) Expand all Loading... |
27 #include "content/public/browser/web_ui_message_handler.h" | 27 #include "content/public/browser/web_ui_message_handler.h" |
28 #include "grit/browser_resources.h" | 28 #include "grit/browser_resources.h" |
29 #include "grit/chromium_strings.h" | 29 #include "grit/chromium_strings.h" |
30 #include "grit/generated_resources.h" | 30 #include "grit/generated_resources.h" |
31 #include "grit/theme_resources.h" | 31 #include "grit/theme_resources.h" |
32 #include "ui/base/l10n/l10n_util.h" | 32 #include "ui/base/l10n/l10n_util.h" |
33 #include "ui/base/resource/resource_bundle.h" | 33 #include "ui/base/resource/resource_bundle.h" |
34 | 34 |
35 #if defined(OS_CHROMEOS) | 35 #if defined(OS_CHROMEOS) |
36 #include "base/sys_info.h" | 36 #include "base/sys_info.h" |
37 #include "chrome/browser/chromeos/login/users/user_manager.h" | |
38 #include "chrome/browser/chromeos/ownership/owner_settings_service.h" | 37 #include "chrome/browser/chromeos/ownership/owner_settings_service.h" |
39 #include "chrome/browser/chromeos/ownership/owner_settings_service_factory.h" | 38 #include "chrome/browser/chromeos/ownership/owner_settings_service_factory.h" |
40 #include "chrome/browser/chromeos/settings/cros_settings.h" | 39 #include "chrome/browser/chromeos/settings/cros_settings.h" |
41 #include "chrome/browser/chromeos/settings/owner_flags_storage.h" | 40 #include "chrome/browser/chromeos/settings/owner_flags_storage.h" |
42 #include "chromeos/dbus/dbus_thread_manager.h" | 41 #include "chromeos/dbus/dbus_thread_manager.h" |
43 #include "chromeos/dbus/session_manager_client.h" | 42 #include "chromeos/dbus/session_manager_client.h" |
44 #include "components/pref_registry/pref_registry_syncable.h" | 43 #include "components/pref_registry/pref_registry_syncable.h" |
| 44 #include "components/user_manager/user_manager.h" |
45 #endif | 45 #endif |
46 | 46 |
47 using content::WebContents; | 47 using content::WebContents; |
48 using content::WebUIMessageHandler; | 48 using content::WebUIMessageHandler; |
49 | 49 |
50 namespace { | 50 namespace { |
51 | 51 |
52 content::WebUIDataSource* CreateFlagsUIHTMLSource() { | 52 content::WebUIDataSource* CreateFlagsUIHTMLSource() { |
53 content::WebUIDataSource* source = | 53 content::WebUIDataSource* source = |
54 content::WebUIDataSource::Create(chrome::kChromeUIFlagsHost); | 54 content::WebUIDataSource::Create(chrome::kChromeUIFlagsHost); |
(...skipping 13 matching lines...) Expand all Loading... |
68 source->AddLocalizedString("flagsNoUnsupportedExperiments", | 68 source->AddLocalizedString("flagsNoUnsupportedExperiments", |
69 IDS_FLAGS_NO_UNSUPPORTED_EXPERIMENTS); | 69 IDS_FLAGS_NO_UNSUPPORTED_EXPERIMENTS); |
70 source->AddLocalizedString("flagsNotSupported", IDS_FLAGS_NOT_AVAILABLE); | 70 source->AddLocalizedString("flagsNotSupported", IDS_FLAGS_NOT_AVAILABLE); |
71 source->AddLocalizedString("flagsRestartNotice", IDS_FLAGS_RELAUNCH_NOTICE); | 71 source->AddLocalizedString("flagsRestartNotice", IDS_FLAGS_RELAUNCH_NOTICE); |
72 source->AddLocalizedString("flagsRestartButton", IDS_FLAGS_RELAUNCH_BUTTON); | 72 source->AddLocalizedString("flagsRestartButton", IDS_FLAGS_RELAUNCH_BUTTON); |
73 source->AddLocalizedString("resetAllButton", IDS_FLAGS_RESET_ALL_BUTTON); | 73 source->AddLocalizedString("resetAllButton", IDS_FLAGS_RESET_ALL_BUTTON); |
74 source->AddLocalizedString("disable", IDS_FLAGS_DISABLE); | 74 source->AddLocalizedString("disable", IDS_FLAGS_DISABLE); |
75 source->AddLocalizedString("enable", IDS_FLAGS_ENABLE); | 75 source->AddLocalizedString("enable", IDS_FLAGS_ENABLE); |
76 | 76 |
77 #if defined(OS_CHROMEOS) | 77 #if defined(OS_CHROMEOS) |
78 if (!chromeos::UserManager::Get()->IsCurrentUserOwner() && | 78 if (!user_manager::UserManager::Get()->IsCurrentUserOwner() && |
79 base::SysInfo::IsRunningOnChromeOS()) { | 79 base::SysInfo::IsRunningOnChromeOS()) { |
80 // Set the strings to show which user can actually change the flags. | 80 // Set the strings to show which user can actually change the flags. |
81 std::string owner; | 81 std::string owner; |
82 chromeos::CrosSettings::Get()->GetString(chromeos::kDeviceOwner, &owner); | 82 chromeos::CrosSettings::Get()->GetString(chromeos::kDeviceOwner, &owner); |
83 source->AddString("ownerWarning", | 83 source->AddString("ownerWarning", |
84 l10n_util::GetStringFUTF16(IDS_SYSTEM_FLAGS_OWNER_ONLY, | 84 l10n_util::GetStringFUTF16(IDS_SYSTEM_FLAGS_OWNER_ONLY, |
85 base::UTF8ToUTF16(owner))); | 85 base::UTF8ToUTF16(owner))); |
86 } else { | 86 } else { |
87 // The warning will be only shown on ChromeOS, when the current user is not | 87 // The warning will be only shown on ChromeOS, when the current user is not |
88 // the owner. | 88 // the owner. |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
224 // On ChromeOS be less intrusive and restart inside the user session after | 224 // On ChromeOS be less intrusive and restart inside the user session after |
225 // we apply the newly selected flags. | 225 // we apply the newly selected flags. |
226 CommandLine user_flags(CommandLine::NO_PROGRAM); | 226 CommandLine user_flags(CommandLine::NO_PROGRAM); |
227 about_flags::ConvertFlagsToSwitches(flags_storage_.get(), | 227 about_flags::ConvertFlagsToSwitches(flags_storage_.get(), |
228 &user_flags, | 228 &user_flags, |
229 about_flags::kAddSentinels); | 229 about_flags::kAddSentinels); |
230 CommandLine::StringVector flags; | 230 CommandLine::StringVector flags; |
231 // argv[0] is the program name |CommandLine::NO_PROGRAM|. | 231 // argv[0] is the program name |CommandLine::NO_PROGRAM|. |
232 flags.assign(user_flags.argv().begin() + 1, user_flags.argv().end()); | 232 flags.assign(user_flags.argv().begin() + 1, user_flags.argv().end()); |
233 VLOG(1) << "Restarting to apply per-session flags..."; | 233 VLOG(1) << "Restarting to apply per-session flags..."; |
234 chromeos::DBusThreadManager::Get()->GetSessionManagerClient()-> | 234 chromeos::DBusThreadManager::Get() |
235 SetFlagsForUser(chromeos::UserManager::Get()->GetActiveUser()->email(), | 235 ->GetSessionManagerClient() |
236 flags); | 236 ->SetFlagsForUser( |
| 237 user_manager::UserManager::Get()->GetActiveUser()->email(), flags); |
237 #endif | 238 #endif |
238 chrome::AttemptRestart(); | 239 chrome::AttemptRestart(); |
239 } | 240 } |
240 | 241 |
241 void FlagsDOMHandler::HandleResetAllFlags(const base::ListValue* args) { | 242 void FlagsDOMHandler::HandleResetAllFlags(const base::ListValue* args) { |
242 DCHECK(flags_storage_); | 243 DCHECK(flags_storage_); |
243 about_flags::ResetAllFlags(flags_storage_.get()); | 244 about_flags::ResetAllFlags(flags_storage_.get()); |
244 } | 245 } |
245 | 246 |
246 | 247 |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
328 } | 329 } |
329 | 330 |
330 #if defined(OS_CHROMEOS) | 331 #if defined(OS_CHROMEOS) |
331 // static | 332 // static |
332 void FlagsUI::RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry) { | 333 void FlagsUI::RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry) { |
333 registry->RegisterListPref(prefs::kEnabledLabsExperiments, | 334 registry->RegisterListPref(prefs::kEnabledLabsExperiments, |
334 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); | 335 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
335 } | 336 } |
336 | 337 |
337 #endif | 338 #endif |
OLD | NEW |