Upstream version 7.36.149.0
[platform/framework/web/crosswalk.git] / src / chrome / browser / profiles / profile_window.cc
index a3ac27a..ca62eea 100644 (file)
@@ -8,11 +8,17 @@
 #include "base/files/file_path.h"
 #include "base/prefs/pref_service.h"
 #include "base/strings/string_number_conversions.h"
+#include "base/strings/utf_string_conversions.h"
+#include "chrome/browser/about_flags.h"
 #include "chrome/browser/browser_process.h"
+#include "chrome/browser/lifetime/application_lifetime.h"
+#include "chrome/browser/pref_service_flags_storage.h"
 #include "chrome/browser/profiles/profile.h"
+#include "chrome/browser/profiles/profile_avatar_icon_util.h"
 #include "chrome/browser/profiles/profile_manager.h"
 #include "chrome/browser/ui/browser.h"
 #include "chrome/browser/ui/browser_dialogs.h"
+#include "chrome/common/chrome_switches.h"
 #include "chrome/common/pref_names.h"
 #include "chrome/common/url_constants.h"
 #include "content/public/browser/browser_thread.h"
@@ -31,6 +37,9 @@ using content::BrowserThread;
 
 namespace {
 
+const char kNewProfileManagementExperimentInternalName[] =
+    "enable-new-profile-management";
+
 // Handles running a callback when a new Browser for the given profile
 // has been completely created.
 class BrowserAddedForProfileObserver : public chrome::BrowserListObserver {
@@ -220,9 +229,14 @@ void SwitchToGuestProfile(chrome::HostDesktopType desktop_type,
 void CreateAndSwitchToNewProfile(chrome::HostDesktopType desktop_type,
                                  ProfileSwitchingDoneCallback callback,
                                  ProfileMetrics::ProfileAdd metric) {
+  ProfileInfoCache& cache =
+      g_browser_process->profile_manager()->GetProfileInfoCache();
+
+  int placeholder_avatar_index = profiles::GetPlaceholderAvatarIndex();
   ProfileManager::CreateMultiProfileAsync(
-      base::string16(),
-      base::string16(),
+      cache.ChooseNameForNewProfile(placeholder_avatar_index),
+      base::UTF8ToUTF16(profiles::GetDefaultAvatarIconUrl(
+          placeholder_avatar_index)),
       base::Bind(&OpenBrowserWindowForProfile,
                  callback,
                  true,
@@ -271,7 +285,8 @@ void CreateGuestProfileForUserManager(
 }
 
 void ShowUserManagerMaybeWithTutorial(Profile* profile) {
-  if (!profile) {
+  // Guest users cannot appear in the User Manager, nor display a tutorial.
+  if (!profile || profile->IsGuestSession()) {
     chrome::ShowUserManager(base::FilePath());
     return;
   }
@@ -290,4 +305,27 @@ void ShowUserManagerMaybeWithTutorial(Profile* profile) {
   }
 }
 
+void EnableNewProfileManagementPreview() {
+  about_flags::PrefServiceFlagsStorage flags_storage(
+      g_browser_process->local_state());
+  about_flags::SetExperimentEnabled(
+      &flags_storage,
+      kNewProfileManagementExperimentInternalName,
+      true);
+
+  CommandLine::ForCurrentProcess()->AppendSwitch(
+      switches::kNewProfileManagement);
+  chrome::ShowUserManagerWithTutorial(profiles::USER_MANAGER_TUTORIAL_OVERVIEW);
+}
+
+void DisableNewProfileManagementPreview() {
+  about_flags::PrefServiceFlagsStorage flags_storage(
+      g_browser_process->local_state());
+  about_flags::SetExperimentEnabled(
+      &flags_storage,
+      kNewProfileManagementExperimentInternalName,
+      false);
+  chrome::AttemptRestart();
+}
+
 }  // namespace profiles