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
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_PROFILES_PROFILE_WINDOW_H_
6 #define CHROME_BROWSER_PROFILES_PROFILE_WINDOW_H_
8 #include "base/callback_forward.h"
9 #include "chrome/browser/profiles/profile_manager.h"
10 #include "chrome/browser/profiles/profile_metrics.h"
11 #include "chrome/browser/ui/browser_window.h"
12 #include "chrome/browser/ui/host_desktop.h"
13 #include "chrome/browser/ui/profile_chooser_constants.h"
14 #include "chrome/browser/ui/startup/startup_types.h"
17 namespace base
{ class FilePath
; }
21 // Different tutorials that can be displayed in the user manager.
22 enum UserManagerTutorialMode
{
23 USER_MANAGER_NO_TUTORIAL
, // Does not display a tutorial.
24 USER_MANAGER_TUTORIAL_OVERVIEW
, // Basic overview of new features.
25 USER_MANAGER_TUTORIAL_LOCK
, // TODO(noms): To be implemented.
28 // Different actions to perform after the user manager selects a profile.
29 enum UserManagerProfileSelected
{
30 USER_MANAGER_SELECT_PROFILE_NO_ACTION
,
31 USER_MANAGER_SELECT_PROFILE_TASK_MANAGER
,
32 USER_MANAGER_SELECT_PROFILE_ABOUT_CHROME
,
33 USER_MANAGER_SELECT_PROFILE_CHROME_SETTINGS
,
34 USER_MANAGER_SELECT_PROFILE_CHROME_MEMORY
,
35 USER_MANAGER_SELECT_PROFILE_APP_LAUNCHER
,
38 extern const char kUserManagerDisplayTutorial
[];
39 extern const char kUserManagerSelectProfileTaskManager
[];
40 extern const char kUserManagerSelectProfileAboutChrome
[];
41 extern const char kUserManagerSelectProfileChromeSettings
[];
42 extern const char kUserManagerSelectProfileChromeMemory
[];
43 extern const char kUserManagerSelectProfileAppLauncher
[];
45 // Returns the path of the profile connected to the given email. If no profile
46 // is found an empty file path is returned.
47 base::FilePath
GetPathOfProfileWithEmail(ProfileManager
* profile_manager
,
48 const std::string
& email
);
50 // Activates a window for |profile| on the desktop specified by
51 // |desktop_type|. If no such window yet exists, or if |always_create| is
52 // true, this first creates a new window, then activates
53 // that. If activating an exiting window and multiple windows exists then the
54 // window that was most recently active is activated. This is used for
55 // creation of a window from the multi-profile dropdown menu.
56 void FindOrCreateNewWindowForProfile(
58 chrome::startup::IsProcessStartup process_startup
,
59 chrome::startup::IsFirstRun is_first_run
,
60 chrome::HostDesktopType desktop_type
,
63 // Opens a Browser with the specified profile given by |path|.
64 // If |always_create| is true then a new window is created
65 // even if a window for that profile already exists. When the browser is
66 // opened, |callback| will be run if it isn't null.
68 void SwitchToProfile(const base::FilePath
& path
,
69 chrome::HostDesktopType desktop_type
,
71 ProfileManager::CreateCallback callback
,
72 ProfileMetrics::ProfileOpen metric
);
74 // Opens a Browser for the guest profile and runs |callback| if it isn't null.
75 void SwitchToGuestProfile(chrome::HostDesktopType desktop_type
,
76 ProfileManager::CreateCallback callback
);
78 // Returns true if |profile| has potential profile switch targets, ie there's at
79 // least one other profile available to switch to, not counting guest. This is
80 // the case when there are more than 1 profiles available or when there's only
81 // one and the current window is a guest window.
82 bool HasProfileSwitchTargets(Profile
* profile
);
84 // Creates a new profile from the next available profile directory, and
85 // opens a new browser window for the profile once it is ready. When the browser
86 // is opened, |callback| will be run if it isn't null.
87 void CreateAndSwitchToNewProfile(chrome::HostDesktopType desktop_type
,
88 ProfileManager::CreateCallback callback
,
89 ProfileMetrics::ProfileAdd metric
);
91 // Closes all browser windows that belong to the guest profile.
92 void CloseGuestProfileWindows();
94 // Closes all the browser windows for |profile| and opens the user manager.
95 void LockProfile(Profile
* profile
);
97 // Returns whether lock is available to this profile.
98 bool IsLockAvailable(Profile
* profile
);
100 // Creates or reuses the system profile needed by the user manager. Based on
101 // the value of |tutorial_mode|, the user manager can show a specific
102 // tutorial, or no tutorial at all. If a tutorial is not shown, then
103 // |profile_path_to_focus| could be used to specify which user should be
104 // focused. After a profile is opened from the user manager, perform
105 // |profile_open_action|. |callback| is run with the custom url to be displayed,
106 // as well as a pointer to the guest profile.
107 void CreateSystemProfileForUserManager(
108 const base::FilePath
& profile_path_to_focus
,
109 profiles::UserManagerTutorialMode tutorial_mode
,
110 profiles::UserManagerProfileSelected profile_open_action
,
111 const base::Callback
<void(Profile
*, const std::string
&)>& callback
);
113 // Based on the |profile| preferences, determines whether a user manager
114 // tutorial needs to be shown, and displays the user manager with or without
116 void ShowUserManagerMaybeWithTutorial(Profile
* profile
);
118 // Enables new profile management preview and shows the user manager tutorial.
119 void EnableNewProfileManagementPreview(Profile
* profile
);
121 // Disables new profile management preview and attempts to relaunch Chrome.
122 void DisableNewProfileManagementPreview(Profile
* profile
);
124 // Converts from modes in the avatar menu to modes understood by
125 // ProfileChooserView.
126 void BubbleViewModeFromAvatarBubbleMode(
127 BrowserWindow::AvatarBubbleMode mode
,
128 BubbleViewMode
* bubble_view_mode
,
129 TutorialMode
* tutorial_mode
);
131 // Returns true if the Welcome/Upgrade tutorial bubble should be shown to the
132 // user, false otherwise.
133 bool ShouldShowWelcomeUpgradeTutorial(
134 Profile
* profile
, TutorialMode tutorial_mode
);
136 // Returns true if the tutorial informing the user about right-click user
137 // switching should be shown, false otherwise.
138 bool ShouldShowRightClickTutorial(Profile
* profile
);
140 } // namespace profiles
142 #endif // CHROME_BROWSER_PROFILES_PROFILE_WINDOW_H_