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

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

Issue 10823217: Create/Delete windows profile shortcuts (Closed) Base URL: https://src.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 4 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/file_path.h" 14 #include "base/file_path.h"
15 #include "base/gtest_prod_util.h" 15 #include "base/gtest_prod_util.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_list_observer.h" 22 #include "chrome/browser/ui/browser_list_observer.h"
23 #include "chrome/browser/ui/startup/startup_types.h" 23 #include "chrome/browser/ui/startup/startup_types.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
31 class NewProfileLauncher; 27 class NewProfileLauncher;
32 class ProfileInfoCache; 28 class ProfileInfoCache;
33 29
34 class ProfileManager : public base::NonThreadSafe, 30 class ProfileManager : public base::NonThreadSafe,
35 public content::NotificationObserver, 31 public content::NotificationObserver,
36 public Profile::Delegate { 32 public Profile::Delegate {
37 public: 33 public:
38 typedef base::Callback<void(Profile*, Profile::CreateStatus)> CreateCallback; 34 typedef base::Callback<void(Profile*, Profile::CreateStatus)> CreateCallback;
39 35
40 explicit ProfileManager(const FilePath& user_data_dir); 36 explicit ProfileManager(const FilePath& user_data_dir);
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
202 // method. Virtual so that unittests can return a TestingProfile instead 198 // method. Virtual so that unittests can return a TestingProfile instead
203 // of the Profile's result. 199 // of the Profile's result.
204 virtual Profile* CreateProfileHelper(const FilePath& path); 200 virtual Profile* CreateProfileHelper(const FilePath& path);
205 201
206 // Creates a new profile asynchronously by calling into the profile's 202 // Creates a new profile asynchronously by calling into the profile's
207 // asynchronous profile creation method. Virtual so that unittests can return 203 // asynchronous profile creation method. Virtual so that unittests can return
208 // a TestingProfile instead of the Profile's result. 204 // a TestingProfile instead of the Profile's result.
209 virtual Profile* CreateProfileAsyncHelper(const FilePath& path, 205 virtual Profile* CreateProfileAsyncHelper(const FilePath& path,
210 Delegate* delegate); 206 Delegate* delegate);
211 207
212 #if defined(OS_WIN)
213 // Creates a shortcut manager. Override this to return a different shortcut
214 // manager or NULL to avoid creating shortcuts.
215 virtual ProfileShortcutManagerWin* CreateShortcutManager();
216 #endif
217
218 private: 208 private:
219 friend class TestingProfileManager; 209 friend class TestingProfileManager;
220 FRIEND_TEST_ALL_PREFIXES(ProfileManagerBrowserTest, DeleteAllProfiles); 210 FRIEND_TEST_ALL_PREFIXES(ProfileManagerBrowserTest, DeleteAllProfiles);
221 211
222 // This struct contains information about profiles which are being loaded or 212 // This struct contains information about profiles which are being loaded or
223 // were loaded. 213 // were loaded.
224 struct ProfileInfo { 214 struct ProfileInfo {
225 ProfileInfo(Profile* profile, bool created) 215 ProfileInfo(Profile* profile, bool created)
226 : profile(profile), created(created) { 216 : profile(profile), created(created) {
227 } 217 }
(...skipping 25 matching lines...) Expand all
253 typedef std::vector<ProfilePathAndName> ProfilePathAndNames; 243 typedef std::vector<ProfilePathAndName> ProfilePathAndNames;
254 ProfilePathAndNames GetSortedProfilesFromDirectoryMap(); 244 ProfilePathAndNames GetSortedProfilesFromDirectoryMap();
255 245
256 static bool CompareProfilePathAndName( 246 static bool CompareProfilePathAndName(
257 const ProfileManager::ProfilePathAndName& pair1, 247 const ProfileManager::ProfilePathAndName& pair1,
258 const ProfileManager::ProfilePathAndName& pair2); 248 const ProfileManager::ProfilePathAndName& pair2);
259 249
260 // Adds |profile| to the profile info cache if it hasn't been added yet. 250 // Adds |profile| to the profile info cache if it hasn't been added yet.
261 void AddProfileToCache(Profile* profile); 251 void AddProfileToCache(Profile* profile);
262 252
263 #if defined(OS_WIN)
264 // Creates a profile desktop shortcut for |profile| if we are in multi
265 // profile mode and the shortcut has not been created before.
266 void CreateDesktopShortcut(Profile* profile);
267 #endif
268
269 // Initializes user prefs of |profile|. This includes profile name and 253 // Initializes user prefs of |profile|. This includes profile name and
270 // avatar values 254 // avatar values
271 void InitProfileUserPrefs(Profile* profile); 255 void InitProfileUserPrefs(Profile* profile);
272 256
273 // For ChromeOS, determines if profile should be otr. 257 // For ChromeOS, determines if profile should be otr.
274 bool ShouldGoOffTheRecord(); 258 bool ShouldGoOffTheRecord();
275 259
276 // Get the path of the next profile directory and increment the internal 260 // Get the path of the next profile directory and increment the internal
277 // count. 261 // count.
278 // Lack of side effects: 262 // Lack of side effects:
(...skipping 22 matching lines...) Expand all
301 // RegisterProfile() to add into this map. This map owns all loaded profile 285 // RegisterProfile() to add into this map. This map owns all loaded profile
302 // objects in a running instance of Chrome. 286 // objects in a running instance of Chrome.
303 typedef std::map<FilePath, linked_ptr<ProfileInfo> > ProfilesInfoMap; 287 typedef std::map<FilePath, linked_ptr<ProfileInfo> > ProfilesInfoMap;
304 ProfilesInfoMap profiles_info_; 288 ProfilesInfoMap profiles_info_;
305 289
306 // Object to cache various information about profiles. Contains information 290 // Object to cache various information about profiles. Contains information
307 // about every profile which has been created for this instance of Chrome, 291 // about every profile which has been created for this instance of Chrome,
308 // if it has not been explicitly deleted. 292 // if it has not been explicitly deleted.
309 scoped_ptr<ProfileInfoCache> profile_info_cache_; 293 scoped_ptr<ProfileInfoCache> profile_info_cache_;
310 294
311 #if defined(OS_WIN)
312 // Manages the creation, deletion, and renaming of Windows shortcuts by
313 // observing the ProfileInfoCache.
314 scoped_ptr<ProfileShortcutManagerWin> profile_shortcut_manager_;
315 #endif
316 295
317 #if !defined(OS_ANDROID) 296 #if !defined(OS_ANDROID)
318 class BrowserListObserver : public chrome::BrowserListObserver { 297 class BrowserListObserver : public chrome::BrowserListObserver {
319 public: 298 public:
320 explicit BrowserListObserver(ProfileManager* manager); 299 explicit BrowserListObserver(ProfileManager* manager);
321 virtual ~BrowserListObserver(); 300 virtual ~BrowserListObserver();
322 301
323 // chrome::BrowserListObserver implementation. 302 // chrome::BrowserListObserver implementation.
324 virtual void OnBrowserAdded(Browser* browser) OVERRIDE; 303 virtual void OnBrowserAdded(Browser* browser) OVERRIDE;
325 virtual void OnBrowserRemoved(Browser* browser) OVERRIDE; 304 virtual void OnBrowserRemoved(Browser* browser) OVERRIDE;
(...skipping 22 matching lines...) Expand all
348 class ProfileManagerWithoutInit : public ProfileManager { 327 class ProfileManagerWithoutInit : public ProfileManager {
349 public: 328 public:
350 explicit ProfileManagerWithoutInit(const FilePath& user_data_dir); 329 explicit ProfileManagerWithoutInit(const FilePath& user_data_dir);
351 330
352 protected: 331 protected:
353 virtual void DoFinalInitForServices(Profile*, bool) OVERRIDE {} 332 virtual void DoFinalInitForServices(Profile*, bool) OVERRIDE {}
354 virtual void DoFinalInitLogging(Profile*) OVERRIDE {} 333 virtual void DoFinalInitLogging(Profile*) OVERRIDE {}
355 }; 334 };
356 335
357 #endif // CHROME_BROWSER_PROFILES_PROFILE_MANAGER_H_ 336 #endif // CHROME_BROWSER_PROFILES_PROFILE_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698