| 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 #include "chrome/browser/ui/ash/chrome_launcher_prefs.h" | 5 #include "chrome/browser/ui/ash/chrome_launcher_prefs.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <memory> | 9 #include <memory> |
| 10 | 10 |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 113 base::DictionaryValue* shelf_prefs = update.Get(); | 113 base::DictionaryValue* shelf_prefs = update.Get(); |
| 114 base::DictionaryValue* pref_dictionary = nullptr; | 114 base::DictionaryValue* pref_dictionary = nullptr; |
| 115 std::string key = base::Int64ToString(display_id); | 115 std::string key = base::Int64ToString(display_id); |
| 116 if (!shelf_prefs->GetDictionary(key, &pref_dictionary)) { | 116 if (!shelf_prefs->GetDictionary(key, &pref_dictionary)) { |
| 117 pref_dictionary = new base::DictionaryValue(); | 117 pref_dictionary = new base::DictionaryValue(); |
| 118 shelf_prefs->Set(key, pref_dictionary); | 118 shelf_prefs->Set(key, pref_dictionary); |
| 119 } | 119 } |
| 120 pref_dictionary->SetStringWithoutPathExpansion(pref_key, value); | 120 pref_dictionary->SetStringWithoutPathExpansion(pref_key, value); |
| 121 } | 121 } |
| 122 | 122 |
| 123 wm::ShelfAlignment AlignmentFromPref(const std::string& value) { | 123 ShelfAlignment AlignmentFromPref(const std::string& value) { |
| 124 if (value == kShelfAlignmentLeft) | 124 if (value == kShelfAlignmentLeft) |
| 125 return wm::SHELF_ALIGNMENT_LEFT; | 125 return SHELF_ALIGNMENT_LEFT; |
| 126 else if (value == kShelfAlignmentRight) | 126 else if (value == kShelfAlignmentRight) |
| 127 return wm::SHELF_ALIGNMENT_RIGHT; | 127 return SHELF_ALIGNMENT_RIGHT; |
| 128 // Default to bottom. | 128 // Default to bottom. |
| 129 return wm::SHELF_ALIGNMENT_BOTTOM; | 129 return SHELF_ALIGNMENT_BOTTOM; |
| 130 } | 130 } |
| 131 | 131 |
| 132 const char* AlignmentToPref(wm::ShelfAlignment alignment) { | 132 const char* AlignmentToPref(ShelfAlignment alignment) { |
| 133 switch (alignment) { | 133 switch (alignment) { |
| 134 case wm::SHELF_ALIGNMENT_BOTTOM: | 134 case SHELF_ALIGNMENT_BOTTOM: |
| 135 return kShelfAlignmentBottom; | 135 return kShelfAlignmentBottom; |
| 136 case wm::SHELF_ALIGNMENT_LEFT: | 136 case SHELF_ALIGNMENT_LEFT: |
| 137 return kShelfAlignmentLeft; | 137 return kShelfAlignmentLeft; |
| 138 case wm::SHELF_ALIGNMENT_RIGHT: | 138 case SHELF_ALIGNMENT_RIGHT: |
| 139 return kShelfAlignmentRight; | 139 return kShelfAlignmentRight; |
| 140 case wm::SHELF_ALIGNMENT_BOTTOM_LOCKED: | 140 case SHELF_ALIGNMENT_BOTTOM_LOCKED: |
| 141 // This should not be a valid preference option for now. We only want to | 141 // This should not be a valid preference option for now. We only want to |
| 142 // lock the shelf during login or when adding a user. | 142 // lock the shelf during login or when adding a user. |
| 143 return nullptr; | 143 return nullptr; |
| 144 } | 144 } |
| 145 NOTREACHED(); | 145 NOTREACHED(); |
| 146 return nullptr; | 146 return nullptr; |
| 147 } | 147 } |
| 148 | 148 |
| 149 ShelfAutoHideBehavior AutoHideBehaviorFromPref(const std::string& value) { | 149 ShelfAutoHideBehavior AutoHideBehaviorFromPref(const std::string& value) { |
| 150 // Note: To maintain sync compatibility with old images of chrome/chromeos | 150 // Note: To maintain sync compatibility with old images of chrome/chromeos |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 260 return; | 260 return; |
| 261 | 261 |
| 262 SetPerDisplayPref(prefs, display_id, prefs::kShelfAutoHideBehavior, value); | 262 SetPerDisplayPref(prefs, display_id, prefs::kShelfAutoHideBehavior, value); |
| 263 if (display_id == display::Screen::GetScreen()->GetPrimaryDisplay().id()) { | 263 if (display_id == display::Screen::GetScreen()->GetPrimaryDisplay().id()) { |
| 264 // See comment in |kShelfAlignment| about why we have two prefs here. | 264 // See comment in |kShelfAlignment| about why we have two prefs here. |
| 265 prefs->SetString(prefs::kShelfAutoHideBehaviorLocal, value); | 265 prefs->SetString(prefs::kShelfAutoHideBehaviorLocal, value); |
| 266 prefs->SetString(prefs::kShelfAutoHideBehavior, value); | 266 prefs->SetString(prefs::kShelfAutoHideBehavior, value); |
| 267 } | 267 } |
| 268 } | 268 } |
| 269 | 269 |
| 270 wm::ShelfAlignment GetShelfAlignmentPref(PrefService* prefs, | 270 ShelfAlignment GetShelfAlignmentPref(PrefService* prefs, int64_t display_id) { |
| 271 int64_t display_id) { | |
| 272 DCHECK_GE(display_id, 0); | 271 DCHECK_GE(display_id, 0); |
| 273 | 272 |
| 274 // See comment in |kShelfAlignment| as to why we consider two prefs. | 273 // See comment in |kShelfAlignment| as to why we consider two prefs. |
| 275 return AlignmentFromPref(GetPerDisplayPref( | 274 return AlignmentFromPref(GetPerDisplayPref( |
| 276 prefs, display_id, prefs::kShelfAlignmentLocal, prefs::kShelfAlignment)); | 275 prefs, display_id, prefs::kShelfAlignmentLocal, prefs::kShelfAlignment)); |
| 277 } | 276 } |
| 278 | 277 |
| 279 void SetShelfAlignmentPref(PrefService* prefs, | 278 void SetShelfAlignmentPref(PrefService* prefs, |
| 280 int64_t display_id, | 279 int64_t display_id, |
| 281 wm::ShelfAlignment alignment) { | 280 ShelfAlignment alignment) { |
| 282 DCHECK_GE(display_id, 0); | 281 DCHECK_GE(display_id, 0); |
| 283 | 282 |
| 284 const char* value = AlignmentToPref(alignment); | 283 const char* value = AlignmentToPref(alignment); |
| 285 if (!value) | 284 if (!value) |
| 286 return; | 285 return; |
| 287 | 286 |
| 288 SetPerDisplayPref(prefs, display_id, prefs::kShelfAlignment, value); | 287 SetPerDisplayPref(prefs, display_id, prefs::kShelfAlignment, value); |
| 289 if (display_id == display::Screen::GetScreen()->GetPrimaryDisplay().id()) { | 288 if (display_id == display::Screen::GetScreen()->GetPrimaryDisplay().id()) { |
| 290 // See comment in |kShelfAlignment| as to why we consider two prefs. | 289 // See comment in |kShelfAlignment| as to why we consider two prefs. |
| 291 prefs->SetString(prefs::kShelfAlignmentLocal, value); | 290 prefs->SetString(prefs::kShelfAlignmentLocal, value); |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 380 apps.push_back(extension_misc::kChromeAppId); | 379 apps.push_back(extension_misc::kChromeAppId); |
| 381 | 380 |
| 382 // If not added yet, place the app list item at the beginning of the list. | 381 // If not added yet, place the app list item at the beginning of the list. |
| 383 if (std::find(apps.begin(), apps.end(), kPinnedAppsPlaceholder) == apps.end()) | 382 if (std::find(apps.begin(), apps.end(), kPinnedAppsPlaceholder) == apps.end()) |
| 384 apps.insert(apps.begin(), kPinnedAppsPlaceholder); | 383 apps.insert(apps.begin(), kPinnedAppsPlaceholder); |
| 385 | 384 |
| 386 return apps; | 385 return apps; |
| 387 } | 386 } |
| 388 | 387 |
| 389 } // namespace ash | 388 } // namespace ash |
| OLD | NEW |