| 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 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 108 base::DictionaryValue* shelf_prefs = update.Get(); | 108 base::DictionaryValue* shelf_prefs = update.Get(); |
| 109 base::DictionaryValue* pref_dictionary = nullptr; | 109 base::DictionaryValue* pref_dictionary = nullptr; |
| 110 std::string key = base::Int64ToString(display_id); | 110 std::string key = base::Int64ToString(display_id); |
| 111 if (!shelf_prefs->GetDictionary(key, &pref_dictionary)) { | 111 if (!shelf_prefs->GetDictionary(key, &pref_dictionary)) { |
| 112 pref_dictionary = new base::DictionaryValue(); | 112 pref_dictionary = new base::DictionaryValue(); |
| 113 shelf_prefs->Set(key, pref_dictionary); | 113 shelf_prefs->Set(key, pref_dictionary); |
| 114 } | 114 } |
| 115 pref_dictionary->SetStringWithoutPathExpansion(pref_key, value); | 115 pref_dictionary->SetStringWithoutPathExpansion(pref_key, value); |
| 116 } | 116 } |
| 117 | 117 |
| 118 ShelfAlignment AlignmentFromPref(const std::string& value) { | 118 wm::ShelfAlignment AlignmentFromPref(const std::string& value) { |
| 119 if (value == kShelfAlignmentLeft) | 119 if (value == kShelfAlignmentLeft) |
| 120 return SHELF_ALIGNMENT_LEFT; | 120 return wm::SHELF_ALIGNMENT_LEFT; |
| 121 else if (value == kShelfAlignmentRight) | 121 else if (value == kShelfAlignmentRight) |
| 122 return SHELF_ALIGNMENT_RIGHT; | 122 return wm::SHELF_ALIGNMENT_RIGHT; |
| 123 // Default to bottom. | 123 // Default to bottom. |
| 124 return SHELF_ALIGNMENT_BOTTOM; | 124 return wm::SHELF_ALIGNMENT_BOTTOM; |
| 125 } | 125 } |
| 126 | 126 |
| 127 const char* AlignmentToPref(ShelfAlignment alignment) { | 127 const char* AlignmentToPref(wm::ShelfAlignment alignment) { |
| 128 switch (alignment) { | 128 switch (alignment) { |
| 129 case SHELF_ALIGNMENT_BOTTOM: | 129 case wm::SHELF_ALIGNMENT_BOTTOM: |
| 130 return kShelfAlignmentBottom; | 130 return kShelfAlignmentBottom; |
| 131 case SHELF_ALIGNMENT_LEFT: | 131 case wm::SHELF_ALIGNMENT_LEFT: |
| 132 return kShelfAlignmentLeft; | 132 return kShelfAlignmentLeft; |
| 133 case SHELF_ALIGNMENT_RIGHT: | 133 case wm::SHELF_ALIGNMENT_RIGHT: |
| 134 return kShelfAlignmentRight; | 134 return kShelfAlignmentRight; |
| 135 case SHELF_ALIGNMENT_BOTTOM_LOCKED: | 135 case wm::SHELF_ALIGNMENT_BOTTOM_LOCKED: |
| 136 // This should not be a valid preference option for now. We only want to | 136 // This should not be a valid preference option for now. We only want to |
| 137 // lock the shelf during login or when adding a user. | 137 // lock the shelf during login or when adding a user. |
| 138 return nullptr; | 138 return nullptr; |
| 139 } | 139 } |
| 140 NOTREACHED(); | 140 NOTREACHED(); |
| 141 return nullptr; | 141 return nullptr; |
| 142 } | 142 } |
| 143 | 143 |
| 144 ShelfAutoHideBehavior AutoHideBehaviorFromPref(const std::string& value) { | 144 ShelfAutoHideBehavior AutoHideBehaviorFromPref(const std::string& value) { |
| 145 // Note: To maintain sync compatibility with old images of chrome/chromeos | 145 // Note: To maintain sync compatibility with old images of chrome/chromeos |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 235 return; | 235 return; |
| 236 | 236 |
| 237 SetPerDisplayPref(prefs, display_id, prefs::kShelfAutoHideBehavior, value); | 237 SetPerDisplayPref(prefs, display_id, prefs::kShelfAutoHideBehavior, value); |
| 238 if (display_id == gfx::Screen::GetScreen()->GetPrimaryDisplay().id()) { | 238 if (display_id == gfx::Screen::GetScreen()->GetPrimaryDisplay().id()) { |
| 239 // See comment in |kShelfAlignment| about why we have two prefs here. | 239 // See comment in |kShelfAlignment| about why we have two prefs here. |
| 240 prefs->SetString(prefs::kShelfAutoHideBehaviorLocal, value); | 240 prefs->SetString(prefs::kShelfAutoHideBehaviorLocal, value); |
| 241 prefs->SetString(prefs::kShelfAutoHideBehavior, value); | 241 prefs->SetString(prefs::kShelfAutoHideBehavior, value); |
| 242 } | 242 } |
| 243 } | 243 } |
| 244 | 244 |
| 245 ShelfAlignment GetShelfAlignmentPref(PrefService* prefs, int64_t display_id) { | 245 wm::ShelfAlignment GetShelfAlignmentPref(PrefService* prefs, |
| 246 int64_t display_id) { |
| 246 DCHECK_GE(display_id, 0); | 247 DCHECK_GE(display_id, 0); |
| 247 | 248 |
| 248 // See comment in |kShelfAlignment| as to why we consider two prefs. | 249 // See comment in |kShelfAlignment| as to why we consider two prefs. |
| 249 return AlignmentFromPref(GetPerDisplayPref( | 250 return AlignmentFromPref(GetPerDisplayPref( |
| 250 prefs, display_id, prefs::kShelfAlignmentLocal, prefs::kShelfAlignment)); | 251 prefs, display_id, prefs::kShelfAlignmentLocal, prefs::kShelfAlignment)); |
| 251 } | 252 } |
| 252 | 253 |
| 253 void SetShelfAlignmentPref(PrefService* prefs, | 254 void SetShelfAlignmentPref(PrefService* prefs, |
| 254 int64_t display_id, | 255 int64_t display_id, |
| 255 ShelfAlignment alignment) { | 256 wm::ShelfAlignment alignment) { |
| 256 DCHECK_GE(display_id, 0); | 257 DCHECK_GE(display_id, 0); |
| 257 | 258 |
| 258 const char* value = AlignmentToPref(alignment); | 259 const char* value = AlignmentToPref(alignment); |
| 259 if (!value) | 260 if (!value) |
| 260 return; | 261 return; |
| 261 | 262 |
| 262 SetPerDisplayPref(prefs, display_id, prefs::kShelfAlignment, value); | 263 SetPerDisplayPref(prefs, display_id, prefs::kShelfAlignment, value); |
| 263 if (display_id == gfx::Screen::GetScreen()->GetPrimaryDisplay().id()) { | 264 if (display_id == gfx::Screen::GetScreen()->GetPrimaryDisplay().id()) { |
| 264 // See comment in |kShelfAlignment| as to why we consider two prefs. | 265 // See comment in |kShelfAlignment| as to why we consider two prefs. |
| 265 prefs->SetString(prefs::kShelfAlignmentLocal, value); | 266 prefs->SetString(prefs::kShelfAlignmentLocal, value); |
| 266 prefs->SetString(prefs::kShelfAlignment, value); | 267 prefs->SetString(prefs::kShelfAlignment, value); |
| 267 } | 268 } |
| 268 } | 269 } |
| 269 | 270 |
| 270 } // namespace ash | 271 } // namespace ash |
| OLD | NEW |