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

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

Issue 8502033: Add Windows desktop shortcut for multiple profiles. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: change construction of First User profile launcher Created 9 years, 1 month 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 #pragma once 9 #pragma once
10 10
11 #include <list> 11 #include <list>
12 #include <vector> 12 #include <vector>
13 13
14 #include "base/basictypes.h" 14 #include "base/basictypes.h"
15 #include "base/file_path.h" 15 #include "base/file_path.h"
16 #include "base/hash_tables.h" 16 #include "base/hash_tables.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/ui/browser_init.h" 22 #include "chrome/browser/ui/browser_init.h"
23 #include "chrome/browser/ui/browser_list.h" 23 #include "chrome/browser/ui/browser_list.h"
24 #include "content/public/browser/notification_observer.h" 24 #include "content/public/browser/notification_observer.h"
25 #include "content/public/browser/notification_registrar.h" 25 #include "content/public/browser/notification_registrar.h"
26 26
27 #if defined(OS_WIN)
28 #include "chrome/browser/profiles/profile_shortcut_manager_win.h"
29 #endif
30
27 class NewProfileLauncher; 31 class NewProfileLauncher;
28 class ProfileInfoCache; 32 class ProfileInfoCache;
29 33
30 class ProfileManagerObserver { 34 class ProfileManagerObserver {
31 public: 35 public:
32 enum Status { 36 enum Status {
33 // So epic. 37 // Asynchronous Profile services were not created.
34 STATUS_FAIL, 38 STATUS_FAIL,
35 // Profile created but before initializing extensions and promo resources. 39 // Profile created but before initializing extensions and promo resources.
36 STATUS_CREATED, 40 STATUS_CREATED,
37 // Profile is created, extensions and promo resources are initialized. 41 // Profile is created, extensions and promo resources are initialized.
38 STATUS_INITIALIZED 42 STATUS_INITIALIZED
39 }; 43 };
40 44
41 // This method is called when profile is ready. If profile already exists, 45 // This method is called when profile is ready. If profile already exists,
42 // method is called with pointer to that profile and STATUS_INITIALIZED. 46 // method is called with pointer to that profile and STATUS_INITIALIZED.
43 // If profile creation has failed, method is called with |profile| equal to 47 // If profile creation has failed, method is called with |profile| equal to
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
236 ProfileInfo* RegisterProfile(Profile* profile, bool created); 240 ProfileInfo* RegisterProfile(Profile* profile, bool created);
237 241
238 typedef std::pair<FilePath, string16> ProfilePathAndName; 242 typedef std::pair<FilePath, string16> ProfilePathAndName;
239 typedef std::vector<ProfilePathAndName> ProfilePathAndNames; 243 typedef std::vector<ProfilePathAndName> ProfilePathAndNames;
240 ProfilePathAndNames GetSortedProfilesFromDirectoryMap(); 244 ProfilePathAndNames GetSortedProfilesFromDirectoryMap();
241 245
242 static bool CompareProfilePathAndName( 246 static bool CompareProfilePathAndName(
243 const ProfileManager::ProfilePathAndName& pair1, 247 const ProfileManager::ProfilePathAndName& pair1,
244 const ProfileManager::ProfilePathAndName& pair2); 248 const ProfileManager::ProfilePathAndName& pair2);
245 249
246 // Adds |profile| to the profile info cache if it's not already there. 250 // Adds |profile| to the profile info cache if it hasn't been added yet.
247 void AddProfileToCache(Profile* profile); 251 void AddProfileToCache(Profile* profile);
248 252
249 // For ChromeOS, determines if profile should be otr. 253 // For ChromeOS, determines if profile should be otr.
250 bool ShouldGoOffTheRecord(); 254 bool ShouldGoOffTheRecord();
251 255
252 // Get the path of the next profile directory and increment the internal 256 // Get the path of the next profile directory and increment the internal
253 // count. 257 // count.
254 // Lack of side effects: 258 // Lack of side effects:
255 // This function doesn't actually create the directory or touch the file 259 // This function doesn't actually create the directory or touch the file
256 // system. 260 // system.
257 FilePath GenerateNextProfileDirectoryPath(); 261 FilePath GenerateNextProfileDirectoryPath();
258 262
259 content::NotificationRegistrar registrar_; 263 content::NotificationRegistrar registrar_;
260 264
261 // The path to the user data directory (DIR_USER_DATA). 265 // The path to the user data directory (DIR_USER_DATA).
262 const FilePath user_data_dir_; 266 const FilePath user_data_dir_;
263 267
264 // Indicates that a user has logged in and that the profile specified 268 // Indicates that a user has logged in and that the profile specified
265 // in the --login-profile command line argument should be used as the 269 // in the --login-profile command line argument should be used as the
266 // default. 270 // default.
267 bool logged_in_; 271 bool logged_in_;
268 272
269 // True if an import process will be run. 273 // True if an import process will be run.
270 bool will_import_; 274 bool will_import_;
271 275
272 // Maps profile path to ProfileInfo (if profile has been created). Use 276 // Maps profile path to ProfileInfo (if profile has been created). Use
273 // RegisterProfile() to add into this map. 277 // RegisterProfile() to add into this map. This map owns all loaded profile
278 // objects in a running instance of Chrome.
274 typedef std::map<FilePath, linked_ptr<ProfileInfo> > ProfilesInfoMap; 279 typedef std::map<FilePath, linked_ptr<ProfileInfo> > ProfilesInfoMap;
275 ProfilesInfoMap profiles_info_; 280 ProfilesInfoMap profiles_info_;
276 281
277 // Object to cache various information about profiles. 282 // Object to cache various information about profiles. Contains information
283 // about every profile which has been created for this instance of Chrome,
284 // if it has not been explicitly deleted.
278 scoped_ptr<ProfileInfoCache> profile_info_cache_; 285 scoped_ptr<ProfileInfoCache> profile_info_cache_;
279 286
287 #if defined(OS_WIN)
288 // Manages the creation, deletion, and renaming of Windows shortcuts by
289 // observing the ProfileInfoCache.
290 scoped_ptr<ProfileShortcutManagerWin> profile_shortcut_manager_;
291 #endif
292
280 DISALLOW_COPY_AND_ASSIGN(ProfileManager); 293 DISALLOW_COPY_AND_ASSIGN(ProfileManager);
281 }; 294 };
282 295
283 // Same as the ProfileManager, but doesn't initialize some services of the 296 // Same as the ProfileManager, but doesn't initialize some services of the
284 // profile. This one is useful in unittests. 297 // profile. This one is useful in unittests.
285 class ProfileManagerWithoutInit : public ProfileManager { 298 class ProfileManagerWithoutInit : public ProfileManager {
286 public: 299 public:
287 explicit ProfileManagerWithoutInit(const FilePath& user_data_dir); 300 explicit ProfileManagerWithoutInit(const FilePath& user_data_dir);
288 301
289 protected: 302 protected:
290 virtual void DoFinalInitForServices(Profile*, bool) OVERRIDE {} 303 virtual void DoFinalInitForServices(Profile*, bool) OVERRIDE {}
291 virtual void DoFinalInitLogging(Profile*) OVERRIDE {} 304 virtual void DoFinalInitLogging(Profile*) OVERRIDE {}
292 }; 305 };
293 306
294 #endif // CHROME_BROWSER_PROFILES_PROFILE_MANAGER_H_ 307 #endif // CHROME_BROWSER_PROFILES_PROFILE_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698