| 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_impl.h" | 5 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller_impl.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "ash/common/ash_switches.h" | 11 #include "ash/common/ash_switches.h" |
| 12 #include "ash/common/multi_profile_uma.h" | 12 #include "ash/common/multi_profile_uma.h" |
| 13 #include "ash/common/shelf/shelf.h" | 13 #include "ash/common/shelf/shelf.h" |
| 14 #include "ash/common/shelf/shelf_model.h" | 14 #include "ash/common/shelf/shelf_model.h" |
| 15 #include "ash/common/shelf/wm_shelf.h" |
| 15 #include "ash/common/system/tray/system_tray_delegate.h" | 16 #include "ash/common/system/tray/system_tray_delegate.h" |
| 16 #include "ash/common/wm_shell.h" | 17 #include "ash/common/wm_shell.h" |
| 17 #include "ash/common/wm_window.h" | 18 #include "ash/common/wm_window.h" |
| 18 #include "ash/root_window_controller.h" | 19 #include "ash/root_window_controller.h" |
| 19 #include "ash/shell.h" | 20 #include "ash/shell.h" |
| 20 #include "ash/wm/window_util.h" | 21 #include "ash/wm/window_util.h" |
| 21 #include "base/command_line.h" | 22 #include "base/command_line.h" |
| 22 #include "base/macros.h" | 23 #include "base/macros.h" |
| 23 #include "base/strings/pattern.h" | 24 #include "base/strings/pattern.h" |
| 24 #include "base/strings/string_util.h" | 25 #include "base/strings/string_util.h" |
| (...skipping 834 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 859 return arc_deferred_launcher_.get(); | 860 return arc_deferred_launcher_.get(); |
| 860 } | 861 } |
| 861 | 862 |
| 862 /////////////////////////////////////////////////////////////////////////////// | 863 /////////////////////////////////////////////////////////////////////////////// |
| 863 // ash::ShelfDelegate: | 864 // ash::ShelfDelegate: |
| 864 | 865 |
| 865 void ChromeLauncherControllerImpl::OnShelfCreated(ash::Shelf* shelf) { | 866 void ChromeLauncherControllerImpl::OnShelfCreated(ash::Shelf* shelf) { |
| 866 PrefService* prefs = profile_->GetPrefs(); | 867 PrefService* prefs = profile_->GetPrefs(); |
| 867 const int64_t display = GetDisplayIDForShelf(shelf); | 868 const int64_t display = GetDisplayIDForShelf(shelf); |
| 868 | 869 |
| 869 shelf->SetAutoHideBehavior( | 870 shelf->wm_shelf()->SetAutoHideBehavior( |
| 870 ash::launcher::GetShelfAutoHideBehaviorPref(prefs, display)); | 871 ash::launcher::GetShelfAutoHideBehaviorPref(prefs, display)); |
| 871 | 872 |
| 872 if (ash::ShelfWidget::ShelfAlignmentAllowed()) | 873 if (ash::ShelfWidget::ShelfAlignmentAllowed()) { |
| 873 shelf->SetAlignment(ash::launcher::GetShelfAlignmentPref(prefs, display)); | 874 shelf->wm_shelf()->SetAlignment( |
| 875 ash::launcher::GetShelfAlignmentPref(prefs, display)); |
| 876 } |
| 874 } | 877 } |
| 875 | 878 |
| 876 void ChromeLauncherControllerImpl::OnShelfDestroyed(ash::Shelf* shelf) {} | 879 void ChromeLauncherControllerImpl::OnShelfDestroyed(ash::Shelf* shelf) {} |
| 877 | 880 |
| 878 void ChromeLauncherControllerImpl::OnShelfAlignmentChanged(ash::Shelf* shelf) { | 881 void ChromeLauncherControllerImpl::OnShelfAlignmentChanged(ash::Shelf* shelf) { |
| 879 ash::launcher::SetShelfAlignmentPref( | 882 ash::launcher::SetShelfAlignmentPref(profile_->GetPrefs(), |
| 880 profile_->GetPrefs(), GetDisplayIDForShelf(shelf), shelf->alignment()); | 883 GetDisplayIDForShelf(shelf), |
| 884 shelf->wm_shelf()->alignment()); |
| 881 } | 885 } |
| 882 | 886 |
| 883 void ChromeLauncherControllerImpl::OnShelfAutoHideBehaviorChanged( | 887 void ChromeLauncherControllerImpl::OnShelfAutoHideBehaviorChanged( |
| 884 ash::Shelf* shelf) { | 888 ash::Shelf* shelf) { |
| 885 ash::launcher::SetShelfAutoHideBehaviorPref(profile_->GetPrefs(), | 889 ash::launcher::SetShelfAutoHideBehaviorPref( |
| 886 GetDisplayIDForShelf(shelf), | 890 profile_->GetPrefs(), GetDisplayIDForShelf(shelf), |
| 887 shelf->auto_hide_behavior()); | 891 shelf->wm_shelf()->auto_hide_behavior()); |
| 888 } | 892 } |
| 889 | 893 |
| 890 void ChromeLauncherControllerImpl::OnShelfAutoHideStateChanged( | 894 void ChromeLauncherControllerImpl::OnShelfAutoHideStateChanged( |
| 891 ash::Shelf* shelf) {} | 895 ash::Shelf* shelf) {} |
| 892 | 896 |
| 893 void ChromeLauncherControllerImpl::OnShelfVisibilityStateChanged( | 897 void ChromeLauncherControllerImpl::OnShelfVisibilityStateChanged( |
| 894 ash::Shelf* shelf) {} | 898 ash::Shelf* shelf) {} |
| 895 | 899 |
| 896 ash::ShelfID ChromeLauncherControllerImpl::GetShelfIDForAppID( | 900 ash::ShelfID ChromeLauncherControllerImpl::GetShelfIDForAppID( |
| 897 const std::string& app_id) { | 901 const std::string& app_id) { |
| (...skipping 408 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1306 if (source_index != target_index) | 1310 if (source_index != target_index) |
| 1307 model_->Move(source_index, target_index); | 1311 model_->Move(source_index, target_index); |
| 1308 } | 1312 } |
| 1309 } | 1313 } |
| 1310 } | 1314 } |
| 1311 | 1315 |
| 1312 void ChromeLauncherControllerImpl::SetShelfAutoHideBehaviorFromPrefs() { | 1316 void ChromeLauncherControllerImpl::SetShelfAutoHideBehaviorFromPrefs() { |
| 1313 for (ash::WmWindow* window : ash::WmShell::Get()->GetAllRootWindows()) { | 1317 for (ash::WmWindow* window : ash::WmShell::Get()->GetAllRootWindows()) { |
| 1314 ash::Shelf* shelf = ash::Shelf::ForWindow(window); | 1318 ash::Shelf* shelf = ash::Shelf::ForWindow(window); |
| 1315 if (shelf) { | 1319 if (shelf) { |
| 1316 shelf->SetAutoHideBehavior(ash::launcher::GetShelfAutoHideBehaviorPref( | 1320 shelf->wm_shelf()->SetAutoHideBehavior( |
| 1317 profile_->GetPrefs(), GetDisplayIDForShelf(shelf))); | 1321 ash::launcher::GetShelfAutoHideBehaviorPref( |
| 1322 profile_->GetPrefs(), GetDisplayIDForShelf(shelf))); |
| 1318 } | 1323 } |
| 1319 } | 1324 } |
| 1320 } | 1325 } |
| 1321 | 1326 |
| 1322 void ChromeLauncherControllerImpl::SetShelfAlignmentFromPrefs() { | 1327 void ChromeLauncherControllerImpl::SetShelfAlignmentFromPrefs() { |
| 1323 if (!ash::ShelfWidget::ShelfAlignmentAllowed()) | 1328 if (!ash::ShelfWidget::ShelfAlignmentAllowed()) |
| 1324 return; | 1329 return; |
| 1325 | 1330 |
| 1326 for (ash::WmWindow* window : ash::WmShell::Get()->GetAllRootWindows()) { | 1331 for (ash::WmWindow* window : ash::WmShell::Get()->GetAllRootWindows()) { |
| 1327 ash::Shelf* shelf = ash::Shelf::ForWindow(window); | 1332 ash::Shelf* shelf = ash::Shelf::ForWindow(window); |
| 1328 if (shelf) { | 1333 if (shelf) { |
| 1329 shelf->SetAlignment(ash::launcher::GetShelfAlignmentPref( | 1334 shelf->wm_shelf()->SetAlignment(ash::launcher::GetShelfAlignmentPref( |
| 1330 profile_->GetPrefs(), GetDisplayIDForShelf(shelf))); | 1335 profile_->GetPrefs(), GetDisplayIDForShelf(shelf))); |
| 1331 } | 1336 } |
| 1332 } | 1337 } |
| 1333 } | 1338 } |
| 1334 | 1339 |
| 1335 void ChromeLauncherControllerImpl::SetShelfBehaviorsFromPrefs() { | 1340 void ChromeLauncherControllerImpl::SetShelfBehaviorsFromPrefs() { |
| 1336 SetShelfAutoHideBehaviorFromPrefs(); | 1341 SetShelfAutoHideBehaviorFromPrefs(); |
| 1337 SetShelfAlignmentFromPrefs(); | 1342 SetShelfAlignmentFromPrefs(); |
| 1338 } | 1343 } |
| 1339 | 1344 |
| (...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1640 } | 1645 } |
| 1641 | 1646 |
| 1642 /////////////////////////////////////////////////////////////////////////////// | 1647 /////////////////////////////////////////////////////////////////////////////// |
| 1643 // ash::WindowTreeHostManager::Observer: | 1648 // ash::WindowTreeHostManager::Observer: |
| 1644 | 1649 |
| 1645 void ChromeLauncherControllerImpl::OnDisplayConfigurationChanged() { | 1650 void ChromeLauncherControllerImpl::OnDisplayConfigurationChanged() { |
| 1646 // In BOTTOM_LOCKED state, ignore the call of SetShelfBehaviorsFromPrefs. | 1651 // In BOTTOM_LOCKED state, ignore the call of SetShelfBehaviorsFromPrefs. |
| 1647 // Because it might be called by some operations, like crbug.com/627040 | 1652 // Because it might be called by some operations, like crbug.com/627040 |
| 1648 // rotating screen. | 1653 // rotating screen. |
| 1649 ash::Shelf* shelf = ash::Shelf::ForPrimaryDisplay(); | 1654 ash::Shelf* shelf = ash::Shelf::ForPrimaryDisplay(); |
| 1650 if (!shelf || shelf->alignment() != ash::SHELF_ALIGNMENT_BOTTOM_LOCKED) | 1655 if (!shelf || |
| 1656 shelf->wm_shelf()->alignment() != ash::SHELF_ALIGNMENT_BOTTOM_LOCKED) |
| 1651 SetShelfBehaviorsFromPrefs(); | 1657 SetShelfBehaviorsFromPrefs(); |
| 1652 } | 1658 } |
| 1653 | 1659 |
| 1654 /////////////////////////////////////////////////////////////////////////////// | 1660 /////////////////////////////////////////////////////////////////////////////// |
| 1655 // AppSyncUIStateObserver: | 1661 // AppSyncUIStateObserver: |
| 1656 | 1662 |
| 1657 void ChromeLauncherControllerImpl::OnAppSyncUIStatusChanged() { | 1663 void ChromeLauncherControllerImpl::OnAppSyncUIStatusChanged() { |
| 1658 if (app_sync_ui_state_->status() == AppSyncUIState::STATUS_SYNCING) | 1664 if (app_sync_ui_state_->status() == AppSyncUIState::STATUS_SYNCING) |
| 1659 model_->set_status(ash::ShelfModel::STATUS_LOADING); | 1665 model_->set_status(ash::ShelfModel::STATUS_LOADING); |
| 1660 else | 1666 else |
| (...skipping 19 matching lines...) Expand all Loading... |
| 1680 if (index == -1) | 1686 if (index == -1) |
| 1681 continue; | 1687 continue; |
| 1682 ash::ShelfItem item = model_->items()[index]; | 1688 ash::ShelfItem item = model_->items()[index]; |
| 1683 item.image = image; | 1689 item.image = image; |
| 1684 if (arc_deferred_launcher_) | 1690 if (arc_deferred_launcher_) |
| 1685 arc_deferred_launcher_->MaybeApplySpinningEffect(id, &item.image); | 1691 arc_deferred_launcher_->MaybeApplySpinningEffect(id, &item.image); |
| 1686 model_->Set(index, item); | 1692 model_->Set(index, item); |
| 1687 // It's possible we're waiting on more than one item, so don't break. | 1693 // It's possible we're waiting on more than one item, so don't break. |
| 1688 } | 1694 } |
| 1689 } | 1695 } |
| OLD | NEW |