Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(319)

Side by Side Diff: chrome/browser/profiles/profile_manager.h

Issue 18615010: Refactor utility methods out of the ProfileManager (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: unbreak rebase and added new static fn from trunk Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 // This class keeps track of the currently-active profiles in the runtime. 5 // This class keeps track of the currently-active profiles in the runtime.
6 6
7 #ifndef CHROME_BROWSER_PROFILES_PROFILE_MANAGER_H_ 7 #ifndef CHROME_BROWSER_PROFILES_PROFILE_MANAGER_H_
8 #define CHROME_BROWSER_PROFILES_PROFILE_MANAGER_H_ 8 #define CHROME_BROWSER_PROFILES_PROFILE_MANAGER_H_
9 9
10 #include <list> 10 #include <list>
11 #include <vector> 11 #include <vector>
12 12
13 #include "base/basictypes.h" 13 #include "base/basictypes.h"
14 #include "base/containers/hash_tables.h" 14 #include "base/containers/hash_tables.h"
15 #include "base/files/file_path.h" 15 #include "base/files/file_path.h"
16 #include "base/gtest_prod_util.h" 16 #include "base/gtest_prod_util.h"
17 #include "base/memory/linked_ptr.h" 17 #include "base/memory/linked_ptr.h"
18 #include "base/memory/scoped_ptr.h" 18 #include "base/memory/scoped_ptr.h"
19 #include "base/message_loop.h" 19 #include "base/message_loop.h"
20 #include "base/threading/non_thread_safe.h" 20 #include "base/threading/non_thread_safe.h"
21 #include "chrome/browser/profiles/profile.h" 21 #include "chrome/browser/profiles/profile.h"
22 #include "chrome/browser/profiles/profile_shortcut_manager.h" 22 #include "chrome/browser/profiles/profile_shortcut_manager.h"
23 #include "chrome/browser/ui/browser_list_observer.h" 23 #include "chrome/browser/ui/browser_list_observer.h"
24 #include "chrome/browser/ui/host_desktop.h"
25 #include "chrome/browser/ui/startup/startup_types.h"
26 #include "content/public/browser/notification_observer.h" 24 #include "content/public/browser/notification_observer.h"
27 #include "content/public/browser/notification_registrar.h" 25 #include "content/public/browser/notification_registrar.h"
28 26
29 class CommandLine; 27 class CommandLine;
30 class NewProfileLauncher; 28 class NewProfileLauncher;
31 class ProfileInfoCache; 29 class ProfileInfoCache;
32 30
33 class ProfileManager : public base::NonThreadSafe, 31 class ProfileManager : public base::NonThreadSafe,
34 public content::NotificationObserver, 32 public content::NotificationObserver,
35 public Profile::Delegate { 33 public Profile::Delegate {
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 const content::NotificationSource& source, 141 const content::NotificationSource& source,
144 const content::NotificationDetails& details) OVERRIDE; 142 const content::NotificationDetails& details) OVERRIDE;
145 143
146 // Indicate that an import process will run for the next created Profile. 144 // Indicate that an import process will run for the next created Profile.
147 void SetWillImport(); 145 void SetWillImport();
148 bool will_import() { return will_import_; } 146 bool will_import() { return will_import_; }
149 147
150 // Indicate that the import process for |profile| has completed. 148 // Indicate that the import process for |profile| has completed.
151 void OnImportFinished(Profile* profile); 149 void OnImportFinished(Profile* profile);
152 150
153 // ------------------ static utility functions -------------------
154
155 // Returns the path to the default profile directory, based on the given
156 // user data directory.
157 static base::FilePath GetDefaultProfileDir(
158 const base::FilePath& user_data_dir);
159
160 // Returns the path to the preferences file given the user profile directory.
161 static base::FilePath GetProfilePrefsPath(const base::FilePath& profile_dir);
162
163 // If a profile with the given path is currently managed by this object, 151 // If a profile with the given path is currently managed by this object,
164 // return a pointer to the corresponding Profile object; 152 // return a pointer to the corresponding Profile object;
165 // otherwise return NULL. 153 // otherwise return NULL.
166 Profile* GetProfileByPath(const base::FilePath& path) const; 154 Profile* GetProfileByPath(const base::FilePath& path) const;
167 155
168 // Activates a window for |profile| on the desktop specified by
169 // |desktop_type|. If no such window yet exists, or if |always_create| is
170 // true, this first creates a new window, then activates
171 // that. If activating an exiting window and multiple windows exists then the
172 // window that was most recently active is activated. This is used for
173 // creation of a window from the multi-profile dropdown menu.
174 static void FindOrCreateNewWindowForProfile(
175 Profile* profile,
176 chrome::startup::IsProcessStartup process_startup,
177 chrome::startup::IsFirstRun is_first_run,
178 chrome::HostDesktopType desktop_type,
179 bool always_create);
180
181 // Profile::Delegate implementation: 156 // Profile::Delegate implementation:
182 virtual void OnProfileCreated(Profile* profile, 157 virtual void OnProfileCreated(Profile* profile,
183 bool success, 158 bool success,
184 bool is_new_profile) OVERRIDE; 159 bool is_new_profile) OVERRIDE;
185 160
186 // Add or remove a profile launcher to/from the list of launchers waiting for 161 // Add or remove a profile launcher to/from the list of launchers waiting for
187 // new profiles to be created from the multi-profile menu. 162 // new profiles to be created from the multi-profile menu.
188 void AddProfileLauncher(NewProfileLauncher* profile_launcher); 163 void AddProfileLauncher(NewProfileLauncher* profile_launcher);
189 void RemoveProfileLauncher(NewProfileLauncher* profile_launcher); 164 void RemoveProfileLauncher(NewProfileLauncher* profile_launcher);
190 165
191 // Creates a new profile in the next available multiprofile directory. 166 // Creates a new profile in the next available multiprofile directory.
192 // Directories are named "profile_1", "profile_2", etc., in sequence of 167 // Directories are named "profile_1", "profile_2", etc., in sequence of
193 // creation. (Because directories can be removed, however, it may be the case 168 // creation. (Because directories can be removed, however, it may be the case
194 // that at some point the list of numbered profiles is not continuous.) 169 // that at some point the list of numbered profiles is not continuous.)
195 // |callback| may be invoked multiple times (for CREATE_STATUS_INITIALIZED 170 // |callback| may be invoked multiple times (for CREATE_STATUS_INITIALIZED
196 // and CREATE_STATUS_CREATED) so binding parameters with bind::Passed() is 171 // and CREATE_STATUS_CREATED) so binding parameters with bind::Passed() is
197 // prohibited. Returns the file path to the profile that will be created 172 // prohibited. Returns the file path to the profile that will be created
198 // asynchronously. 173 // asynchronously.
199 static base::FilePath CreateMultiProfileAsync( 174 static base::FilePath CreateMultiProfileAsync(
200 const string16& name, 175 const string16& name,
201 const string16& icon_url, 176 const string16& icon_url,
202 const CreateCallback& callback, 177 const CreateCallback& callback,
203 bool is_managed); 178 bool is_managed);
204 179
205 // Returns the full path to be used for guest profiles. 180 // Returns the full path to be used for guest profiles.
206 static base::FilePath GetGuestProfilePath(); 181 static base::FilePath GetGuestProfilePath();
207 182
208 // Register multi-profile related preferences in Local State.
209 static void RegisterPrefs(PrefRegistrySimple* registry);
210
211 // Returns a ProfileInfoCache object which can be used to get information 183 // Returns a ProfileInfoCache object which can be used to get information
212 // about profiles without having to load them from disk. 184 // about profiles without having to load them from disk.
213 ProfileInfoCache& GetProfileInfoCache(); 185 ProfileInfoCache& GetProfileInfoCache();
214 186
215 // Returns a ProfileShortcut Manager that enables the caller to create 187 // Returns a ProfileShortcut Manager that enables the caller to create
216 // profile specfic desktop shortcuts. 188 // profile specfic desktop shortcuts.
217 ProfileShortcutManager* profile_shortcut_manager(); 189 ProfileShortcutManager* profile_shortcut_manager();
218 190
219 // Schedules the profile at the given path to be deleted on shutdown. If we're 191 // Schedules the profile at the given path to be deleted on shutdown. If we're
220 // deleting the last profile, a new one will be created in its place, and in 192 // deleting the last profile, a new one will be created in its place, and in
221 // that case the callback will be called when profile creation is complete. 193 // that case the callback will be called when profile creation is complete.
222 void ScheduleProfileForDeletion(const base::FilePath& profile_dir, 194 void ScheduleProfileForDeletion(const base::FilePath& profile_dir,
223 const CreateCallback& callback); 195 const CreateCallback& callback);
224 196
225 // Checks if multiple profiles is enabled.
226 static bool IsMultipleProfilesEnabled();
227
228 // Checks if new profile management is enabled.
229 static bool IsNewProfileManagementEnabled();
230
231 // Autoloads profiles if they are running background apps. 197 // Autoloads profiles if they are running background apps.
232 void AutoloadProfiles(); 198 void AutoloadProfiles();
233 199
234 // Sign-Out a profile against use until re-authentication. 200 // Sign-Out a profile against use until re-authentication.
235 void SignOutProfile(Profile* profile); 201 void SignOutProfile(Profile* profile);
236 202
237 // Register and add testing profile to the ProfileManager. Use ONLY in tests. 203 // Register and add testing profile to the ProfileManager. Use ONLY in tests.
238 // This allows the creation of Profiles outside of the standard creation path 204 // This allows the creation of Profiles outside of the standard creation path
239 // for testing. If |addToCache|, adds to ProfileInfoCache as well. 205 // for testing. If |addToCache|, adds to ProfileInfoCache as well.
240 // If |start_deferred_task_runners|, starts the deferred task runners. 206 // If |start_deferred_task_runners|, starts the deferred task runners.
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
407 class ProfileManagerWithoutInit : public ProfileManager { 373 class ProfileManagerWithoutInit : public ProfileManager {
408 public: 374 public:
409 explicit ProfileManagerWithoutInit(const base::FilePath& user_data_dir); 375 explicit ProfileManagerWithoutInit(const base::FilePath& user_data_dir);
410 376
411 protected: 377 protected:
412 virtual void DoFinalInitForServices(Profile*, bool) OVERRIDE {} 378 virtual void DoFinalInitForServices(Profile*, bool) OVERRIDE {}
413 virtual void DoFinalInitLogging(Profile*) OVERRIDE {} 379 virtual void DoFinalInitLogging(Profile*) OVERRIDE {}
414 }; 380 };
415 381
416 #endif // CHROME_BROWSER_PROFILES_PROFILE_MANAGER_H_ 382 #endif // CHROME_BROWSER_PROFILES_PROFILE_MANAGER_H_
OLDNEW
« no previous file with comments | « chrome/browser/profiles/avatar_menu_model_unittest.cc ('k') | chrome/browser/profiles/profile_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698