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

Side by Side Diff: chrome/browser/ui/ash/launcher/chrome_launcher_controller.cc

Issue 1839223003: Add basic Chrome interaction with the mash shelf. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Sync and rebase. 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/launcher/chrome_launcher_controller.h" 5 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <vector> 9 #include <vector>
10 10
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
214 ash::ShelfAutoHideBehavior GetShelfAutoHideBehaviorFromPrefs( 214 ash::ShelfAutoHideBehavior GetShelfAutoHideBehaviorFromPrefs(
215 Profile* profile, 215 Profile* profile,
216 aura::Window* root_window) { 216 aura::Window* root_window) {
217 DCHECK(profile); 217 DCHECK(profile);
218 218
219 // Don't show the shelf in app mode. 219 // Don't show the shelf in app mode.
220 if (chrome::IsRunningInAppMode()) 220 if (chrome::IsRunningInAppMode())
221 return ash::SHELF_AUTO_HIDE_ALWAYS_HIDDEN; 221 return ash::SHELF_AUTO_HIDE_ALWAYS_HIDDEN;
222 222
223 // See comment in |kShelfAlignment| as to why we consider two prefs. 223 // See comment in |kShelfAlignment| as to why we consider two prefs.
224 const std::string behavior_value( 224 return ash::AutoHideBehaviorFromPref(GetPrefForRootWindow(
225 GetPrefForRootWindow(profile->GetPrefs(), 225 profile->GetPrefs(), root_window, prefs::kShelfAutoHideBehaviorLocal,
226 root_window, 226 prefs::kShelfAutoHideBehavior));
227 prefs::kShelfAutoHideBehaviorLocal,
228 prefs::kShelfAutoHideBehavior));
229
230 // Note: To maintain sync compatibility with old images of chrome/chromeos
231 // the set of values that may be encountered includes the now-extinct
232 // "Default" as well as "Never" and "Always", "Default" should now
233 // be treated as "Never" (http://crbug.com/146773).
234 if (behavior_value == ash::kShelfAutoHideBehaviorAlways)
235 return ash::SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS;
236 return ash::SHELF_AUTO_HIDE_BEHAVIOR_NEVER;
237 } 227 }
238 228
239 // Gets the shelf alignment from prefs for a root window. 229 // Gets the shelf alignment from prefs for a root window.
240 ash::ShelfAlignment GetShelfAlignmentFromPrefs(Profile* profile, 230 ash::ShelfAlignment GetShelfAlignmentFromPrefs(Profile* profile,
241 aura::Window* root_window) { 231 aura::Window* root_window) {
242 DCHECK(profile); 232 DCHECK(profile);
243 233
244 // See comment in |kShelfAlignment| as to why we consider two prefs. 234 // See comment in |kShelfAlignment| as to why we consider two prefs.
245 const std::string alignment_value( 235 return ash::AlignmentFromPref(GetPrefForRootWindow(
246 GetPrefForRootWindow(profile->GetPrefs(), 236 profile->GetPrefs(), root_window, prefs::kShelfAlignmentLocal,
247 root_window, 237 prefs::kShelfAlignment));
248 prefs::kShelfAlignmentLocal,
249 prefs::kShelfAlignment));
250 if (alignment_value == ash::kShelfAlignmentLeft)
251 return ash::SHELF_ALIGNMENT_LEFT;
252 else if (alignment_value == ash::kShelfAlignmentRight)
253 return ash::SHELF_ALIGNMENT_RIGHT;
254 // Default to bottom.
255 return ash::SHELF_ALIGNMENT_BOTTOM;
256 } 238 }
257 239
258 // If prefs have synced and no user-set value exists at |local_path|, the value 240 // If prefs have synced and no user-set value exists at |local_path|, the value
259 // from |synced_path| is copied to |local_path|. 241 // from |synced_path| is copied to |local_path|.
260 void MaybePropagatePrefToLocal( 242 void MaybePropagatePrefToLocal(
261 syncable_prefs::PrefServiceSyncable* pref_service, 243 syncable_prefs::PrefServiceSyncable* pref_service,
262 const char* local_path, 244 const char* local_path,
263 const char* synced_path) { 245 const char* synced_path) {
264 if (!pref_service->FindPreference(local_path)->HasUserSetting() && 246 if (!pref_service->FindPreference(local_path)->HasUserSetting() &&
265 pref_service->IsSyncing()) { 247 pref_service->IsSyncing()) {
(...skipping 880 matching lines...) Expand 10 before | Expand all | Expand 10 after
1146 shelf->SetAutoHideBehavior( 1128 shelf->SetAutoHideBehavior(
1147 GetShelfAutoHideBehaviorFromPrefs(profile_, root_window)); 1129 GetShelfAutoHideBehaviorFromPrefs(profile_, root_window));
1148 1130
1149 if (ash::ShelfWidget::ShelfAlignmentAllowed()) 1131 if (ash::ShelfWidget::ShelfAlignmentAllowed())
1150 shelf->SetAlignment(GetShelfAlignmentFromPrefs(profile_, root_window)); 1132 shelf->SetAlignment(GetShelfAlignmentFromPrefs(profile_, root_window));
1151 } 1133 }
1152 1134
1153 void ChromeLauncherController::OnShelfDestroyed(ash::Shelf* shelf) {} 1135 void ChromeLauncherController::OnShelfDestroyed(ash::Shelf* shelf) {}
1154 1136
1155 void ChromeLauncherController::OnShelfAlignmentChanged(ash::Shelf* shelf) { 1137 void ChromeLauncherController::OnShelfAlignmentChanged(ash::Shelf* shelf) {
1156 const char* value = nullptr; 1138 const char* value = ash::AlignmentToPref(shelf->GetAlignment());
1157 switch (shelf->GetAlignment()) {
1158 case ash::SHELF_ALIGNMENT_BOTTOM:
1159 value = ash::kShelfAlignmentBottom;
1160 break;
1161 case ash::SHELF_ALIGNMENT_LEFT:
1162 value = ash::kShelfAlignmentLeft;
1163 break;
1164 case ash::SHELF_ALIGNMENT_RIGHT:
1165 value = ash::kShelfAlignmentRight;
1166 break;
1167 }
1168
1169 aura::Window* root_window = 1139 aura::Window* root_window =
1170 shelf->shelf_widget()->GetNativeWindow()->GetRootWindow(); 1140 shelf->shelf_widget()->GetNativeWindow()->GetRootWindow();
1171 1141
1172 UpdatePerDisplayPref(profile_->GetPrefs(), root_window, 1142 UpdatePerDisplayPref(profile_->GetPrefs(), root_window,
1173 prefs::kShelfAlignment, value); 1143 prefs::kShelfAlignment, value);
1174 1144
1175 if (root_window == ash::Shell::GetPrimaryRootWindow()) { 1145 if (root_window == ash::Shell::GetPrimaryRootWindow()) {
1176 // See comment in |kShelfAlignment| about why we have two prefs here. 1146 // See comment in |kShelfAlignment| about why we have two prefs here.
1177 profile_->GetPrefs()->SetString(prefs::kShelfAlignmentLocal, value); 1147 profile_->GetPrefs()->SetString(prefs::kShelfAlignmentLocal, value);
1178 profile_->GetPrefs()->SetString(prefs::kShelfAlignment, value); 1148 profile_->GetPrefs()->SetString(prefs::kShelfAlignment, value);
1179 } 1149 }
1180 } 1150 }
1181 1151
1182 void ChromeLauncherController::OnShelfAutoHideBehaviorChanged( 1152 void ChromeLauncherController::OnShelfAutoHideBehaviorChanged(
1183 ash::Shelf* shelf) { 1153 ash::Shelf* shelf) {
1184 const char* value = nullptr; 1154 const char* value = ash::AutoHideBehaviorToPref(shelf->GetAutoHideBehavior());
1185 switch (shelf->GetAutoHideBehavior()) { 1155 if (!value)
1186 case ash::SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS: 1156 return;
1187 value = ash::kShelfAutoHideBehaviorAlways;
1188 break;
1189 case ash::SHELF_AUTO_HIDE_BEHAVIOR_NEVER:
1190 value = ash::kShelfAutoHideBehaviorNever;
1191 break;
1192 case ash::SHELF_AUTO_HIDE_ALWAYS_HIDDEN:
1193 // This one should not be a valid preference option for now. We only want
1194 // to completely hide it when we run in app mode - or while we temporarily
1195 // hide the shelf as part of an animation (e.g. the multi user change).
1196 return;
1197 }
1198 1157
1199 aura::Window* root_window = 1158 aura::Window* root_window =
1200 shelf->shelf_widget()->GetNativeWindow()->GetRootWindow(); 1159 shelf->shelf_widget()->GetNativeWindow()->GetRootWindow();
1201 1160
1202 UpdatePerDisplayPref(profile_->GetPrefs(), root_window, 1161 UpdatePerDisplayPref(profile_->GetPrefs(), root_window,
1203 prefs::kShelfAutoHideBehavior, value); 1162 prefs::kShelfAutoHideBehavior, value);
1204 1163
1205 if (root_window == ash::Shell::GetPrimaryRootWindow()) { 1164 if (root_window == ash::Shell::GetPrimaryRootWindow()) {
1206 // See comment in |kShelfAlignment| about why we have two prefs here. 1165 // See comment in |kShelfAlignment| about why we have two prefs here.
1207 profile_->GetPrefs()->SetString(prefs::kShelfAutoHideBehaviorLocal, value); 1166 profile_->GetPrefs()->SetString(prefs::kShelfAutoHideBehaviorLocal, value);
(...skipping 1020 matching lines...) Expand 10 before | Expand all | Expand 10 after
2228 2187
2229 AppIconLoader* ChromeLauncherController::GetAppIconLoaderForApp( 2188 AppIconLoader* ChromeLauncherController::GetAppIconLoaderForApp(
2230 const std::string& app_id) { 2189 const std::string& app_id) {
2231 for (const auto& app_icon_loader : app_icon_loaders_) { 2190 for (const auto& app_icon_loader : app_icon_loaders_) {
2232 if (app_icon_loader->CanLoadImageForApp(app_id)) 2191 if (app_icon_loader->CanLoadImageForApp(app_id))
2233 return app_icon_loader.get(); 2192 return app_icon_loader.get();
2234 } 2193 }
2235 2194
2236 return nullptr; 2195 return nullptr;
2237 } 2196 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/ash/chrome_launcher_prefs.cc ('k') | chrome/browser/ui/ash/launcher/chrome_mash_shelf_controller.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698