| OLD | NEW |
| 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 "ash/multi_profile_uma.h" | 7 #include "ash/multi_profile_uma.h" |
| 8 #include "ash/public/cpp/remote_shelf_item_delegate.h" |
| 8 #include "ash/public/cpp/shelf_item.h" | 9 #include "ash/public/cpp/shelf_item.h" |
| 9 #include "ash/public/interfaces/constants.mojom.h" | 10 #include "ash/public/interfaces/constants.mojom.h" |
| 10 #include "ash/resources/grit/ash_resources.h" | 11 #include "ash/resources/grit/ash_resources.h" |
| 11 #include "ash/shelf/shelf.h" | 12 #include "ash/shelf/shelf.h" |
| 12 #include "ash/shelf/shelf_model.h" | 13 #include "ash/shelf/shelf_model.h" |
| 13 #include "ash/shell.h" | 14 #include "ash/shell.h" |
| 14 #include "ash/shell_port.h" | 15 #include "ash/shell_port.h" |
| 15 #include "ash/strings/grit/ash_strings.h" | 16 #include "ash/strings/grit/ash_strings.h" |
| 16 #include "ash/system/tray/system_tray_delegate.h" | 17 #include "ash/system/tray/system_tray_delegate.h" |
| 17 #include "ash/wm_window.h" | 18 #include "ash/wm_window.h" |
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 176 chrome::MultiUserWindowManager::MULTI_PROFILE_MODE_SEPARATED) | 177 chrome::MultiUserWindowManager::MULTI_PROFILE_MODE_SEPARATED) |
| 177 chrome::MultiUserWindowManager::GetInstance()->AddUser(profile); | 178 chrome::MultiUserWindowManager::GetInstance()->AddUser(profile); |
| 178 controller_->AdditionalUserAddedToSession(profile->GetOriginalProfile()); | 179 controller_->AdditionalUserAddedToSession(profile->GetOriginalProfile()); |
| 179 } | 180 } |
| 180 | 181 |
| 181 // static | 182 // static |
| 182 ChromeLauncherController* ChromeLauncherController::instance_ = nullptr; | 183 ChromeLauncherController* ChromeLauncherController::instance_ = nullptr; |
| 183 | 184 |
| 184 ChromeLauncherController::ChromeLauncherController(Profile* profile, | 185 ChromeLauncherController::ChromeLauncherController(Profile* profile, |
| 185 ash::ShelfModel* model) | 186 ash::ShelfModel* model) |
| 186 : model_(model), observer_binding_(this), weak_ptr_factory_(this) { | 187 : model_(model), |
| 188 observer_binding_(this), |
| 189 shelf_model_observer_binding_(this), |
| 190 weak_ptr_factory_(this) { |
| 187 DCHECK(!instance_); | 191 DCHECK(!instance_); |
| 188 instance_ = this; | 192 instance_ = this; |
| 189 | 193 |
| 190 DCHECK(model_); | 194 DCHECK(model_); |
| 191 | 195 |
| 192 if (!profile) { | 196 if (!profile) { |
| 193 // If no profile was passed, we take the currently active profile and use it | 197 // If no profile was passed, we take the currently active profile and use it |
| 194 // as the owner of the current desktop. | 198 // as the owner of the current desktop. |
| 195 // Use the original profile as on chromeos we may get a temporary off the | 199 // Use the original profile as on chromeos we may get a temporary off the |
| 196 // record profile, unless in guest session (where off the record profile is | 200 // record profile, unless in guest session (where off the record profile is |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 273 if (instance_ == this) | 277 if (instance_ == this) |
| 274 instance_ = nullptr; | 278 instance_ = nullptr; |
| 275 } | 279 } |
| 276 | 280 |
| 277 void ChromeLauncherController::Init() { | 281 void ChromeLauncherController::Init() { |
| 278 // Start observing the shelf controller. | 282 // Start observing the shelf controller. |
| 279 if (ConnectToShelfController()) { | 283 if (ConnectToShelfController()) { |
| 280 ash::mojom::ShelfObserverAssociatedPtrInfo ptr_info; | 284 ash::mojom::ShelfObserverAssociatedPtrInfo ptr_info; |
| 281 observer_binding_.Bind(mojo::MakeRequest(&ptr_info)); | 285 observer_binding_.Bind(mojo::MakeRequest(&ptr_info)); |
| 282 shelf_controller_->AddObserver(std::move(ptr_info)); | 286 shelf_controller_->AddObserver(std::move(ptr_info)); |
| 287 if (ash_util::IsRunningInMash()) { |
| 288 // Mash synchronizes two ShelfModel instances, owned by Ash and Chrome. |
| 289 // Delay binding Chrome's observer of Ash for now, to avoid handling Ash's |
| 290 // shelf model changes before the initial states have been synchronized. |
| 291 ash::mojom::ShelfModelObserverPtr observer_ptr; |
| 292 shelf_model_observer_request_ = mojo::MakeRequest(&observer_ptr); |
| 293 shelf_controller_->LinkShelfModels( |
| 294 std::move(observer_ptr), |
| 295 base::Bind(&ChromeLauncherController::LinkShelfModels, |
| 296 weak_ptr_factory_.GetWeakPtr())); |
| 297 } |
| 283 } | 298 } |
| 284 | 299 |
| 285 CreateBrowserShortcutLauncherItem(); | 300 CreateBrowserShortcutLauncherItem(); |
| 286 UpdateAppLaunchersFromPref(); | 301 UpdateAppLaunchersFromPref(); |
| 287 | 302 |
| 288 // TODO(sky): update unit test so that this test isn't necessary. | 303 // TODO(sky): update unit test so that this test isn't necessary. |
| 289 if (ash::Shell::HasInstance()) | 304 if (ash::Shell::HasInstance()) |
| 290 SetVirtualKeyboardBehaviorFromPrefs(); | 305 SetVirtualKeyboardBehaviorFromPrefs(); |
| 291 | 306 |
| 292 prefs_observer_ = ChromeLauncherPrefsObserver::CreateIfNecessary(profile()); | 307 prefs_observer_ = ChromeLauncherPrefsObserver::CreateIfNecessary(profile()); |
| (...skipping 937 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1230 pref_change_registrar_.RemoveAll(); | 1245 pref_change_registrar_.RemoveAll(); |
| 1231 | 1246 |
| 1232 app_list::AppListSyncableService* app_service = | 1247 app_list::AppListSyncableService* app_service = |
| 1233 app_list::AppListSyncableServiceFactory::GetForProfile(profile()); | 1248 app_list::AppListSyncableServiceFactory::GetForProfile(profile()); |
| 1234 if (app_service) | 1249 if (app_service) |
| 1235 app_service->RemoveObserver(this); | 1250 app_service->RemoveObserver(this); |
| 1236 | 1251 |
| 1237 PrefServiceSyncableFromProfile(profile())->RemoveObserver(this); | 1252 PrefServiceSyncableFromProfile(profile())->RemoveObserver(this); |
| 1238 } | 1253 } |
| 1239 | 1254 |
| 1255 void ChromeLauncherController::LinkShelfModels( |
| 1256 ash::mojom::ShelfModelObserverPtr observer, |
| 1257 const std::vector<ash::ShelfItem>& items) { |
| 1258 // Prepend Ash's shelf model items to the local (Chrome) shelf model. |
| 1259 DCHECK(!applying_remote_shelf_model_changes_) << "Unexpected model change"; |
| 1260 base::AutoReset<bool> reset(&applying_remote_shelf_model_changes_, true); |
| 1261 for (size_t i = 0; i < items.size(); ++i) |
| 1262 model_->AddAt(i, items[i]); |
| 1263 |
| 1264 // Notify Ash of all the other existing local (Chrome) items and delegates. |
| 1265 for (int32_t i = items.size(); i < model_->item_count(); ++i) { |
| 1266 const ash::ShelfItem& item = model_->items()[i]; |
| 1267 observer->OnShelfItemAdded(i, item); |
| 1268 ash::ShelfItemDelegate* delegate = model_->GetShelfItemDelegate(item.id); |
| 1269 observer->OnShelfItemDelegateChanged( |
| 1270 item.id, delegate ? delegate->CreateInterfacePtrAndBind() |
| 1271 : ash::mojom::ShelfItemDelegatePtr()); |
| 1272 } |
| 1273 |
| 1274 // Delay binding Chrome's observer of Ash until now, to avoid handling Ash's |
| 1275 // shelf model changes before the initial states have been synchronized. |
| 1276 shelf_model_observer_binding_.Bind(std::move(shelf_model_observer_request_)); |
| 1277 shelf_model_observers_.AddPtr(std::move(observer)); |
| 1278 } |
| 1279 |
| 1240 /////////////////////////////////////////////////////////////////////////////// | 1280 /////////////////////////////////////////////////////////////////////////////// |
| 1241 // ash::mojom::ShelfObserver: | 1281 // ash::mojom::ShelfObserver: |
| 1242 | 1282 |
| 1243 void ChromeLauncherController::OnShelfInitialized(int64_t display_id) { | 1283 void ChromeLauncherController::OnShelfInitialized(int64_t display_id) { |
| 1244 if (!ConnectToShelfController()) | 1284 if (!ConnectToShelfController()) |
| 1245 return; | 1285 return; |
| 1246 | 1286 |
| 1247 // The pref helper functions return default values for invalid display ids. | 1287 // The pref helper functions return default values for invalid display ids. |
| 1248 PrefService* prefs = profile_->GetPrefs(); | 1288 PrefService* prefs = profile_->GetPrefs(); |
| 1249 shelf_controller_->SetAlignment(GetShelfAlignmentPref(prefs, display_id), | 1289 shelf_controller_->SetAlignment(GetShelfAlignmentPref(prefs, display_id), |
| (...skipping 16 matching lines...) Expand all Loading... |
| 1266 void ChromeLauncherController::OnAutoHideBehaviorChanged( | 1306 void ChromeLauncherController::OnAutoHideBehaviorChanged( |
| 1267 ash::ShelfAutoHideBehavior auto_hide, | 1307 ash::ShelfAutoHideBehavior auto_hide, |
| 1268 int64_t display_id) { | 1308 int64_t display_id) { |
| 1269 DCHECK(!updating_shelf_pref_from_observer_); | 1309 DCHECK(!updating_shelf_pref_from_observer_); |
| 1270 base::AutoReset<bool> updating(&updating_shelf_pref_from_observer_, true); | 1310 base::AutoReset<bool> updating(&updating_shelf_pref_from_observer_, true); |
| 1271 // This will uselessly store a preference value for invalid display ids. | 1311 // This will uselessly store a preference value for invalid display ids. |
| 1272 SetShelfAutoHideBehaviorPref(profile_->GetPrefs(), display_id, auto_hide); | 1312 SetShelfAutoHideBehaviorPref(profile_->GetPrefs(), display_id, auto_hide); |
| 1273 } | 1313 } |
| 1274 | 1314 |
| 1275 /////////////////////////////////////////////////////////////////////////////// | 1315 /////////////////////////////////////////////////////////////////////////////// |
| 1316 // ash::mojom::ShelfModelObserver: |
| 1317 |
| 1318 void ChromeLauncherController::OnShelfItemAdded(int32_t index, |
| 1319 const ash::ShelfItem& item) { |
| 1320 DCHECK(ash_util::IsRunningInMash()) << "Unexpected model synchronization"; |
| 1321 DCHECK(!applying_remote_shelf_model_changes_) << "Unexpected model change"; |
| 1322 DCHECK_GE(model_->item_count(), index) << "Models out of sync"; |
| 1323 base::AutoReset<bool> reset(&applying_remote_shelf_model_changes_, true); |
| 1324 model_->AddAt(index, item); |
| 1325 } |
| 1326 |
| 1327 void ChromeLauncherController::OnShelfItemRemoved(int32_t index, |
| 1328 const ash::ShelfItem& item) { |
| 1329 DCHECK(ash_util::IsRunningInMash()) << "Unexpected model synchronization"; |
| 1330 DCHECK(!applying_remote_shelf_model_changes_) << "Unexpected model change"; |
| 1331 DCHECK_GT(model_->item_count(), index) << "Models out of sync"; |
| 1332 DCHECK_EQ(model_->items()[index].id, item.id) << "Models out of sync"; |
| 1333 base::AutoReset<bool> reset(&applying_remote_shelf_model_changes_, true); |
| 1334 model_->RemoveItemAt(index); |
| 1335 } |
| 1336 |
| 1337 void ChromeLauncherController::OnShelfItemMoved(int32_t start_index, |
| 1338 int32_t target_index) { |
| 1339 DCHECK(ash_util::IsRunningInMash()) << "Unexpected model synchronization"; |
| 1340 DCHECK(!applying_remote_shelf_model_changes_) << "Unexpected model change"; |
| 1341 DCHECK_GT(model_->item_count(), start_index) << "Models out of sync"; |
| 1342 DCHECK_GT(model_->item_count(), target_index) << "Models out of sync"; |
| 1343 base::AutoReset<bool> reset(&applying_remote_shelf_model_changes_, true); |
| 1344 model_->Move(start_index, target_index); |
| 1345 } |
| 1346 |
| 1347 void ChromeLauncherController::OnShelfItemChanged(int32_t index, |
| 1348 const ash::ShelfItem& item) { |
| 1349 DCHECK(ash_util::IsRunningInMash()) << "Unexpected model synchronization"; |
| 1350 DCHECK(!applying_remote_shelf_model_changes_) << "Unexpected model change"; |
| 1351 DCHECK_GT(model_->item_count(), index) << "Models out of sync"; |
| 1352 DCHECK_EQ(model_->items()[index].id, item.id) << "Models out of sync"; |
| 1353 base::AutoReset<bool> reset(&applying_remote_shelf_model_changes_, true); |
| 1354 model_->Set(index, item); |
| 1355 } |
| 1356 |
| 1357 void ChromeLauncherController::OnShelfItemDelegateChanged( |
| 1358 const ash::ShelfID& id, |
| 1359 ash::mojom::ShelfItemDelegatePtr delegate) { |
| 1360 DCHECK(ash_util::IsRunningInMash()) << "Unexpected model synchronization"; |
| 1361 DCHECK(!applying_remote_shelf_model_changes_) << "Unexpected model change"; |
| 1362 base::AutoReset<bool> reset(&applying_remote_shelf_model_changes_, true); |
| 1363 if (delegate.is_bound()) |
| 1364 model_->SetShelfItemDelegate(id, |
| 1365 base::MakeUnique<ash::RemoteShelfItemDelegate>( |
| 1366 id, std::move(delegate))); |
| 1367 else |
| 1368 model_->SetShelfItemDelegate(id, nullptr); |
| 1369 } |
| 1370 |
| 1371 /////////////////////////////////////////////////////////////////////////////// |
| 1276 // ash::ShelfModelObserver: | 1372 // ash::ShelfModelObserver: |
| 1277 | 1373 |
| 1278 void ChromeLauncherController::ShelfItemAdded(int index) { | 1374 void ChromeLauncherController::ShelfItemAdded(int index) { |
| 1375 ash::ShelfItem item = model_->items()[index]; |
| 1376 if (!applying_remote_shelf_model_changes_) { |
| 1377 shelf_model_observers_.ForAllPtrs( |
| 1378 [index, item](ash::mojom::ShelfModelObserver* observer) { |
| 1379 observer->OnShelfItemAdded(index, item); |
| 1380 }); |
| 1381 } |
| 1382 |
| 1279 // Update the pin position preference as needed. | 1383 // Update the pin position preference as needed. |
| 1280 ash::ShelfItem item = model_->items()[index]; | |
| 1281 if (ItemTypeIsPinned(item) && should_sync_pin_changes_) | 1384 if (ItemTypeIsPinned(item) && should_sync_pin_changes_) |
| 1282 SyncPinPosition(item.id); | 1385 SyncPinPosition(item.id); |
| 1283 | 1386 |
| 1284 // Fetch and update the icon for the app's item. | 1387 // Fetch and update the icon for the app's item. |
| 1285 const std::string& app_id = item.id.app_id; | 1388 const std::string& app_id = item.id.app_id; |
| 1286 AppIconLoader* app_icon_loader = GetAppIconLoaderForApp(app_id); | 1389 AppIconLoader* app_icon_loader = GetAppIconLoaderForApp(app_id); |
| 1287 if (app_icon_loader) { | 1390 if (app_icon_loader) { |
| 1288 app_icon_loader->FetchImage(app_id); | 1391 app_icon_loader->FetchImage(app_id); |
| 1289 app_icon_loader->UpdateImage(app_id); | 1392 app_icon_loader->UpdateImage(app_id); |
| 1290 } | 1393 } |
| 1291 | 1394 |
| 1292 // Update the item with any missing Chrome-specific info. | 1395 // Update the item with any missing Chrome-specific info. |
| 1293 if (item.type == ash::TYPE_APP || item.type == ash::TYPE_PINNED_APP) { | 1396 if (item.type == ash::TYPE_APP || item.type == ash::TYPE_PINNED_APP) { |
| 1294 bool needs_update = false; | 1397 bool needs_update = false; |
| 1295 if (item.image.isNull()) { | 1398 if (item.image.isNull()) { |
| 1296 needs_update = true; | 1399 needs_update = true; |
| 1297 item.image = extensions::util::GetDefaultAppIcon(); | 1400 item.image = extensions::util::GetDefaultAppIcon(); |
| 1298 } | 1401 } |
| 1299 if (item.title.empty()) { | 1402 if (item.title.empty()) { |
| 1300 needs_update = true; | 1403 needs_update = true; |
| 1301 item.title = LauncherControllerHelper::GetAppTitle(profile(), app_id); | 1404 item.title = LauncherControllerHelper::GetAppTitle(profile(), app_id); |
| 1302 } | 1405 } |
| 1303 ash::ShelfItemStatus status = GetAppState(app_id); | 1406 ash::ShelfItemStatus status = GetAppState(app_id); |
| 1304 if (status != item.status && status != ash::STATUS_CLOSED) { | 1407 if (status != item.status && status != ash::STATUS_CLOSED) { |
| 1305 needs_update = true; | 1408 needs_update = true; |
| 1306 item.status = status; | 1409 item.status = status; |
| 1307 } | 1410 } |
| 1308 if (needs_update) | 1411 if (needs_update) { |
| 1412 // Ensure these changes are reported back to Ash. |
| 1413 base::AutoReset<bool> reset(&applying_remote_shelf_model_changes_, false); |
| 1309 model_->Set(index, item); | 1414 model_->Set(index, item); |
| 1415 } |
| 1310 } | 1416 } |
| 1311 | 1417 |
| 1312 // Construct a ShelfItemDelegate for the item if one does not yet exist. | 1418 // Construct a ShelfItemDelegate for the item if one does not yet exist. |
| 1313 if (!model_->GetShelfItemDelegate(item.id)) { | 1419 if (!model_->GetShelfItemDelegate(item.id)) { |
| 1420 // Ensure these changes are reported back to Ash. |
| 1421 base::AutoReset<bool> reset(&applying_remote_shelf_model_changes_, false); |
| 1314 model_->SetShelfItemDelegate( | 1422 model_->SetShelfItemDelegate( |
| 1315 item.id, AppShortcutLauncherItemController::Create(item.id)); | 1423 item.id, AppShortcutLauncherItemController::Create(item.id)); |
| 1316 } | 1424 } |
| 1317 } | 1425 } |
| 1318 | 1426 |
| 1319 void ChromeLauncherController::ShelfItemRemoved( | 1427 void ChromeLauncherController::ShelfItemRemoved( |
| 1320 int index, | 1428 int index, |
| 1321 const ash::ShelfItem& old_item) { | 1429 const ash::ShelfItem& old_item) { |
| 1430 if (!applying_remote_shelf_model_changes_) { |
| 1431 shelf_model_observers_.ForAllPtrs( |
| 1432 [index, old_item](ash::mojom::ShelfModelObserver* observer) { |
| 1433 observer->OnShelfItemRemoved(index, old_item); |
| 1434 }); |
| 1435 } |
| 1436 |
| 1322 // Remove the pin position from preferences as needed. | 1437 // Remove the pin position from preferences as needed. |
| 1323 if (ItemTypeIsPinned(old_item) && should_sync_pin_changes_) | 1438 if (ItemTypeIsPinned(old_item) && should_sync_pin_changes_) |
| 1324 RemovePinPosition(profile(), old_item.id); | 1439 RemovePinPosition(profile(), old_item.id); |
| 1325 | 1440 |
| 1326 AppIconLoader* app_icon_loader = GetAppIconLoaderForApp(old_item.id.app_id); | 1441 AppIconLoader* app_icon_loader = GetAppIconLoaderForApp(old_item.id.app_id); |
| 1327 if (app_icon_loader) | 1442 if (app_icon_loader) |
| 1328 app_icon_loader->ClearImage(old_item.id.app_id); | 1443 app_icon_loader->ClearImage(old_item.id.app_id); |
| 1329 } | 1444 } |
| 1330 | 1445 |
| 1331 void ChromeLauncherController::ShelfItemMoved(int start_index, | 1446 void ChromeLauncherController::ShelfItemMoved(int start_index, |
| 1332 int target_index) { | 1447 int target_index) { |
| 1448 if (!applying_remote_shelf_model_changes_) { |
| 1449 shelf_model_observers_.ForAllPtrs( |
| 1450 [start_index, target_index](ash::mojom::ShelfModelObserver* observer) { |
| 1451 observer->OnShelfItemMoved(start_index, target_index); |
| 1452 }); |
| 1453 } |
| 1454 |
| 1333 // Update the pin position preference as needed. | 1455 // Update the pin position preference as needed. |
| 1334 const ash::ShelfItem& item = model_->items()[target_index]; | 1456 const ash::ShelfItem& item = model_->items()[target_index]; |
| 1335 DCHECK_NE(ash::TYPE_APP_LIST, item.type); | 1457 DCHECK_NE(ash::TYPE_APP_LIST, item.type); |
| 1336 if (ItemTypeIsPinned(item) && should_sync_pin_changes_) | 1458 if (ItemTypeIsPinned(item) && should_sync_pin_changes_) |
| 1337 SyncPinPosition(item.id); | 1459 SyncPinPosition(item.id); |
| 1338 } | 1460 } |
| 1339 | 1461 |
| 1340 void ChromeLauncherController::ShelfItemChanged( | 1462 void ChromeLauncherController::ShelfItemChanged( |
| 1341 int index, | 1463 int index, |
| 1342 const ash::ShelfItem& old_item) { | 1464 const ash::ShelfItem& old_item) { |
| 1465 if (!applying_remote_shelf_model_changes_) { |
| 1466 const ash::ShelfItem& item = model_->items()[index]; |
| 1467 shelf_model_observers_.ForAllPtrs( |
| 1468 [index, item](ash::mojom::ShelfModelObserver* observer) { |
| 1469 observer->OnShelfItemChanged(index, item); |
| 1470 }); |
| 1471 } |
| 1472 |
| 1343 if (!should_sync_pin_changes_) | 1473 if (!should_sync_pin_changes_) |
| 1344 return; | 1474 return; |
| 1345 | 1475 |
| 1346 const ash::ShelfItem& item = model_->items()[index]; | 1476 const ash::ShelfItem& item = model_->items()[index]; |
| 1347 // Add or remove the pin position from preferences as needed. | 1477 // Add or remove the pin position from preferences as needed. |
| 1348 if (!ItemTypeIsPinned(old_item) && ItemTypeIsPinned(item)) | 1478 if (!ItemTypeIsPinned(old_item) && ItemTypeIsPinned(item)) |
| 1349 SyncPinPosition(item.id); | 1479 SyncPinPosition(item.id); |
| 1350 else if (ItemTypeIsPinned(old_item) && !ItemTypeIsPinned(item)) | 1480 else if (ItemTypeIsPinned(old_item) && !ItemTypeIsPinned(item)) |
| 1351 RemovePinPosition(profile(), old_item.id); | 1481 RemovePinPosition(profile(), old_item.id); |
| 1352 } | 1482 } |
| 1353 | 1483 |
| 1484 void ChromeLauncherController::ShelfItemDelegateChanged( |
| 1485 const ash::ShelfID& id, |
| 1486 ash::ShelfItemDelegate* delegate) { |
| 1487 if (applying_remote_shelf_model_changes_) |
| 1488 return; |
| 1489 |
| 1490 shelf_model_observers_.ForAllPtrs( |
| 1491 [id, delegate](ash::mojom::ShelfModelObserver* observer) { |
| 1492 observer->OnShelfItemDelegateChanged( |
| 1493 id, delegate ? delegate->CreateInterfacePtrAndBind() |
| 1494 : ash::mojom::ShelfItemDelegatePtr()); |
| 1495 }); |
| 1496 } |
| 1497 |
| 1354 /////////////////////////////////////////////////////////////////////////////// | 1498 /////////////////////////////////////////////////////////////////////////////// |
| 1355 // ash::WindowTreeHostManager::Observer: | 1499 // ash::WindowTreeHostManager::Observer: |
| 1356 | 1500 |
| 1357 void ChromeLauncherController::OnDisplayConfigurationChanged() { | 1501 void ChromeLauncherController::OnDisplayConfigurationChanged() { |
| 1358 // In BOTTOM_LOCKED state, ignore the call of SetShelfBehaviorsFromPrefs. | 1502 // In BOTTOM_LOCKED state, ignore the call of SetShelfBehaviorsFromPrefs. |
| 1359 // Because it might be called by some operations, like crbug.com/627040 | 1503 // Because it might be called by some operations, like crbug.com/627040 |
| 1360 // rotating screen. | 1504 // rotating screen. |
| 1361 ash::Shelf* shelf = ash::Shelf::ForWindow(ash::Shell::GetPrimaryRootWindow()); | 1505 ash::Shelf* shelf = ash::Shelf::ForWindow(ash::Shell::GetPrimaryRootWindow()); |
| 1362 if (shelf->alignment() != ash::SHELF_ALIGNMENT_BOTTOM_LOCKED) | 1506 if (shelf->alignment() != ash::SHELF_ALIGNMENT_BOTTOM_LOCKED) |
| 1363 SetShelfBehaviorsFromPrefs(); | 1507 SetShelfBehaviorsFromPrefs(); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 1374 : IDS_ASH_SHELF_APP_LIST_LAUNCHER_TITLE); | 1518 : IDS_ASH_SHELF_APP_LIST_LAUNCHER_TITLE); |
| 1375 | 1519 |
| 1376 const int app_list_index = model_->GetItemIndexForType(ash::TYPE_APP_LIST); | 1520 const int app_list_index = model_->GetItemIndexForType(ash::TYPE_APP_LIST); |
| 1377 DCHECK_GE(app_list_index, 0); | 1521 DCHECK_GE(app_list_index, 0); |
| 1378 ash::ShelfItem item = model_->items()[app_list_index]; | 1522 ash::ShelfItem item = model_->items()[app_list_index]; |
| 1379 if (item.title != title) { | 1523 if (item.title != title) { |
| 1380 item.title = title; | 1524 item.title = title; |
| 1381 model_->Set(app_list_index, item); | 1525 model_->Set(app_list_index, item); |
| 1382 } | 1526 } |
| 1383 } | 1527 } |
| OLD | NEW |