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 <set> | |
9 | |
10 #include "base/callback.h" | 8 #include "base/callback.h" |
11 #include "chrome/browser/profiles/profile_shortcut_manager.h" | 9 #include "chrome/browser/profiles/profile_shortcut_manager.h" |
12 #include "content/public/browser/notification_observer.h" | 10 #include "content/public/browser/notification_observer.h" |
13 #include "content/public/browser/notification_registrar.h" | 11 #include "content/public/browser/notification_registrar.h" |
14 | 12 |
15 class BrowserDistribution; | 13 class BrowserDistribution; |
16 | 14 |
17 // Internal free-standing functions that are exported here for testing. | 15 // Internal free-standing functions that are exported here for testing. |
18 namespace profiles { | 16 namespace profiles { |
19 namespace internal { | 17 namespace internal { |
20 | 18 |
21 // Returns the full path to the profile icon file. | 19 // Returns the full path to the profile icon file. |
22 base::FilePath GetProfileIconPath(const base::FilePath& profile_path); | 20 base::FilePath GetProfileIconPath(const base::FilePath& profile_path); |
23 | 21 |
24 // Returns the default shortcut filename for the given profile name, | 22 // Returns the default shortcut filename for the given profile name, |
25 // given |distribution|. Returns a filename appropriate for a | 23 // given |distribution|. Returns a filename appropriate for a |
26 // single-user installation if |profile_name| is empty. | 24 // single-user installation if |profile_name| is empty. |
27 base::string16 GetShortcutFilenameForProfile(const base::string16& profile_name, | 25 base::string16 GetShortcutFilenameForProfile(const base::string16& profile_name, |
28 BrowserDistribution* distribution); | 26 BrowserDistribution* distribution); |
29 | 27 |
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 | |
55 // 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. |
56 base::string16 CreateProfileShortcutFlags(const base::FilePath& profile_path); | 29 base::string16 CreateProfileShortcutFlags(const base::FilePath& profile_path); |
57 | 30 |
58 } // namespace internal | 31 } // namespace internal |
59 } // namespace profiles | 32 } // namespace profiles |
60 | 33 |
61 class ProfileShortcutManagerWin : public ProfileShortcutManager, | 34 class ProfileShortcutManagerWin : public ProfileShortcutManager, |
62 public ProfileInfoCacheObserver, | 35 public ProfileInfoCacheObserver, |
63 public content::NotificationObserver { | 36 public content::NotificationObserver { |
64 public: | 37 public: |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
117 NonProfileShortcutAction action); | 90 NonProfileShortcutAction action); |
118 | 91 |
119 ProfileManager* profile_manager_; | 92 ProfileManager* profile_manager_; |
120 | 93 |
121 content::NotificationRegistrar registrar_; | 94 content::NotificationRegistrar registrar_; |
122 | 95 |
123 DISALLOW_COPY_AND_ASSIGN(ProfileShortcutManagerWin); | 96 DISALLOW_COPY_AND_ASSIGN(ProfileShortcutManagerWin); |
124 }; | 97 }; |
125 | 98 |
126 #endif // CHROME_BROWSER_PROFILES_PROFILE_SHORTCUT_MANAGER_WIN_H_ | 99 #endif // CHROME_BROWSER_PROFILES_PROFILE_SHORTCUT_MANAGER_WIN_H_ |
OLD | NEW |