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

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

Issue 14137032: Create profile .ico file on profile creation (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: address 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 #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 "base/callback.h"
8 #include "chrome/browser/profiles/profile_shortcut_manager.h" 9 #include "chrome/browser/profiles/profile_shortcut_manager.h"
10 #include "content/public/browser/notification_observer.h"
11 #include "content/public/browser/notification_registrar.h"
9 12
10 class BrowserDistribution; 13 class BrowserDistribution;
11 14
12 // Internal free-standing functions that are exported here for testing. 15 // Internal free-standing functions that are exported here for testing.
13 namespace profiles { 16 namespace profiles {
14 namespace internal { 17 namespace internal {
15 18
16 // Name of the badged icon file generated for a given profile. 19 // Returns the full path to the profile icon file.
17 extern const char kProfileIconFileName[]; 20 base::FilePath GetProfileIconPath(const base::FilePath& profile_path);
18 21
19 // Returns the default shortcut filename for the given profile name, 22 // Returns the default shortcut filename for the given profile name,
20 // given |distribution|. Returns a filename appropriate for a 23 // given |distribution|. Returns a filename appropriate for a
21 // single-user installation if |profile_name| is empty. 24 // single-user installation if |profile_name| is empty.
22 string16 GetShortcutFilenameForProfile(const string16& profile_name, 25 string16 GetShortcutFilenameForProfile(const string16& profile_name,
23 BrowserDistribution* distribution); 26 BrowserDistribution* distribution);
24 27
25 // Returns the command-line flags to launch Chrome with the given profile. 28 // Returns the command-line flags to launch Chrome with the given profile.
26 string16 CreateProfileShortcutFlags(const base::FilePath& profile_path); 29 string16 CreateProfileShortcutFlags(const base::FilePath& profile_path);
27 30
28 } // namespace internal 31 } // namespace internal
29 } // namespace profiles 32 } // namespace profiles
30 33
31 class ProfileShortcutManagerWin : public ProfileShortcutManager, 34 class ProfileShortcutManagerWin : public ProfileShortcutManager,
32 public ProfileInfoCacheObserver { 35 public ProfileInfoCacheObserver,
36 public content::NotificationObserver {
33 public: 37 public:
34 // Specifies whether a new shortcut should be created if none exist. 38 // Specifies whether only the existing shortcut should be updated, a new
39 // shortcut should be created if none exist, or only the icon for this profile
40 // should be created in the profile directory.
35 enum CreateOrUpdateMode { 41 enum CreateOrUpdateMode {
36 UPDATE_EXISTING_ONLY, 42 UPDATE_EXISTING_ONLY,
37 CREATE_WHEN_NONE_FOUND, 43 CREATE_WHEN_NONE_FOUND,
44 CREATE_OR_UPDATE_ICON_ONLY,
38 }; 45 };
39 // Specifies whether non-profile shortcuts should be updated. 46 // Specifies whether non-profile shortcuts should be updated.
40 enum NonProfileShortcutAction { 47 enum NonProfileShortcutAction {
41 IGNORE_NON_PROFILE_SHORTCUTS, 48 IGNORE_NON_PROFILE_SHORTCUTS,
42 UPDATE_NON_PROFILE_SHORTCUTS, 49 UPDATE_NON_PROFILE_SHORTCUTS,
43 }; 50 };
44 51
45 explicit ProfileShortcutManagerWin(ProfileManager* manager); 52 explicit ProfileShortcutManagerWin(ProfileManager* manager);
46 virtual ~ProfileShortcutManagerWin(); 53 virtual ~ProfileShortcutManagerWin();
47 54
48 // ProfileShortcutManager implementation: 55 // ProfileShortcutManager implementation:
56 virtual void CreateOrUpdateProfileIcon(
57 const base::FilePath& profile_path,
58 const base::Closure& callback) OVERRIDE;
49 virtual void CreateProfileShortcut( 59 virtual void CreateProfileShortcut(
50 const base::FilePath& profile_path) OVERRIDE; 60 const base::FilePath& profile_path) OVERRIDE;
51 virtual void RemoveProfileShortcuts( 61 virtual void RemoveProfileShortcuts(
52 const base::FilePath& profile_path) OVERRIDE; 62 const base::FilePath& profile_path) OVERRIDE;
53 virtual void HasProfileShortcuts( 63 virtual void HasProfileShortcuts(
54 const base::FilePath& profile_path, 64 const base::FilePath& profile_path,
55 const base::Callback<void(bool)>& callback) OVERRIDE; 65 const base::Callback<void(bool)>& callback) OVERRIDE;
56 66
57 // ProfileInfoCacheObserver implementation: 67 // ProfileInfoCacheObserver implementation:
58 virtual void OnProfileAdded(const base::FilePath& profile_path) OVERRIDE; 68 virtual void OnProfileAdded(const base::FilePath& profile_path) OVERRIDE;
59 virtual void OnProfileWasRemoved(const base::FilePath& profile_path, 69 virtual void OnProfileWasRemoved(const base::FilePath& profile_path,
60 const string16& profile_name) OVERRIDE; 70 const string16& profile_name) OVERRIDE;
61 virtual void OnProfileNameChanged(const base::FilePath& profile_path, 71 virtual void OnProfileNameChanged(const base::FilePath& profile_path,
62 const string16& old_profile_name) OVERRIDE; 72 const string16& old_profile_name) OVERRIDE;
63 virtual void OnProfileAvatarChanged( 73 virtual void OnProfileAvatarChanged(
64 const base::FilePath& profile_path) OVERRIDE; 74 const base::FilePath& profile_path) OVERRIDE;
65 75
76 // content::NotificationObserver implementation:
77 virtual void Observe(int type,
78 const content::NotificationSource& source,
79 const content::NotificationDetails& details) OVERRIDE;
80
66 private: 81 private:
67 // Gives the profile path of an alternate profile than |profile_path|. 82 // Gives the profile path of an alternate profile than |profile_path|.
68 // Must only be called when the number profiles is 2. 83 // Must only be called when the number profiles is 2.
69 base::FilePath GetOtherProfilePath(const base::FilePath& profile_path); 84 base::FilePath GetOtherProfilePath(const base::FilePath& profile_path);
70 85
86 // Creates or updates shortcuts for the profile at |profile_path| according
87 // to the specified |create_mode| and |action|. This will always involve
88 // creating or updating the icon file for this profile.
89 // Calls |callback| on successful icon creation.
71 void CreateOrUpdateShortcutsForProfileAtPath( 90 void CreateOrUpdateShortcutsForProfileAtPath(
72 const base::FilePath& profile_path, 91 const base::FilePath& profile_path,
73 CreateOrUpdateMode create_mode, 92 CreateOrUpdateMode create_mode,
74 NonProfileShortcutAction action); 93 NonProfileShortcutAction action,
94 const base::Closure& callback);
75 95
76 ProfileManager* profile_manager_; 96 ProfileManager* profile_manager_;
77 97
98 content::NotificationRegistrar registrar_;
99
78 DISALLOW_COPY_AND_ASSIGN(ProfileShortcutManagerWin); 100 DISALLOW_COPY_AND_ASSIGN(ProfileShortcutManagerWin);
79 }; 101 };
80 102
81 #endif // CHROME_BROWSER_PROFILES_PROFILE_SHORTCUT_MANAGER_WIN_H_ 103 #endif // CHROME_BROWSER_PROFILES_PROFILE_SHORTCUT_MANAGER_WIN_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698