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

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

Issue 1128173005: Clean up ProfileManager interface. Base URL: https://chromium.googlesource.com/chromium/src@issue479309
Patch Set: sync Created 5 years, 6 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
« no previous file with comments | « chrome/browser/profiles/profile_android.cc ('k') | chrome/browser/profiles/profile_manager.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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>
(...skipping 26 matching lines...) Expand all
37 ~ProfileManager() override; 37 ~ProfileManager() override;
38 38
39 #if defined(ENABLE_SESSION_SERVICE) 39 #if defined(ENABLE_SESSION_SERVICE)
40 // Invokes SessionServiceFactory::ShutdownForProfile() for all profiles. 40 // Invokes SessionServiceFactory::ShutdownForProfile() for all profiles.
41 static void ShutdownSessionServices(); 41 static void ShutdownSessionServices();
42 #endif 42 #endif
43 43
44 // Physically remove deleted profile directories from disk. 44 // Physically remove deleted profile directories from disk.
45 static void NukeDeletedProfilesFromDisk(); 45 static void NukeDeletedProfilesFromDisk();
46 46
47 // Same as instance method but provides the default user_data_dir as well.
48 // If the Profile is going to be used to open a new window then consider using
49 // GetLastUsedProfileAllowedByPolicy() instead.
50 static Profile* GetLastUsedProfile();
51
52 // Same as GetLastUsedProfile() but returns the incognito Profile if
53 // incognito mode is forced. This should be used if the last used Profile
54 // will be used to open new browser windows.
55 static Profile* GetLastUsedProfileAllowedByPolicy();
56
57 // Same as instance method but provides the default user_data_dir as well.
58 static std::vector<Profile*> GetLastOpenedProfiles();
59
60 // Get the profile for the user which created the current session. 47 // Get the profile for the user which created the current session.
61 // Note that in case of a guest account this will return a 'suitable' profile. 48 // Note that in case of a guest account this will return a 'suitable' profile.
62 // This function is temporary and will soon be moved to ash. As such avoid 49 // This function is temporary and will soon be moved to ash. As such avoid
63 // using it at all cost. 50 // using it at all cost.
64 // TODO(skuhne): Move into ash's new user management function. 51 // TODO(skuhne): Move into ash's new user management function.
65 static Profile* GetPrimaryUserProfile(); 52 static Profile* GetPrimaryUserProfile();
66 53
67 // Get the profile for the currently active user. 54 // Get the profile for the currently active user.
68 // Note that in case of a guest account this will return a 'suitable' profile. 55 // Note that in case of a guest account this will return a 'suitable' profile.
69 // This function is temporary and will soon be moved to ash. As such avoid 56 // This function is temporary and will soon be moved to ash. As such avoid
(...skipping 27 matching lines...) Expand all
97 // profile. 84 // profile.
98 bool IsValidProfile(Profile* profile); 85 bool IsValidProfile(Profile* profile);
99 86
100 // Returns the directory where the first created profile is stored, 87 // Returns the directory where the first created profile is stored,
101 // relative to the user data directory currently in use. 88 // relative to the user data directory currently in use.
102 base::FilePath GetInitialProfileDir(); 89 base::FilePath GetInitialProfileDir();
103 90
104 // Get the Profile last used (the Profile to which owns the most recently 91 // Get the Profile last used (the Profile to which owns the most recently
105 // focused window) with this Chrome build. If no signed profile has been 92 // focused window) with this Chrome build. If no signed profile has been
106 // stored in Local State, hand back the Default profile. 93 // stored in Local State, hand back the Default profile.
107 Profile* GetLastUsedProfile(const base::FilePath& user_data_dir); 94 // If the Profile is going to be used to open a new window then consider using
95 // GetLastUsedProfileAllowedByPolicy() instead.
96 Profile* GetLastUsedProfile();
97
98 // Same as GetLastUsedProfile() but returns the incognito Profile if
99 // incognito mode is forced. This should be used if the last used Profile
100 // will be used to open new browser windows.
101 Profile* GetLastUsedProfileAllowedByPolicy();
108 102
109 // Get the path of the last used profile, or if that's undefined, the default 103 // Get the path of the last used profile, or if that's undefined, the default
110 // profile. 104 // profile.
111 base::FilePath GetLastUsedProfileDir(const base::FilePath& user_data_dir); 105 base::FilePath GetLastUsedProfileDir();
112 106
113 // Get the name of the last used profile, or if that's undefined, the default 107 // Get the name of the last used profile, or if that's undefined, the default
114 // profile. 108 // profile.
115 std::string GetLastUsedProfileName(); 109 std::string GetLastUsedProfileName();
116 110
117 // Get the Profiles which are currently open, i.e., have open browsers, or 111 // Get the Profiles which are currently open, i.e., have open browsers, or
118 // were open the last time Chrome was running. The Profiles appear in the 112 // were open the last time Chrome was running. The Profiles appear in the
119 // order they were opened. The last used profile will be on the list, but its 113 // order they were opened. The last used profile will be on the list, but its
120 // index on the list will depend on when it was opened (it is not necessarily 114 // index on the list will depend on when it was opened (it is not necessarily
121 // the last one). 115 // the last one).
122 std::vector<Profile*> GetLastOpenedProfiles( 116 std::vector<Profile*> GetLastOpenedProfiles();
123 const base::FilePath& user_data_dir);
124 117
125 // Returns created and fully initialized profiles. Note, profiles order is NOT 118 // Returns created and fully initialized profiles. Note, profiles order is NOT
126 // guaranteed to be related with the creation order. 119 // guaranteed to be related with the creation order.
127 std::vector<Profile*> GetLoadedProfiles() const; 120 std::vector<Profile*> GetLoadedProfiles() const;
128 121
129 // If a profile with the given path is currently managed by this object and 122 // If a profile with the given path is currently managed by this object and
130 // fully initialized, return a pointer to the corresponding Profile object; 123 // fully initialized, return a pointer to the corresponding Profile object;
131 // otherwise return null. 124 // otherwise return null.
132 Profile* GetProfileByPath(const base::FilePath& path) const; 125 Profile* GetProfileByPath(const base::FilePath& path) const;
133 126
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
245 238
246 private: 239 private:
247 DISALLOW_COPY_AND_ASSIGN(ProfileInfo); 240 DISALLOW_COPY_AND_ASSIGN(ProfileInfo);
248 }; 241 };
249 242
250 // Returns the profile of the active user and / or the off the record profile 243 // Returns the profile of the active user and / or the off the record profile
251 // if needed. This adds the profile to the ProfileManager if it doesn't 244 // if needed. This adds the profile to the ProfileManager if it doesn't
252 // already exist. The method will return NULL if the profile doesn't exist 245 // already exist. The method will return NULL if the profile doesn't exist
253 // and we can't create it. 246 // and we can't create it.
254 // The profile used can be overridden by using --login-profile on cros. 247 // The profile used can be overridden by using --login-profile on cros.
255 Profile* GetActiveUserOrOffTheRecordProfileFromPath( 248 Profile* GetActiveUserOrOffTheRecordProfileFromPath();
256 const base::FilePath& user_data_dir);
257 249
258 // Adds a pre-existing Profile object to the set managed by this 250 // Adds a pre-existing Profile object to the set managed by this
259 // ProfileManager. This ProfileManager takes ownership of the Profile. 251 // ProfileManager. This ProfileManager takes ownership of the Profile.
260 // The Profile should not already be managed by this ProfileManager. 252 // The Profile should not already be managed by this ProfileManager.
261 // Returns true if the profile was added, false otherwise. 253 // Returns true if the profile was added, false otherwise.
262 bool AddProfile(Profile* profile); 254 bool AddProfile(Profile* profile);
263 255
264 // Synchronously creates and returns a profile. This handles both the full 256 // Synchronously creates and returns a profile. This handles both the full
265 // creation and adds it to the set managed by this ProfileManager. 257 // creation and adds it to the set managed by this ProfileManager.
266 Profile* CreateAndInitializeProfile(const base::FilePath& profile_dir); 258 Profile* CreateAndInitializeProfile(const base::FilePath& profile_dir);
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
375 class ProfileManagerWithoutInit : public ProfileManager { 367 class ProfileManagerWithoutInit : public ProfileManager {
376 public: 368 public:
377 explicit ProfileManagerWithoutInit(const base::FilePath& user_data_dir); 369 explicit ProfileManagerWithoutInit(const base::FilePath& user_data_dir);
378 370
379 protected: 371 protected:
380 void DoFinalInitForServices(Profile*, bool) override {} 372 void DoFinalInitForServices(Profile*, bool) override {}
381 void DoFinalInitLogging(Profile*) override {} 373 void DoFinalInitLogging(Profile*) override {}
382 }; 374 };
383 375
384 #endif // CHROME_BROWSER_PROFILES_PROFILE_MANAGER_H_ 376 #endif // CHROME_BROWSER_PROFILES_PROFILE_MANAGER_H_
OLDNEW
« no previous file with comments | « chrome/browser/profiles/profile_android.cc ('k') | chrome/browser/profiles/profile_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698