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

Side by Side Diff: chrome/browser/ui/ash/chrome_launcher_prefs.h

Issue 2691043002: Discard pinning an app with non-empty launcher id. (Closed)
Patch Set: Created 3 years, 10 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_UI_ASH_CHROME_LAUNCHER_PREFS_H_ 5 #ifndef CHROME_BROWSER_UI_ASH_CHROME_LAUNCHER_PREFS_H_
6 #define CHROME_BROWSER_UI_ASH_CHROME_LAUNCHER_PREFS_H_ 6 #define CHROME_BROWSER_UI_ASH_CHROME_LAUNCHER_PREFS_H_
7 7
8 #include <memory> 8 #include <memory>
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
11 11
12 #include "ash/public/cpp/shelf_types.h" 12 #include "ash/public/cpp/shelf_types.h"
13 #include "base/macros.h" 13 #include "base/macros.h"
14 #include "components/sync_preferences/pref_service_syncable_observer.h" 14 #include "components/sync_preferences/pref_service_syncable_observer.h"
15 15
16 class LauncherControllerHelper; 16 class LauncherControllerHelper;
17 class PrefService; 17 class PrefService;
18 class Profile; 18 class Profile;
19 19
20 namespace base {
21 class DictionaryValue;
22 }
23
24 namespace sync_preferences { 20 namespace sync_preferences {
25 class PrefServiceSyncable; 21 class PrefServiceSyncable;
26 } 22 }
27 23
28 namespace user_prefs { 24 namespace user_prefs {
29 class PrefRegistrySyncable; 25 class PrefRegistrySyncable;
30 } 26 }
31 27
32 namespace ash { 28 namespace ash {
33 namespace launcher { 29 namespace launcher {
34 30
31 class AppLauncherId;
32
35 // Path within the dictionary entries in the prefs::kPinnedLauncherApps list 33 // Path within the dictionary entries in the prefs::kPinnedLauncherApps list
36 // specifying the extension ID of the app to be pinned by that entry. 34 // specifying the extension ID of the app to be pinned by that entry.
37 extern const char kPinnedAppsPrefAppIDPath[]; 35 extern const char kPinnedAppsPrefAppIDPath[];
38 36
39 extern const char kPinnedAppsPrefPinnedByPolicy[]; 37 extern const char kPinnedAppsPrefPinnedByPolicy[];
40 38
41 // Value used as a placeholder in the list of pinned applications. 39 // Value used as a placeholder in the list of pinned applications.
42 // This is NOT a valid extension identifier so pre-M31 versions ignore it. 40 // This is NOT a valid extension identifier so pre-M31 versions ignore it.
43 extern const char kPinnedAppsPlaceholder[]; 41 extern const char kPinnedAppsPlaceholder[];
44 42
45 // Values used for prefs::kShelfAutoHideBehavior. 43 // Values used for prefs::kShelfAutoHideBehavior.
46 extern const char kShelfAutoHideBehaviorAlways[]; 44 extern const char kShelfAutoHideBehaviorAlways[];
47 extern const char kShelfAutoHideBehaviorNever[]; 45 extern const char kShelfAutoHideBehaviorNever[];
48 46
49 // Values used for prefs::kShelfAlignment. 47 // Values used for prefs::kShelfAlignment.
50 extern const char kShelfAlignmentBottom[]; 48 extern const char kShelfAlignmentBottom[];
51 extern const char kShelfAlignmentLeft[]; 49 extern const char kShelfAlignmentLeft[];
52 extern const char kShelfAlignmentRight[]; 50 extern const char kShelfAlignmentRight[];
53 51
54 // A unique chrome launcher id used to identify a shelf item. This class is a
55 // wrapper for the chrome launcher identifier. |app_launcher_id_| includes the
56 // |app_id| and the |launch_id|. The |app_id| is the application id associated
57 // with a set of windows. The |launch_id| is an id that can be passed to an app
58 // when launched in order to support multiple shelf items per app. This id is
59 // used together with the |app_id| to uniquely identify each shelf item that
60 // has the same |app_id|. The |app_id| must not be empty.
61 class AppLauncherId {
62 public:
63 AppLauncherId(const std::string& app_id, const std::string& launch_id);
64 // Creates an AppLauncherId with an empty |launch_id|.
65 explicit AppLauncherId(const std::string& app_id);
66 // Empty constructor for pre-allocating.
67 AppLauncherId();
68 ~AppLauncherId();
69
70 AppLauncherId(const AppLauncherId& app_launcher_id) = default;
71 AppLauncherId(AppLauncherId&& app_launcher_id) = default;
72 AppLauncherId& operator=(const AppLauncherId& other) = default;
73
74 std::string ToString() const;
75 const std::string& app_id() const { return app_id_; }
76 const std::string& launch_id() const { return launch_id_; }
77
78 bool operator<(const AppLauncherId& other) const;
79
80 private:
81 // The application id associated with a set of windows.
82 std::string app_id_;
83 // An id that can be passed to an app when launched in order to support
84 // multiple shelf items per app.
85 std::string launch_id_;
86 };
87
88 void RegisterChromeLauncherUserPrefs( 52 void RegisterChromeLauncherUserPrefs(
89 user_prefs::PrefRegistrySyncable* registry); 53 user_prefs::PrefRegistrySyncable* registry);
90 54
91 std::unique_ptr<base::DictionaryValue> CreateAppDict(
92 const AppLauncherId& app_launcher_id);
93
94 // Get or set the shelf auto hide behavior preference for a particular display. 55 // Get or set the shelf auto hide behavior preference for a particular display.
95 ShelfAutoHideBehavior GetShelfAutoHideBehaviorPref(PrefService* prefs, 56 ShelfAutoHideBehavior GetShelfAutoHideBehaviorPref(PrefService* prefs,
96 int64_t display_id); 57 int64_t display_id);
97 void SetShelfAutoHideBehaviorPref(PrefService* prefs, 58 void SetShelfAutoHideBehaviorPref(PrefService* prefs,
98 int64_t display_id, 59 int64_t display_id,
99 ShelfAutoHideBehavior behavior); 60 ShelfAutoHideBehavior behavior);
100 61
101 // Get or set the shelf alignment preference for a particular display. 62 // Get or set the shelf alignment preference for a particular display.
102 ShelfAlignment GetShelfAlignmentPref(PrefService* prefs, int64_t display_id); 63 ShelfAlignment GetShelfAlignmentPref(PrefService* prefs, int64_t display_id);
103 void SetShelfAlignmentPref(PrefService* prefs, 64 void SetShelfAlignmentPref(PrefService* prefs,
104 int64_t display_id, 65 int64_t display_id,
105 ShelfAlignment alignment); 66 ShelfAlignment alignment);
106 67
107 // Get the list of pinned apps from preferences. 68 // Get the list of pinned apps from preferences.
108 std::vector<AppLauncherId> GetPinnedAppsFromPrefs( 69 std::vector<AppLauncherId> GetPinnedAppsFromPrefs(
109 const PrefService* prefs, 70 const PrefService* prefs,
110 LauncherControllerHelper* helper); 71 LauncherControllerHelper* helper);
111 72
112 // Removes information about pin position from sync model for the app. 73 // Removes information about pin position from sync model for the app. Note,
74 // |app_launcher_id| with non-empty launch_id is not supported.
113 void RemovePinPosition(Profile* profile, const AppLauncherId& app_launcher_id); 75 void RemovePinPosition(Profile* profile, const AppLauncherId& app_launcher_id);
114 76
115 // Updates information about pin position in sync model for the app 77 // Updates information about pin position in sync model for the app
116 // |app_launcher_id|. |app_launcher_id_before| optionally specifies an app that 78 // |app_launcher_id|. |app_launcher_id_before| optionally specifies an app that
117 // exists right before the target app. |app_launcher_ids_after| optionally 79 // exists right before the target app. |app_launcher_ids_after| optionally
118 // specifies sorted by position apps that exist right after the target app. 80 // specifies sorted by position apps that exist right after the target app.
81 // Note, |app_launcher_id| with non-empty launch_id is not supported.
119 void SetPinPosition(Profile* profile, 82 void SetPinPosition(Profile* profile,
120 const AppLauncherId& app_launcher_id, 83 const AppLauncherId& app_launcher_id,
121 const AppLauncherId& app_launcher_id_before, 84 const AppLauncherId& app_launcher_id_before,
122 const std::vector<AppLauncherId>& app_launcher_ids_after); 85 const std::vector<AppLauncherId>& app_launcher_ids_after);
123 86
124 // Used to propagate remote preferences to local during the first run. 87 // Used to propagate remote preferences to local during the first run.
125 class ChromeLauncherPrefsObserver 88 class ChromeLauncherPrefsObserver
126 : public sync_preferences::PrefServiceSyncableObserver { 89 : public sync_preferences::PrefServiceSyncableObserver {
127 public: 90 public:
128 // Creates and returns an instance of ChromeLauncherPrefsObserver if the 91 // Creates and returns an instance of ChromeLauncherPrefsObserver if the
(...skipping 14 matching lines...) Expand all
143 // Profile prefs. Not owned. 106 // Profile prefs. Not owned.
144 sync_preferences::PrefServiceSyncable* prefs_; 107 sync_preferences::PrefServiceSyncable* prefs_;
145 108
146 DISALLOW_COPY_AND_ASSIGN(ChromeLauncherPrefsObserver); 109 DISALLOW_COPY_AND_ASSIGN(ChromeLauncherPrefsObserver);
147 }; 110 };
148 111
149 } // namespace launcher 112 } // namespace launcher
150 } // namespace ash 113 } // namespace ash
151 114
152 #endif // CHROME_BROWSER_UI_ASH_CHROME_LAUNCHER_PREFS_H_ 115 #endif // CHROME_BROWSER_UI_ASH_CHROME_LAUNCHER_PREFS_H_
OLDNEW
« no previous file with comments | « chrome/browser/ui/ash/app_launcher_id.cc ('k') | chrome/browser/ui/ash/chrome_launcher_prefs.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698