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

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: actually fix CrOS compile error + review comments 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" 24 #include "chrome/browser/ui/host_desktop.h"
Miranda Callahan 2013/07/09 14:49:33 You can probably remove host_desktop here.
noms 2013/07/09 15:36:05 Done.
25 #include "chrome/browser/ui/startup/startup_types.h" 25 #include "chrome/browser/ui/startup/startup_types.h"
Miranda Callahan 2013/07/09 14:49:33 Looks like you may be able to remove startup_types
noms 2013/07/09 15:36:05 Done.
26 #include "content/public/browser/notification_observer.h" 26 #include "content/public/browser/notification_observer.h"
27 #include "content/public/browser/notification_registrar.h" 27 #include "content/public/browser/notification_registrar.h"
28 28
29 class CommandLine; 29 class CommandLine;
30 class NewProfileLauncher; 30 class NewProfileLauncher;
31 class ProfileInfoCache; 31 class ProfileInfoCache;
32 32
33 class ProfileManager : public base::NonThreadSafe, 33 class ProfileManager : public base::NonThreadSafe,
34 public content::NotificationObserver, 34 public content::NotificationObserver,
35 public Profile::Delegate { 35 public Profile::Delegate {
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 const content::NotificationSource& source, 143 const content::NotificationSource& source,
144 const content::NotificationDetails& details) OVERRIDE; 144 const content::NotificationDetails& details) OVERRIDE;
145 145
146 // Indicate that an import process will run for the next created Profile. 146 // Indicate that an import process will run for the next created Profile.
147 void SetWillImport(); 147 void SetWillImport();
148 bool will_import() { return will_import_; } 148 bool will_import() { return will_import_; }
149 149
150 // Indicate that the import process for |profile| has completed. 150 // Indicate that the import process for |profile| has completed.
151 void OnImportFinished(Profile* profile); 151 void OnImportFinished(Profile* profile);
152 152
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, 153 // If a profile with the given path is currently managed by this object,
164 // return a pointer to the corresponding Profile object; 154 // return a pointer to the corresponding Profile object;
165 // otherwise return NULL. 155 // otherwise return NULL.
166 Profile* GetProfileByPath(const base::FilePath& path) const; 156 Profile* GetProfileByPath(const base::FilePath& path) const;
167 157
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: 158 // Profile::Delegate implementation:
182 virtual void OnProfileCreated(Profile* profile, 159 virtual void OnProfileCreated(Profile* profile,
183 bool success, 160 bool success,
184 bool is_new_profile) OVERRIDE; 161 bool is_new_profile) OVERRIDE;
185 162
186 // Add or remove a profile launcher to/from the list of launchers waiting for 163 // 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. 164 // new profiles to be created from the multi-profile menu.
188 void AddProfileLauncher(NewProfileLauncher* profile_launcher); 165 void AddProfileLauncher(NewProfileLauncher* profile_launcher);
189 void RemoveProfileLauncher(NewProfileLauncher* profile_launcher); 166 void RemoveProfileLauncher(NewProfileLauncher* profile_launcher);
190 167
191 // Creates a new profile in the next available multiprofile directory. 168 // Creates a new profile in the next available multiprofile directory.
192 // Directories are named "profile_1", "profile_2", etc., in sequence of 169 // Directories are named "profile_1", "profile_2", etc., in sequence of
193 // creation. (Because directories can be removed, however, it may be the case 170 // 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.) 171 // that at some point the list of numbered profiles is not continuous.)
195 // |callback| may be invoked multiple times (for CREATE_STATUS_INITIALIZED 172 // |callback| may be invoked multiple times (for CREATE_STATUS_INITIALIZED
196 // and CREATE_STATUS_CREATED) so binding parameters with bind::Passed() is 173 // and CREATE_STATUS_CREATED) so binding parameters with bind::Passed() is
197 // prohibited. Returns the file path to the profile that will be created 174 // prohibited. Returns the file path to the profile that will be created
198 // asynchronously. 175 // asynchronously.
199 static base::FilePath CreateMultiProfileAsync( 176 static base::FilePath CreateMultiProfileAsync(
200 const string16& name, 177 const string16& name,
201 const string16& icon_url, 178 const string16& icon_url,
202 const CreateCallback& callback, 179 const CreateCallback& callback,
203 bool is_managed); 180 bool is_managed);
204 181
205 // Register multi-profile related preferences in Local State.
206 static void RegisterPrefs(PrefRegistrySimple* registry);
207
208 // Returns a ProfileInfoCache object which can be used to get information 182 // Returns a ProfileInfoCache object which can be used to get information
209 // about profiles without having to load them from disk. 183 // about profiles without having to load them from disk.
210 ProfileInfoCache& GetProfileInfoCache(); 184 ProfileInfoCache& GetProfileInfoCache();
211 185
212 // Returns a ProfileShortcut Manager that enables the caller to create 186 // Returns a ProfileShortcut Manager that enables the caller to create
213 // profile specfic desktop shortcuts. 187 // profile specfic desktop shortcuts.
214 ProfileShortcutManager* profile_shortcut_manager(); 188 ProfileShortcutManager* profile_shortcut_manager();
215 189
216 // Schedules the profile at the given path to be deleted on shutdown. If we're 190 // Schedules the profile at the given path to be deleted on shutdown. If we're
217 // deleting the last profile, a new one will be created in its place, and in 191 // deleting the last profile, a new one will be created in its place, and in
218 // that case the callback will be called when profile creation is complete. 192 // that case the callback will be called when profile creation is complete.
219 void ScheduleProfileForDeletion(const base::FilePath& profile_dir, 193 void ScheduleProfileForDeletion(const base::FilePath& profile_dir,
220 const CreateCallback& callback); 194 const CreateCallback& callback);
221 195
222 // Checks if multiple profiles is enabled.
223 static bool IsMultipleProfilesEnabled();
224
225 // Autoloads profiles if they are running background apps. 196 // Autoloads profiles if they are running background apps.
226 void AutoloadProfiles(); 197 void AutoloadProfiles();
227 198
228 // Sign-Out a profile against use until re-authentication. 199 // Sign-Out a profile against use until re-authentication.
229 void SignOutProfile(Profile* profile); 200 void SignOutProfile(Profile* profile);
230 201
231 // Register and add testing profile to the ProfileManager. Use ONLY in tests. 202 // Register and add testing profile to the ProfileManager. Use ONLY in tests.
232 // This allows the creation of Profiles outside of the standard creation path 203 // This allows the creation of Profiles outside of the standard creation path
233 // for testing. If |addToCache|, adds to ProfileInfoCache as well. 204 // for testing. If |addToCache|, adds to ProfileInfoCache as well.
234 // If |start_deferred_task_runners|, starts the deferred task runners. 205 // If |start_deferred_task_runners|, starts the deferred task runners.
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
401 class ProfileManagerWithoutInit : public ProfileManager { 372 class ProfileManagerWithoutInit : public ProfileManager {
402 public: 373 public:
403 explicit ProfileManagerWithoutInit(const base::FilePath& user_data_dir); 374 explicit ProfileManagerWithoutInit(const base::FilePath& user_data_dir);
404 375
405 protected: 376 protected:
406 virtual void DoFinalInitForServices(Profile*, bool) OVERRIDE {} 377 virtual void DoFinalInitForServices(Profile*, bool) OVERRIDE {}
407 virtual void DoFinalInitLogging(Profile*) OVERRIDE {} 378 virtual void DoFinalInitLogging(Profile*) OVERRIDE {}
408 }; 379 };
409 380
410 #endif // CHROME_BROWSER_PROFILES_PROFILE_MANAGER_H_ 381 #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