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 // Activates a window for |profile| on the desktop specified by
46 // |desktop_type|. If no such window yet exists, or if |always_create| is
47 // true, this first creates a new window, then activates
48 // that. If activating an exiting window and multiple windows exists then the
49 // window that was most recently active is activated. This is used for
50 // creation of a window from the multi-profile dropdown menu.
51 void FindOrCreateNewWindowForProfile(
53 chrome::startup::IsProcessStartup process_startup
,
54 chrome::startup::IsFirstRun is_first_run
,
55 chrome::HostDesktopType desktop_type
,
58 // Opens a Browser with the specified profile given by |path|.
59 // If |always_create| is true then a new window is created
60 // even if a window for that profile already exists. When the browser is
61 // opened, |callback| will be run if it isn't null.
63 void SwitchToProfile(const base::FilePath
& path
,
64 chrome::HostDesktopType desktop_type
,
66 ProfileManager::CreateCallback callback
,
67 ProfileMetrics::ProfileOpen metric
);
69 // Opens a Browser for the guest profile and runs |callback| if it isn't null.
70 void SwitchToGuestProfile(chrome::HostDesktopType desktop_type
,
71 ProfileManager::CreateCallback callback
);
73 // Returns true if |profile| has potential profile switch targets, ie there's at
74 // least one other profile available to switch to, not counting guest. This is
75 // the case when there are more than 1 profiles available or when there's only
76 // one and the current window is a guest window.
77 bool HasProfileSwitchTargets(Profile
* profile
);
79 // Creates a new profile from the next available profile directory, and
80 // opens a new browser window for the profile once it is ready. When the browser
81 // is opened, |callback| will be run if it isn't null.
82 void CreateAndSwitchToNewProfile(chrome::HostDesktopType desktop_type
,
83 ProfileManager::CreateCallback callback
,
84 ProfileMetrics::ProfileAdd metric
);
86 // Closes all browser windows that belong to the guest profile.
87 void CloseGuestProfileWindows();
89 // Closes all the browser windows for |profile| and opens the user manager.
90 void LockProfile(Profile
* profile
);
92 // Returns whether lock is available to this profile.
93 bool IsLockAvailable(Profile
* profile
);
95 // Creates or reuses the system profile needed by the user manager. Based on
96 // the value of |tutorial_mode|, the user manager can show a specific
97 // tutorial, or no tutorial at all. If a tutorial is not shown, then
98 // |profile_path_to_focus| could be used to specify which user should be
99 // focused. After a profile is opened from the user manager, perform
100 // |profile_open_action|. |callback| is run with the custom url to be displayed,
101 // as well as a pointer to the guest profile.
102 void CreateSystemProfileForUserManager(
103 const base::FilePath
& profile_path_to_focus
,
104 profiles::UserManagerTutorialMode tutorial_mode
,
105 profiles::UserManagerProfileSelected profile_open_action
,
106 const base::Callback
<void(Profile
*, const std::string
&)>& callback
);
108 // Based on the |profile| preferences, determines whether a user manager
109 // tutorial needs to be shown, and displays the user manager with or without
111 void ShowUserManagerMaybeWithTutorial(Profile
* profile
);
113 // Enables new profile management preview and shows the user manager tutorial.
114 void EnableNewProfileManagementPreview(Profile
* profile
);
116 // Disables new profile management preview and attempts to relaunch Chrome.
117 void DisableNewProfileManagementPreview(Profile
* profile
);
119 // Converts from modes in the avatar menu to modes understood by
120 // ProfileChooserView.
121 void BubbleViewModeFromAvatarBubbleMode(
122 BrowserWindow::AvatarBubbleMode mode
,
123 BubbleViewMode
* bubble_view_mode
,
124 TutorialMode
* tutorial_mode
);
126 // Returns true if the Welcome/Upgrade tutorial bubble should be shown to the
127 // user, false otherwise.
128 bool ShouldShowWelcomeUpgradeTutorial(
129 Profile
* profile
, TutorialMode tutorial_mode
);
131 // Returns true if the tutorial informing the user about right-click user
132 // switching should be shown, false otherwise.
133 bool ShouldShowRightClickTutorial(Profile
* profile
);
135 } // namespace profiles
137 #endif // CHROME_BROWSER_PROFILES_PROFILE_WINDOW_H_