| 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_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 Loading... |
| 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. 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 |
| 54 void RegisterChromeLauncherUserPrefs( | 88 void RegisterChromeLauncherUserPrefs( |
| 55 user_prefs::PrefRegistrySyncable* registry); | 89 user_prefs::PrefRegistrySyncable* registry); |
| 56 | 90 |
| 57 std::unique_ptr<base::DictionaryValue> CreateAppDict(const std::string& app_id); | 91 std::unique_ptr<base::DictionaryValue> CreateAppDict( |
| 92 const AppLauncherId& app_launcher_id); |
| 58 | 93 |
| 59 // Get or set the shelf auto hide behavior preference for a particular display. | 94 // Get or set the shelf auto hide behavior preference for a particular display. |
| 60 ShelfAutoHideBehavior GetShelfAutoHideBehaviorPref(PrefService* prefs, | 95 ShelfAutoHideBehavior GetShelfAutoHideBehaviorPref(PrefService* prefs, |
| 61 int64_t display_id); | 96 int64_t display_id); |
| 62 void SetShelfAutoHideBehaviorPref(PrefService* prefs, | 97 void SetShelfAutoHideBehaviorPref(PrefService* prefs, |
| 63 int64_t display_id, | 98 int64_t display_id, |
| 64 ShelfAutoHideBehavior behavior); | 99 ShelfAutoHideBehavior behavior); |
| 65 | 100 |
| 66 // Get or set the shelf alignment preference for a particular display. | 101 // Get or set the shelf alignment preference for a particular display. |
| 67 ShelfAlignment GetShelfAlignmentPref(PrefService* prefs, int64_t display_id); | 102 ShelfAlignment GetShelfAlignmentPref(PrefService* prefs, int64_t display_id); |
| 68 void SetShelfAlignmentPref(PrefService* prefs, | 103 void SetShelfAlignmentPref(PrefService* prefs, |
| 69 int64_t display_id, | 104 int64_t display_id, |
| 70 ShelfAlignment alignment); | 105 ShelfAlignment alignment); |
| 71 | 106 |
| 72 // Get the list of pinned apps from preferences. | 107 // Get the list of pinned apps from preferences. |
| 73 std::vector<std::string> GetPinnedAppsFromPrefs( | 108 std::vector<AppLauncherId> GetPinnedAppsFromPrefs( |
| 74 const PrefService* prefs, | 109 const PrefService* prefs, |
| 75 LauncherControllerHelper* helper); | 110 LauncherControllerHelper* helper); |
| 76 | 111 |
| 77 // Removes information about pin position from sync model for the app. | 112 // Removes information about pin position from sync model for the app. |
| 78 void RemovePinPosition(Profile* profile, const std::string& app_id); | 113 void RemovePinPosition(Profile* profile, const AppLauncherId& app_launcher_id); |
| 79 | 114 |
| 80 // Updates information about pin position in sync model for the app |app_id|. | 115 // Updates information about pin position in sync model for the app |
| 81 // |app_id_before| optionally specifies an app that exists right before the | 116 // |app_launcher_id|. |app_launcher_id_before| optionally specifies an app that |
| 82 // target app. |app_ids_after| optionally specifies sorted by position apps that | 117 // exists right before the target app. |app_launcher_ids_after| optionally |
| 83 // exist right after the target app. | 118 // specifies sorted by position apps that exist right after the target app. |
| 84 void SetPinPosition(Profile* profile, | 119 void SetPinPosition(Profile* profile, |
| 85 const std::string& app_id, | 120 const AppLauncherId& app_launcher_id, |
| 86 const std::string& app_id_before, | 121 const AppLauncherId& app_launcher_id_before, |
| 87 const std::vector<std::string>& app_ids_after); | 122 const std::vector<AppLauncherId>& app_launcher_ids_after); |
| 88 | 123 |
| 89 // Used to propagate remote preferences to local during the first run. | 124 // Used to propagate remote preferences to local during the first run. |
| 90 class ChromeLauncherPrefsObserver | 125 class ChromeLauncherPrefsObserver |
| 91 : public syncable_prefs::PrefServiceSyncableObserver { | 126 : public syncable_prefs::PrefServiceSyncableObserver { |
| 92 public: | 127 public: |
| 93 // Creates and returns an instance of ChromeLauncherPrefsObserver if the | 128 // Creates and returns an instance of ChromeLauncherPrefsObserver if the |
| 94 // profile prefs do not contain all the necessary local settings for the | 129 // profile prefs do not contain all the necessary local settings for the |
| 95 // shelf. If the local settings are present, returns null. | 130 // shelf. If the local settings are present, returns null. |
| 96 static std::unique_ptr<ChromeLauncherPrefsObserver> CreateIfNecessary( | 131 static std::unique_ptr<ChromeLauncherPrefsObserver> CreateIfNecessary( |
| 97 Profile* profile); | 132 Profile* profile); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 108 // Profile prefs. Not owned. | 143 // Profile prefs. Not owned. |
| 109 syncable_prefs::PrefServiceSyncable* prefs_; | 144 syncable_prefs::PrefServiceSyncable* prefs_; |
| 110 | 145 |
| 111 DISALLOW_COPY_AND_ASSIGN(ChromeLauncherPrefsObserver); | 146 DISALLOW_COPY_AND_ASSIGN(ChromeLauncherPrefsObserver); |
| 112 }; | 147 }; |
| 113 | 148 |
| 114 } // namespace launcher | 149 } // namespace launcher |
| 115 } // namespace ash | 150 } // namespace ash |
| 116 | 151 |
| 117 #endif // CHROME_BROWSER_UI_ASH_CHROME_LAUNCHER_PREFS_H_ | 152 #endif // CHROME_BROWSER_UI_ASH_CHROME_LAUNCHER_PREFS_H_ |
| OLD | NEW |