Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 #ifndef CHROME_BROWSER_PROFILES_PROFILE_SHORTCUT_MANAGER_WIN_H_ | 5 #ifndef CHROME_BROWSER_PROFILES_PROFILE_SHORTCUT_MANAGER_WIN_H_ |
| 6 #define CHROME_BROWSER_PROFILES_PROFILE_SHORTCUT_MANAGER_WIN_H_ | 6 #define CHROME_BROWSER_PROFILES_PROFILE_SHORTCUT_MANAGER_WIN_H_ |
| 7 | 7 |
| 8 #include "chrome/browser/profiles/profile_shortcut_manager.h" | 8 #include "chrome/browser/profiles/profile_shortcut_manager.h" |
| 9 #include "content/public/browser/notification_observer.h" | |
| 10 #include "content/public/browser/notification_registrar.h" | |
| 9 | 11 |
| 10 class BrowserDistribution; | 12 class BrowserDistribution; |
| 11 | 13 |
| 12 // Internal free-standing functions that are exported here for testing. | 14 // Internal free-standing functions that are exported here for testing. |
| 13 namespace profiles { | 15 namespace profiles { |
| 14 namespace internal { | 16 namespace internal { |
| 15 | 17 |
| 16 // Name of the badged icon file generated for a given profile. | 18 // Returns the full path to the profile icon file. |
| 17 extern const char kProfileIconFileName[]; | 19 base::FilePath GetProfileIconPath(const base::FilePath& profile_path); |
| 18 | 20 |
| 19 // Returns the default shortcut filename for the given profile name, | 21 // Returns the default shortcut filename for the given profile name, |
| 20 // given |distribution|. Returns a filename appropriate for a | 22 // given |distribution|. Returns a filename appropriate for a |
| 21 // single-user installation if |profile_name| is empty. | 23 // single-user installation if |profile_name| is empty. |
| 22 string16 GetShortcutFilenameForProfile(const string16& profile_name, | 24 string16 GetShortcutFilenameForProfile(const string16& profile_name, |
| 23 BrowserDistribution* distribution); | 25 BrowserDistribution* distribution); |
| 24 | 26 |
| 25 // Returns the command-line flags to launch Chrome with the given profile. | 27 // Returns the command-line flags to launch Chrome with the given profile. |
| 26 string16 CreateProfileShortcutFlags(const base::FilePath& profile_path); | 28 string16 CreateProfileShortcutFlags(const base::FilePath& profile_path); |
| 27 | 29 |
| 28 } // namespace internal | 30 } // namespace internal |
| 29 } // namespace profiles | 31 } // namespace profiles |
| 30 | 32 |
| 31 class ProfileShortcutManagerWin : public ProfileShortcutManager, | 33 class ProfileShortcutManagerWin : public ProfileShortcutManager, |
| 32 public ProfileInfoCacheObserver { | 34 public ProfileInfoCacheObserver, |
| 35 public content::NotificationObserver { | |
| 33 public: | 36 public: |
| 34 // Specifies whether a new shortcut should be created if none exist. | 37 // Specifies whether only the existing shortcuts should be updated, a new |
|
gab
2013/06/18 15:36:58
s/shortcuts/shortcut here right?
calamity
2013/06/27 08:10:11
Done.
| |
| 38 // shortcut should be created if none exist, or only the icon for this profile | |
| 39 // should be created in the profile directory. | |
| 35 enum CreateOrUpdateMode { | 40 enum CreateOrUpdateMode { |
| 36 UPDATE_EXISTING_ONLY, | 41 UPDATE_EXISTING_ONLY, |
| 37 CREATE_WHEN_NONE_FOUND, | 42 CREATE_WHEN_NONE_FOUND, |
| 43 CREATE_OR_UPDATE_ICON_ONLY, | |
| 38 }; | 44 }; |
| 39 // Specifies whether non-profile shortcuts should be updated. | 45 // Specifies whether non-profile shortcuts should be updated. |
| 40 enum NonProfileShortcutAction { | 46 enum NonProfileShortcutAction { |
| 41 IGNORE_NON_PROFILE_SHORTCUTS, | 47 IGNORE_NON_PROFILE_SHORTCUTS, |
| 42 UPDATE_NON_PROFILE_SHORTCUTS, | 48 UPDATE_NON_PROFILE_SHORTCUTS, |
| 43 }; | 49 }; |
| 44 | 50 |
| 45 explicit ProfileShortcutManagerWin(ProfileManager* manager); | 51 explicit ProfileShortcutManagerWin(ProfileManager* manager); |
| 46 virtual ~ProfileShortcutManagerWin(); | 52 virtual ~ProfileShortcutManagerWin(); |
| 47 | 53 |
| 48 // ProfileShortcutManager implementation: | 54 // ProfileShortcutManager implementation: |
| 55 virtual void CreateOrUpdateProfileIcon( | |
| 56 const base::FilePath& profile_path, | |
| 57 const base::Closure& callback) OVERRIDE; | |
|
gab
2013/06/18 15:36:58
#include "base/callback.h"
calamity
2013/06/27 08:10:11
Done.
| |
| 49 virtual void CreateProfileShortcut( | 58 virtual void CreateProfileShortcut( |
| 50 const base::FilePath& profile_path) OVERRIDE; | 59 const base::FilePath& profile_path) OVERRIDE; |
| 51 virtual void RemoveProfileShortcuts( | 60 virtual void RemoveProfileShortcuts( |
| 52 const base::FilePath& profile_path) OVERRIDE; | 61 const base::FilePath& profile_path) OVERRIDE; |
| 53 virtual void HasProfileShortcuts( | 62 virtual void HasProfileShortcuts( |
| 54 const base::FilePath& profile_path, | 63 const base::FilePath& profile_path, |
| 55 const base::Callback<void(bool)>& callback) OVERRIDE; | 64 const base::Callback<void(bool)>& callback) OVERRIDE; |
| 56 | 65 |
| 57 // ProfileInfoCacheObserver implementation: | 66 // ProfileInfoCacheObserver implementation: |
| 58 virtual void OnProfileAdded(const base::FilePath& profile_path) OVERRIDE; | 67 virtual void OnProfileAdded(const base::FilePath& profile_path) OVERRIDE; |
| 59 virtual void OnProfileWillBeRemoved( | 68 virtual void OnProfileWillBeRemoved( |
| 60 const base::FilePath& profile_path) OVERRIDE; | 69 const base::FilePath& profile_path) OVERRIDE; |
| 61 virtual void OnProfileWasRemoved(const base::FilePath& profile_path, | 70 virtual void OnProfileWasRemoved(const base::FilePath& profile_path, |
| 62 const string16& profile_name) OVERRIDE; | 71 const string16& profile_name) OVERRIDE; |
| 63 virtual void OnProfileNameChanged(const base::FilePath& profile_path, | 72 virtual void OnProfileNameChanged(const base::FilePath& profile_path, |
| 64 const string16& old_profile_name) OVERRIDE; | 73 const string16& old_profile_name) OVERRIDE; |
| 65 virtual void OnProfileAvatarChanged( | 74 virtual void OnProfileAvatarChanged( |
| 66 const base::FilePath& profile_path) OVERRIDE; | 75 const base::FilePath& profile_path) OVERRIDE; |
| 67 | 76 |
| 77 // content::NotificationObserver: | |
|
Alexei Svitkine (slow)
2013/06/18 15:27:19
Nit: to be consistent with comments above, change
calamity
2013/06/27 08:10:11
Done.
| |
| 78 virtual void Observe(int type, | |
| 79 const content::NotificationSource& source, | |
| 80 const content::NotificationDetails& details) OVERRIDE; | |
| 81 | |
| 68 private: | 82 private: |
| 69 // Gives the profile path of an alternate profile than |profile_path|. | 83 // Gives the profile path of an alternate profile than |profile_path|. |
| 70 // Must only be called when the number profiles is 2. | 84 // Must only be called when the number profiles is 2. |
| 71 base::FilePath GetOtherProfilePath(const base::FilePath& profile_path); | 85 base::FilePath GetOtherProfilePath(const base::FilePath& profile_path); |
| 72 | 86 |
| 73 void CreateOrUpdateShortcutsForProfileAtPath( | 87 void CreateOrUpdateShortcutsForProfileAtPath( |
|
gab
2013/06/18 15:36:58
Add a method comment here.
calamity
2013/06/27 08:10:11
Done.
| |
| 74 const base::FilePath& profile_path, | 88 const base::FilePath& profile_path, |
| 75 CreateOrUpdateMode create_mode, | 89 CreateOrUpdateMode create_mode, |
| 76 NonProfileShortcutAction action); | 90 NonProfileShortcutAction action, |
| 91 const base::Closure& callback); | |
| 77 | 92 |
| 78 ProfileManager* profile_manager_; | 93 ProfileManager* profile_manager_; |
| 79 | 94 |
| 95 content::NotificationRegistrar registrar_; | |
| 96 | |
| 80 DISALLOW_COPY_AND_ASSIGN(ProfileShortcutManagerWin); | 97 DISALLOW_COPY_AND_ASSIGN(ProfileShortcutManagerWin); |
| 81 }; | 98 }; |
| 82 | 99 |
| 83 #endif // CHROME_BROWSER_PROFILES_PROFILE_SHORTCUT_MANAGER_WIN_H_ | 100 #endif // CHROME_BROWSER_PROFILES_PROFILE_SHORTCUT_MANAGER_WIN_H_ |
| OLD | NEW |