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

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

Issue 2352353002: Add AppLauncherId wrapper for items shown in shelf (Closed)
Patch Set: Include AppLauncherId in prefs code v2 Created 4 years, 3 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>
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 44
45 // Values used for prefs::kShelfAutoHideBehavior. 45 // Values used for prefs::kShelfAutoHideBehavior.
46 extern const char kShelfAutoHideBehaviorAlways[]; 46 extern const char kShelfAutoHideBehaviorAlways[];
47 extern const char kShelfAutoHideBehaviorNever[]; 47 extern const char kShelfAutoHideBehaviorNever[];
48 48
49 // Values used for prefs::kShelfAlignment. 49 // Values used for prefs::kShelfAlignment.
50 extern const char kShelfAlignmentBottom[]; 50 extern const char kShelfAlignmentBottom[];
51 extern const char kShelfAlignmentLeft[]; 51 extern const char kShelfAlignmentLeft[];
52 extern const char kShelfAlignmentRight[]; 52 extern const char kShelfAlignmentRight[];
53 53
54 // A unique chrome launcher id used to identify a shelf item.
55 class AppLauncherId {
56 public:
57 explicit AppLauncherId(const std::string& app_id);
58 ~AppLauncherId();
59
60 const std::string& GetAppLauncherID() const { return app_launcher_id_; }
stevenjb 2016/09/21 16:06:40 This is confusing, it looks like it should return
Andra Paraschiv 2016/09/22 09:23:41 Done.
61
62 bool operator==(const AppLauncherId& app_launcher_id) const {
63 return app_launcher_id.GetAppLauncherID() == app_launcher_id_;
64 }
stevenjb 2016/09/21 16:06:40 Since neither of these methods are simple getters
Andra Paraschiv 2016/09/22 09:23:41 Done.
65
66 private:
67 // A unique chrome launcher id for a shelf item.
68 const std::string app_launcher_id_;
69
70 DISALLOW_COPY_AND_ASSIGN(AppLauncherId);
71 };
72
54 void RegisterChromeLauncherUserPrefs( 73 void RegisterChromeLauncherUserPrefs(
55 user_prefs::PrefRegistrySyncable* registry); 74 user_prefs::PrefRegistrySyncable* registry);
56 75
57 base::DictionaryValue* CreateAppDict(const std::string& app_id); 76 base::DictionaryValue* CreateAppDict(AppLauncherId* app_launcher_id);
stevenjb 2016/09/21 16:06:40 Generally prefer const AppLauncherId& for input pa
Andra Paraschiv 2016/09/22 09:23:41 Done.
58 77
59 // Get or set the shelf auto hide behavior preference for a particular display. 78 // Get or set the shelf auto hide behavior preference for a particular display.
60 ShelfAutoHideBehavior GetShelfAutoHideBehaviorPref(PrefService* prefs, 79 ShelfAutoHideBehavior GetShelfAutoHideBehaviorPref(PrefService* prefs,
61 int64_t display_id); 80 int64_t display_id);
62 void SetShelfAutoHideBehaviorPref(PrefService* prefs, 81 void SetShelfAutoHideBehaviorPref(PrefService* prefs,
63 int64_t display_id, 82 int64_t display_id,
64 ShelfAutoHideBehavior behavior); 83 ShelfAutoHideBehavior behavior);
65 84
66 // Get or set the shelf alignment preference for a particular display. 85 // Get or set the shelf alignment preference for a particular display.
67 ShelfAlignment GetShelfAlignmentPref(PrefService* prefs, int64_t display_id); 86 ShelfAlignment GetShelfAlignmentPref(PrefService* prefs, int64_t display_id);
68 void SetShelfAlignmentPref(PrefService* prefs, 87 void SetShelfAlignmentPref(PrefService* prefs,
69 int64_t display_id, 88 int64_t display_id,
70 ShelfAlignment alignment); 89 ShelfAlignment alignment);
71 90
72 // Get the list of pinned apps from preferences. 91 // Get the list of pinned apps from preferences.
73 std::vector<std::string> GetPinnedAppsFromPrefs( 92 std::vector<std::string> GetPinnedAppsFromPrefs(
74 const PrefService* prefs, 93 const PrefService* prefs,
75 LauncherControllerHelper* helper); 94 LauncherControllerHelper* helper);
76 95
77 // Removes information about pin position from sync model for the app. 96 // Removes information about pin position from sync model for the app.
78 void RemovePinPosition(Profile* profile, const std::string& app_id); 97 void RemovePinPosition(Profile* profile, AppLauncherId* app_launcher_id);
79 98
80 // Updates information about pin position in sync model for the app |app_id|. 99 // Updates information about pin position in sync model for the app
81 // |app_id_before| optionally specifies an app that exists right before the 100 // |app_launcher_id|. |app_launcher_id_before| optionally specifies an app that
82 // target app. |app_id_after| optionally specifies an app that exists right 101 // exists right before the target app. |app_launcher_id_after| optionally
83 // after the target app. 102 // specifies an app that exists right after the target app.
84 void SetPinPosition(Profile* profile, 103 void SetPinPosition(Profile* profile,
85 const std::string& app_id, 104 AppLauncherId* app_launcher_id,
86 const std::string& app_id_before, 105 AppLauncherId* app_launcher_id_before,
87 const std::string& app_id_after); 106 AppLauncherId* app_launcher_id_after);
88 107
89 // Used to propagate remote preferences to local during the first run. 108 // Used to propagate remote preferences to local during the first run.
90 class ChromeLauncherPrefsObserver 109 class ChromeLauncherPrefsObserver
91 : public syncable_prefs::PrefServiceSyncableObserver { 110 : public syncable_prefs::PrefServiceSyncableObserver {
92 public: 111 public:
93 // Creates and returns an instance of ChromeLauncherPrefsObserver if the 112 // Creates and returns an instance of ChromeLauncherPrefsObserver if the
94 // profile prefs do not contain all the necessary local settings for the 113 // profile prefs do not contain all the necessary local settings for the
95 // shelf. If the local settings are present, returns null. 114 // shelf. If the local settings are present, returns null.
96 static std::unique_ptr<ChromeLauncherPrefsObserver> CreateIfNecessary( 115 static std::unique_ptr<ChromeLauncherPrefsObserver> CreateIfNecessary(
97 Profile* profile); 116 Profile* profile);
(...skipping 10 matching lines...) Expand all
108 // Profile prefs. Not owned. 127 // Profile prefs. Not owned.
109 syncable_prefs::PrefServiceSyncable* prefs_; 128 syncable_prefs::PrefServiceSyncable* prefs_;
110 129
111 DISALLOW_COPY_AND_ASSIGN(ChromeLauncherPrefsObserver); 130 DISALLOW_COPY_AND_ASSIGN(ChromeLauncherPrefsObserver);
112 }; 131 };
113 132
114 } // namespace launcher 133 } // namespace launcher
115 } // namespace ash 134 } // namespace ash
116 135
117 #endif // CHROME_BROWSER_UI_ASH_CHROME_LAUNCHER_PREFS_H_ 136 #endif // CHROME_BROWSER_UI_ASH_CHROME_LAUNCHER_PREFS_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/ui/ash/chrome_launcher_prefs.cc » ('j') | chrome/browser/ui/ash/chrome_launcher_prefs.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698