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

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

Issue 1540543002: Uniquify profile shortcut name. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix review notes #3 Created 4 years, 11 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 <set>
9
8 #include "base/callback.h" 10 #include "base/callback.h"
9 #include "chrome/browser/profiles/profile_shortcut_manager.h" 11 #include "chrome/browser/profiles/profile_shortcut_manager.h"
10 #include "content/public/browser/notification_observer.h" 12 #include "content/public/browser/notification_observer.h"
11 #include "content/public/browser/notification_registrar.h" 13 #include "content/public/browser/notification_registrar.h"
12 14
13 class BrowserDistribution; 15 class BrowserDistribution;
14 16
15 // Internal free-standing functions that are exported here for testing. 17 // Internal free-standing functions that are exported here for testing.
16 namespace profiles { 18 namespace profiles {
17 namespace internal { 19 namespace internal {
18 20
19 // Returns the full path to the profile icon file. 21 // Returns the full path to the profile icon file.
20 base::FilePath GetProfileIconPath(const base::FilePath& profile_path); 22 base::FilePath GetProfileIconPath(const base::FilePath& profile_path);
21 23
22 // Returns the default shortcut filename for the given profile name, 24 // Returns the default shortcut filename for the given profile name,
23 // given |distribution|. Returns a filename appropriate for a 25 // given |distribution|. Returns a filename appropriate for a
24 // single-user installation if |profile_name| is empty. 26 // single-user installation if |profile_name| is empty.
25 base::string16 GetShortcutFilenameForProfile(const base::string16& profile_name, 27 base::string16 GetShortcutFilenameForProfile(const base::string16& profile_name,
26 BrowserDistribution* distribution); 28 BrowserDistribution* distribution);
27 29
30 // The same as GetShortcutFilenameForProfile but uniqueness is guaranteed.
31 // Makes an unique filename among |excludes|.
32 base::string16 GetUniqueShortcutFilenameForProfile(
33 const base::string16& profile_name,
34 const std::set<base::FilePath>& excludes,
35 BrowserDistribution* distribution);
36
37 // This class checks that shortcut filename matches certain profile.
38 class ShortcutFilenameMatcher {
39 public:
40 ShortcutFilenameMatcher(const base::string16& profile_name,
41 BrowserDistribution* distribution);
42
43 // Check that shortcut filename has a name given by us (by
44 // GetShortcutFilenameForProfile or GetUniqueShortcutFilenameForProfile).
45 bool IsCanonical(const base::string16& filename) const;
46
47 private:
48 const base::string16 profile_shortcut_filename_;
49 const base::StringPiece16 lnk_ext_;
50 base::StringPiece16 profile_shortcut_name_;
51
52 DISALLOW_COPY_AND_ASSIGN(ShortcutFilenameMatcher);
53 };
54
28 // Returns the command-line flags to launch Chrome with the given profile. 55 // Returns the command-line flags to launch Chrome with the given profile.
29 base::string16 CreateProfileShortcutFlags(const base::FilePath& profile_path); 56 base::string16 CreateProfileShortcutFlags(const base::FilePath& profile_path);
30 57
31 } // namespace internal 58 } // namespace internal
32 } // namespace profiles 59 } // namespace profiles
33 60
34 class ProfileShortcutManagerWin : public ProfileShortcutManager, 61 class ProfileShortcutManagerWin : public ProfileShortcutManager,
35 public ProfileInfoCacheObserver, 62 public ProfileInfoCacheObserver,
36 public content::NotificationObserver { 63 public content::NotificationObserver {
37 public: 64 public:
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 NonProfileShortcutAction action); 117 NonProfileShortcutAction action);
91 118
92 ProfileManager* profile_manager_; 119 ProfileManager* profile_manager_;
93 120
94 content::NotificationRegistrar registrar_; 121 content::NotificationRegistrar registrar_;
95 122
96 DISALLOW_COPY_AND_ASSIGN(ProfileShortcutManagerWin); 123 DISALLOW_COPY_AND_ASSIGN(ProfileShortcutManagerWin);
97 }; 124 };
98 125
99 #endif // CHROME_BROWSER_PROFILES_PROFILE_SHORTCUT_MANAGER_WIN_H_ 126 #endif // CHROME_BROWSER_PROFILES_PROFILE_SHORTCUT_MANAGER_WIN_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698