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

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

Issue 1877543002: Revise the shelf alignment locking mechanism. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Update and cleanup tests. Created 4 years, 8 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 #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 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 } 125 }
126 126
127 const char* AlignmentToPref(ShelfAlignment alignment) { 127 const char* AlignmentToPref(ShelfAlignment alignment) {
128 switch (alignment) { 128 switch (alignment) {
129 case SHELF_ALIGNMENT_BOTTOM: 129 case SHELF_ALIGNMENT_BOTTOM:
130 return kShelfAlignmentBottom; 130 return kShelfAlignmentBottom;
131 case SHELF_ALIGNMENT_LEFT: 131 case SHELF_ALIGNMENT_LEFT:
132 return kShelfAlignmentLeft; 132 return kShelfAlignmentLeft;
133 case SHELF_ALIGNMENT_RIGHT: 133 case SHELF_ALIGNMENT_RIGHT:
134 return kShelfAlignmentRight; 134 return kShelfAlignmentRight;
135 case SHELF_ALIGNMENT_BOTTOM_LOCKED:
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.
138 return nullptr;
135 } 139 }
136 NOTREACHED(); 140 NOTREACHED();
137 return nullptr; 141 return nullptr;
138 } 142 }
139 143
140 ShelfAutoHideBehavior AutoHideBehaviorFromPref(const std::string& value) { 144 ShelfAutoHideBehavior AutoHideBehaviorFromPref(const std::string& value) {
141 // Note: To maintain sync compatibility with old images of chrome/chromeos 145 // Note: To maintain sync compatibility with old images of chrome/chromeos
142 // the set of values that may be encountered includes the now-extinct 146 // the set of values that may be encountered includes the now-extinct
143 // "Default" as well as "Never" and "Always", "Default" should now 147 // "Default" as well as "Never" and "Always", "Default" should now
144 // be treated as "Never" (http://crbug.com/146773). 148 // be treated as "Never" (http://crbug.com/146773).
145 if (value == kShelfAutoHideBehaviorAlways) 149 if (value == kShelfAutoHideBehaviorAlways)
146 return SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS; 150 return SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS;
147 return SHELF_AUTO_HIDE_BEHAVIOR_NEVER; 151 return SHELF_AUTO_HIDE_BEHAVIOR_NEVER;
148 } 152 }
149 153
150 const char* AutoHideBehaviorToPref(ShelfAutoHideBehavior behavior) { 154 const char* AutoHideBehaviorToPref(ShelfAutoHideBehavior behavior) {
151 switch (behavior) { 155 switch (behavior) {
152 case SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS: 156 case SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS:
153 return kShelfAutoHideBehaviorAlways; 157 return kShelfAutoHideBehaviorAlways;
154 case SHELF_AUTO_HIDE_BEHAVIOR_NEVER: 158 case SHELF_AUTO_HIDE_BEHAVIOR_NEVER:
155 return kShelfAutoHideBehaviorNever; 159 return kShelfAutoHideBehaviorNever;
156 case SHELF_AUTO_HIDE_ALWAYS_HIDDEN: 160 case SHELF_AUTO_HIDE_ALWAYS_HIDDEN:
157 // This one should not be a valid preference option for now. We only want 161 // This should not be a valid preference option for now. We only want to
158 // to completely hide it when we run in app mode - or while we temporarily 162 // completely hide it when we run in app mode - or while we temporarily
159 // hide the shelf as part of an animation (e.g. the multi user change). 163 // hide the shelf as part of an animation (e.g. the multi user change).
160 return nullptr; 164 return nullptr;
161 } 165 }
162 NOTREACHED(); 166 NOTREACHED();
163 return nullptr; 167 return nullptr;
164 } 168 }
165 169
166 } // namespace 170 } // namespace
167 171
168 const char kPinnedAppsPrefAppIDPath[] = "id"; 172 const char kPinnedAppsPrefAppIDPath[] = "id";
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
245 return AlignmentFromPref(GetPerDisplayPref( 249 return AlignmentFromPref(GetPerDisplayPref(
246 prefs, display_id, prefs::kShelfAlignmentLocal, prefs::kShelfAlignment)); 250 prefs, display_id, prefs::kShelfAlignmentLocal, prefs::kShelfAlignment));
247 } 251 }
248 252
249 void SetShelfAlignmentPref(PrefService* prefs, 253 void SetShelfAlignmentPref(PrefService* prefs,
250 int64_t display_id, 254 int64_t display_id,
251 ShelfAlignment alignment) { 255 ShelfAlignment alignment) {
252 DCHECK_GE(display_id, 0); 256 DCHECK_GE(display_id, 0);
253 257
254 const char* value = AlignmentToPref(alignment); 258 const char* value = AlignmentToPref(alignment);
259 if (!value)
260 return;
261
255 SetPerDisplayPref(prefs, display_id, prefs::kShelfAlignment, value); 262 SetPerDisplayPref(prefs, display_id, prefs::kShelfAlignment, value);
256 if (display_id == gfx::Screen::GetScreen()->GetPrimaryDisplay().id()) { 263 if (display_id == gfx::Screen::GetScreen()->GetPrimaryDisplay().id()) {
257 // See comment in |kShelfAlignment| as to why we consider two prefs. 264 // See comment in |kShelfAlignment| as to why we consider two prefs.
258 prefs->SetString(prefs::kShelfAlignmentLocal, value); 265 prefs->SetString(prefs::kShelfAlignmentLocal, value);
259 prefs->SetString(prefs::kShelfAlignment, value); 266 prefs->SetString(prefs::kShelfAlignment, value);
260 } 267 }
261 } 268 }
262 269
263 } // namespace ash 270 } // namespace ash
OLDNEW
« no previous file with comments | « ash/wm/window_animations.cc ('k') | chrome/browser/ui/ash/launcher/chrome_launcher_controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698