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

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: rebase 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 // 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 180 // Returns a ProfileInfoCache object which can be used to get information
209 // about profiles without having to load them from disk. 181 // about profiles without having to load them from disk.
210 ProfileInfoCache& GetProfileInfoCache(); 182 ProfileInfoCache& GetProfileInfoCache();
211 183
212 // Returns a ProfileShortcut Manager that enables the caller to create 184 // Returns a ProfileShortcut Manager that enables the caller to create
213 // profile specfic desktop shortcuts. 185 // profile specfic desktop shortcuts.
214 ProfileShortcutManager* profile_shortcut_manager(); 186 ProfileShortcutManager* profile_shortcut_manager();
215 187
216 // Schedules the profile at the given path to be deleted on shutdown. If we're 188 // 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 189 // 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. 190 // that case the callback will be called when profile creation is complete.
219 void ScheduleProfileForDeletion(const base::FilePath& profile_dir, 191 void ScheduleProfileForDeletion(const base::FilePath& profile_dir,
220 const CreateCallback& callback); 192 const CreateCallback& callback);
221 193
222 // Checks if multiple profiles is enabled.
223 static bool IsMultipleProfilesEnabled();
224
225 // Autoloads profiles if they are running background apps. 194 // Autoloads profiles if they are running background apps.
226 void AutoloadProfiles(); 195 void AutoloadProfiles();
227 196
228 // Sign-Out a profile against use until re-authentication. 197 // Sign-Out a profile against use until re-authentication.
229 void SignOutProfile(Profile* profile); 198 void SignOutProfile(Profile* profile);
230 199
231 // Register and add testing profile to the ProfileManager. Use ONLY in tests. 200 // 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 201 // This allows the creation of Profiles outside of the standard creation path
233 // for testing. If |addToCache|, adds to ProfileInfoCache as well. 202 // for testing. If |addToCache|, adds to ProfileInfoCache as well.
234 // If |start_deferred_task_runners|, starts the deferred task runners. 203 // 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 { 370 class ProfileManagerWithoutInit : public ProfileManager {
402 public: 371 public:
403 explicit ProfileManagerWithoutInit(const base::FilePath& user_data_dir); 372 explicit ProfileManagerWithoutInit(const base::FilePath& user_data_dir);
404 373
405 protected: 374 protected:
406 virtual void DoFinalInitForServices(Profile*, bool) OVERRIDE {} 375 virtual void DoFinalInitForServices(Profile*, bool) OVERRIDE {}
407 virtual void DoFinalInitLogging(Profile*) OVERRIDE {} 376 virtual void DoFinalInitLogging(Profile*) OVERRIDE {}
408 }; 377 };
409 378
410 #endif // CHROME_BROWSER_PROFILES_PROFILE_MANAGER_H_ 379 #endif // CHROME_BROWSER_PROFILES_PROFILE_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698