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

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

Powered by Google App Engine
This is Rietveld 408576698