Only grant permissions to new extensions from sync if they have the expected version
[chromium-blink-merge.git] / chrome / browser / profiles / profile_shortcut_manager_win.h
blob7645b8d425c6d5b42edca5ef0bb9ef660ee80248
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
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_PROFILES_PROFILE_SHORTCUT_MANAGER_WIN_H_
6 #define CHROME_BROWSER_PROFILES_PROFILE_SHORTCUT_MANAGER_WIN_H_
8 #include "base/callback.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"
13 class BrowserDistribution;
15 // Internal free-standing functions that are exported here for testing.
16 namespace profiles {
17 namespace internal {
19 // Returns the full path to the profile icon file.
20 base::FilePath GetProfileIconPath(const base::FilePath& profile_path);
22 // Returns the default shortcut filename for the given profile name,
23 // given |distribution|. Returns a filename appropriate for a
24 // single-user installation if |profile_name| is empty.
25 base::string16 GetShortcutFilenameForProfile(const base::string16& profile_name,
26 BrowserDistribution* distribution);
28 // Returns the command-line flags to launch Chrome with the given profile.
29 base::string16 CreateProfileShortcutFlags(const base::FilePath& profile_path);
31 } // namespace internal
32 } // namespace profiles
34 class ProfileShortcutManagerWin : public ProfileShortcutManager,
35 public ProfileInfoCacheObserver,
36 public content::NotificationObserver {
37 public:
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.
41 enum CreateOrUpdateMode {
42 UPDATE_EXISTING_ONLY,
43 CREATE_WHEN_NONE_FOUND,
44 CREATE_OR_UPDATE_ICON_ONLY,
46 // Specifies whether non-profile shortcuts should be updated.
47 enum NonProfileShortcutAction {
48 IGNORE_NON_PROFILE_SHORTCUTS,
49 UPDATE_NON_PROFILE_SHORTCUTS,
52 explicit ProfileShortcutManagerWin(ProfileManager* manager);
53 ~ProfileShortcutManagerWin() override;
55 // ProfileShortcutManager implementation:
56 void CreateOrUpdateProfileIcon(const base::FilePath& profile_path) override;
57 void CreateProfileShortcut(const base::FilePath& profile_path) override;
58 void RemoveProfileShortcuts(const base::FilePath& profile_path) override;
59 void HasProfileShortcuts(const base::FilePath& profile_path,
60 const base::Callback<void(bool)>& callback) override;
61 void GetShortcutProperties(const base::FilePath& profile_path,
62 base::CommandLine* command_line,
63 base::string16* name,
64 base::FilePath* icon_path) override;
66 // ProfileInfoCacheObserver implementation:
67 void OnProfileAdded(const base::FilePath& profile_path) override;
68 void OnProfileWasRemoved(const base::FilePath& profile_path,
69 const base::string16& profile_name) override;
70 void OnProfileNameChanged(const base::FilePath& profile_path,
71 const base::string16& old_profile_name) override;
72 void OnProfileAvatarChanged(const base::FilePath& profile_path) override;
74 // content::NotificationObserver implementation:
75 void Observe(int type,
76 const content::NotificationSource& source,
77 const content::NotificationDetails& details) override;
79 private:
80 // Gives the profile path of an alternate profile than |profile_path|.
81 // Must only be called when the number profiles is 2.
82 base::FilePath GetOtherProfilePath(const base::FilePath& profile_path);
84 // Creates or updates shortcuts for the profile at |profile_path| according
85 // to the specified |create_mode| and |action|. This will always involve
86 // creating or updating the icon file for this profile.
87 void CreateOrUpdateShortcutsForProfileAtPath(
88 const base::FilePath& profile_path,
89 CreateOrUpdateMode create_mode,
90 NonProfileShortcutAction action);
92 ProfileManager* profile_manager_;
94 content::NotificationRegistrar registrar_;
96 DISALLOW_COPY_AND_ASSIGN(ProfileShortcutManagerWin);
99 #endif // CHROME_BROWSER_PROFILES_PROFILE_SHORTCUT_MANAGER_WIN_H_