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

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: '' 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 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 static bool IsMultipleProfilesEnabled(); 187 static bool IsMultipleProfilesEnabled();
184 188
185 // Autoloads profiles if they are running background apps. 189 // Autoloads profiles if they are running background apps.
186 void AutoloadProfiles(); 190 void AutoloadProfiles();
187 191
188 // Register and add testing profile to the ProfileManager. Use ONLY in tests. 192 // Register and add testing profile to the ProfileManager. Use ONLY in tests.
189 // This allows the creation of Profiles outside of the standard creation path 193 // This allows the creation of Profiles outside of the standard creation path
190 // for testing. If |addToCache|, add to ProfileInfoCache as well. 194 // for testing. If |addToCache|, add to ProfileInfoCache as well.
191 void RegisterTestingProfile(Profile* profile, bool addToCache); 195 void RegisterTestingProfile(Profile* profile, bool addToCache);
192 196
197 #if defined(OS_WIN)
198 // Remove the shortcut manager for testing.
199 void RemoveProfileShortcutManagerForTesting();
200 #endif
201
193 const FilePath& user_data_dir() const { return user_data_dir_; } 202 const FilePath& user_data_dir() const { return user_data_dir_; }
194 203
195 protected: 204 protected:
196 // Does final initial actions. 205 // Does final initial actions.
197 virtual void DoFinalInit(Profile* profile, bool go_off_the_record); 206 virtual void DoFinalInit(Profile* profile, bool go_off_the_record);
198 virtual void DoFinalInitForServices(Profile* profile, bool go_off_the_record); 207 virtual void DoFinalInitForServices(Profile* profile, bool go_off_the_record);
199 virtual void DoFinalInitLogging(Profile* profile); 208 virtual void DoFinalInitLogging(Profile* profile);
200 209
201 // Creates a new profile. Virtual so that unittests can return TestingProfile. 210 // Creates a new profile. Virtual so that unittests can return TestingProfile.
202 virtual Profile* CreateProfile(const FilePath& path); 211 virtual Profile* CreateProfile(const FilePath& path);
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
236 ProfileInfo* RegisterProfile(Profile* profile, bool created); 245 ProfileInfo* RegisterProfile(Profile* profile, bool created);
237 246
238 typedef std::pair<FilePath, string16> ProfilePathAndName; 247 typedef std::pair<FilePath, string16> ProfilePathAndName;
239 typedef std::vector<ProfilePathAndName> ProfilePathAndNames; 248 typedef std::vector<ProfilePathAndName> ProfilePathAndNames;
240 ProfilePathAndNames GetSortedProfilesFromDirectoryMap(); 249 ProfilePathAndNames GetSortedProfilesFromDirectoryMap();
241 250
242 static bool CompareProfilePathAndName( 251 static bool CompareProfilePathAndName(
243 const ProfileManager::ProfilePathAndName& pair1, 252 const ProfileManager::ProfilePathAndName& pair1,
244 const ProfileManager::ProfilePathAndName& pair2); 253 const ProfileManager::ProfilePathAndName& pair2);
245 254
246 // Adds |profile| to the profile info cache if it's not already there. 255 // Adds |profile| to the profile info cache if it hasn't been added yet.
247 void AddProfileToCache(Profile* profile); 256 void AddProfileToCache(Profile* profile);
248 257
249 // For ChromeOS, determines if profile should be otr. 258 // For ChromeOS, determines if profile should be otr.
250 bool ShouldGoOffTheRecord(); 259 bool ShouldGoOffTheRecord();
251 260
252 // Get the path of the next profile directory and increment the internal 261 // Get the path of the next profile directory and increment the internal
253 // count. 262 // count.
254 // Lack of side effects: 263 // Lack of side effects:
255 // This function doesn't actually create the directory or touch the file 264 // This function doesn't actually create the directory or touch the file
256 // system. 265 // system.
257 FilePath GenerateNextProfileDirectoryPath(); 266 FilePath GenerateNextProfileDirectoryPath();
258 267
259 content::NotificationRegistrar registrar_; 268 content::NotificationRegistrar registrar_;
260 269
261 // The path to the user data directory (DIR_USER_DATA). 270 // The path to the user data directory (DIR_USER_DATA).
262 const FilePath user_data_dir_; 271 const FilePath user_data_dir_;
263 272
264 // Indicates that a user has logged in and that the profile specified 273 // 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 274 // in the --login-profile command line argument should be used as the
266 // default. 275 // default.
267 bool logged_in_; 276 bool logged_in_;
268 277
269 // True if an import process will be run. 278 // True if an import process will be run.
270 bool will_import_; 279 bool will_import_;
271 280
272 // Maps profile path to ProfileInfo (if profile has been created). Use 281 // Maps profile path to ProfileInfo (if profile has been created). Use
273 // RegisterProfile() to add into this map. 282 // RegisterProfile() to add into this map. This map owns all loaded profile
283 // objects in a running instance of Chrome.
274 typedef std::map<FilePath, linked_ptr<ProfileInfo> > ProfilesInfoMap; 284 typedef std::map<FilePath, linked_ptr<ProfileInfo> > ProfilesInfoMap;
275 ProfilesInfoMap profiles_info_; 285 ProfilesInfoMap profiles_info_;
276 286
277 // Object to cache various information about profiles. 287 // Object to cache various information about profiles. Contains information
288 // about every profile which has been created for this instance of Chrome,
Robert Sesek 2011/11/21 16:00:37 über-nit: s/which/that
Miranda Callahan 2011/11/21 18:19:52 From The Chicago Manual of Style Online (http://ww
Robert Sesek 2011/11/21 18:29:33 I _guess_ I can let it slide, if you really want t
289 // if it has not been explicitly deleted.
278 scoped_ptr<ProfileInfoCache> profile_info_cache_; 290 scoped_ptr<ProfileInfoCache> profile_info_cache_;
279 291
292 #if defined(OS_WIN)
293 // Manages the creation, deletion, and renaming of Windows shortcuts by
294 // observing the ProfileInfoCache.
295 scoped_ptr<ProfileShortcutManagerWin> profile_shortcut_manager_;
296 #endif
297
280 DISALLOW_COPY_AND_ASSIGN(ProfileManager); 298 DISALLOW_COPY_AND_ASSIGN(ProfileManager);
281 }; 299 };
282 300
283 // Same as the ProfileManager, but doesn't initialize some services of the 301 // Same as the ProfileManager, but doesn't initialize some services of the
284 // profile. This one is useful in unittests. 302 // profile. This one is useful in unittests.
285 class ProfileManagerWithoutInit : public ProfileManager { 303 class ProfileManagerWithoutInit : public ProfileManager {
286 public: 304 public:
287 explicit ProfileManagerWithoutInit(const FilePath& user_data_dir); 305 explicit ProfileManagerWithoutInit(const FilePath& user_data_dir);
288 306
289 protected: 307 protected:
290 virtual void DoFinalInitForServices(Profile*, bool) OVERRIDE {} 308 virtual void DoFinalInitForServices(Profile*, bool) OVERRIDE {}
291 virtual void DoFinalInitLogging(Profile*) OVERRIDE {} 309 virtual void DoFinalInitLogging(Profile*) OVERRIDE {}
292 }; 310 };
293 311
294 #endif // CHROME_BROWSER_PROFILES_PROFILE_MANAGER_H_ 312 #endif // CHROME_BROWSER_PROFILES_PROFILE_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698