| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/profiles/profile_window.h" | 5 #include "chrome/browser/profiles/profile_window.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/files/file_path.h" | 8 #include "base/files/file_path.h" |
| 9 #include "base/prefs/pref_service.h" | 9 #include "base/prefs/pref_service.h" |
| 10 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
| 11 #include "base/strings/utf_string_conversions.h" | 11 #include "base/strings/utf_string_conversions.h" |
| 12 #include "chrome/browser/about_flags.h" | 12 #include "chrome/browser/about_flags.h" |
| 13 #include "chrome/browser/browser_process.h" | 13 #include "chrome/browser/browser_process.h" |
| 14 #include "chrome/browser/lifetime/application_lifetime.h" |
| 14 #include "chrome/browser/pref_service_flags_storage.h" | 15 #include "chrome/browser/pref_service_flags_storage.h" |
| 15 #include "chrome/browser/profiles/profile.h" | 16 #include "chrome/browser/profiles/profile.h" |
| 16 #include "chrome/browser/profiles/profile_avatar_icon_util.h" | 17 #include "chrome/browser/profiles/profile_avatar_icon_util.h" |
| 17 #include "chrome/browser/profiles/profile_manager.h" | 18 #include "chrome/browser/profiles/profile_manager.h" |
| 18 #include "chrome/browser/ui/browser.h" | 19 #include "chrome/browser/ui/browser.h" |
| 19 #include "chrome/browser/ui/browser_dialogs.h" | 20 #include "chrome/browser/ui/browser_dialogs.h" |
| 20 #include "chrome/common/chrome_switches.h" | 21 #include "chrome/common/chrome_switches.h" |
| 21 #include "chrome/common/pref_names.h" | 22 #include "chrome/common/pref_names.h" |
| 22 #include "chrome/common/url_constants.h" | 23 #include "chrome/common/url_constants.h" |
| 23 #include "content/public/browser/browser_thread.h" | 24 #include "content/public/browser/browser_thread.h" |
| 24 #include "content/public/browser/user_metrics.h" | 25 #include "content/public/browser/user_metrics.h" |
| 25 | 26 |
| 26 #if !defined(OS_IOS) | 27 #if !defined(OS_IOS) |
| 27 #include "chrome/browser/ui/browser_finder.h" | 28 #include "chrome/browser/ui/browser_finder.h" |
| 28 #include "chrome/browser/ui/browser_list.h" | 29 #include "chrome/browser/ui/browser_list.h" |
| 29 #include "chrome/browser/ui/browser_list_observer.h" | 30 #include "chrome/browser/ui/browser_list_observer.h" |
| 30 #include "chrome/browser/ui/browser_window.h" | 31 #include "chrome/browser/ui/browser_window.h" |
| 31 #include "chrome/browser/ui/startup/startup_browser_creator.h" | 32 #include "chrome/browser/ui/startup/startup_browser_creator.h" |
| 32 #endif // !defined (OS_IOS) | 33 #endif // !defined (OS_IOS) |
| 33 | 34 |
| 34 using base::UserMetricsAction; | 35 using base::UserMetricsAction; |
| 35 using content::BrowserThread; | 36 using content::BrowserThread; |
| 36 | 37 |
| 37 namespace { | 38 namespace { |
| 38 | 39 |
| 40 const char kNewProfileManagementExperimentInternalName[] = |
| 41 "enable-new-profile-management"; |
| 42 |
| 39 // Handles running a callback when a new Browser for the given profile | 43 // Handles running a callback when a new Browser for the given profile |
| 40 // has been completely created. | 44 // has been completely created. |
| 41 class BrowserAddedForProfileObserver : public chrome::BrowserListObserver { | 45 class BrowserAddedForProfileObserver : public chrome::BrowserListObserver { |
| 42 public: | 46 public: |
| 43 BrowserAddedForProfileObserver( | 47 BrowserAddedForProfileObserver( |
| 44 Profile* profile, | 48 Profile* profile, |
| 45 profiles::ProfileSwitchingDoneCallback callback) | 49 profiles::ProfileSwitchingDoneCallback callback) |
| 46 : profile_(profile), | 50 : profile_(profile), |
| 47 callback_(callback) { | 51 callback_(callback) { |
| 48 DCHECK(!callback_.is_null()); | 52 DCHECK(!callback_.is_null()); |
| (...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 295 | 299 |
| 296 if (tutorial_shown) { | 300 if (tutorial_shown) { |
| 297 chrome::ShowUserManager(profile->GetPath()); | 301 chrome::ShowUserManager(profile->GetPath()); |
| 298 } else { | 302 } else { |
| 299 chrome::ShowUserManagerWithTutorial( | 303 chrome::ShowUserManagerWithTutorial( |
| 300 profiles::USER_MANAGER_TUTORIAL_OVERVIEW); | 304 profiles::USER_MANAGER_TUTORIAL_OVERVIEW); |
| 301 } | 305 } |
| 302 } | 306 } |
| 303 | 307 |
| 304 void EnableNewProfileManagementPreview() { | 308 void EnableNewProfileManagementPreview() { |
| 305 const char kNewProfileManagementExperimentInternalName[] = | |
| 306 "enable-new-profile-management"; | |
| 307 about_flags::PrefServiceFlagsStorage flags_storage( | 309 about_flags::PrefServiceFlagsStorage flags_storage( |
| 308 g_browser_process->local_state()); | 310 g_browser_process->local_state()); |
| 309 about_flags::SetExperimentEnabled( | 311 about_flags::SetExperimentEnabled( |
| 310 &flags_storage, | 312 &flags_storage, |
| 311 kNewProfileManagementExperimentInternalName, | 313 kNewProfileManagementExperimentInternalName, |
| 312 true); | 314 true); |
| 313 | 315 |
| 314 CommandLine::ForCurrentProcess()->AppendSwitch( | 316 CommandLine::ForCurrentProcess()->AppendSwitch( |
| 315 switches::kNewProfileManagement); | 317 switches::kNewProfileManagement); |
| 316 chrome::ShowUserManagerWithTutorial(profiles::USER_MANAGER_TUTORIAL_OVERVIEW); | 318 chrome::ShowUserManagerWithTutorial(profiles::USER_MANAGER_TUTORIAL_OVERVIEW); |
| 317 } | 319 } |
| 318 | 320 |
| 321 void DisableNewProfileManagementPreview() { |
| 322 about_flags::PrefServiceFlagsStorage flags_storage( |
| 323 g_browser_process->local_state()); |
| 324 about_flags::SetExperimentEnabled( |
| 325 &flags_storage, |
| 326 kNewProfileManagementExperimentInternalName, |
| 327 false); |
| 328 chrome::AttemptRestart(); |
| 329 } |
| 330 |
| 319 } // namespace profiles | 331 } // namespace profiles |
| OLD | NEW |