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

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

Issue 2293183002: ash: Remove ash::Shelf in favor of ash::WmShelf (Closed)
Patch Set: rebase again Created 4 years, 3 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_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"
14 #include "ash/common/shelf/shelf_model.h" 13 #include "ash/common/shelf/shelf_model.h"
14 #include "ash/common/shelf/shelf_widget.h"
15 #include "ash/common/shelf/wm_shelf.h" 15 #include "ash/common/shelf/wm_shelf.h"
16 #include "ash/common/system/tray/system_tray_delegate.h" 16 #include "ash/common/system/tray/system_tray_delegate.h"
17 #include "ash/common/wm_shell.h" 17 #include "ash/common/wm_shell.h"
18 #include "ash/common/wm_window.h" 18 #include "ash/common/wm_window.h"
19 #include "ash/resources/grit/ash_resources.h" 19 #include "ash/resources/grit/ash_resources.h"
20 #include "ash/root_window_controller.h" 20 #include "ash/root_window_controller.h"
21 #include "ash/shell.h" 21 #include "ash/shell.h"
22 #include "ash/wm/window_util.h" 22 #include "ash/wm/window_util.h"
23 #include "base/command_line.h" 23 #include "base/command_line.h"
24 #include "base/macros.h" 24 #include "base/macros.h"
(...skipping 791 matching lines...) Expand 10 before | Expand all | Expand 10 after
816 } 816 }
817 817
818 LauncherItemController* ChromeLauncherControllerImpl::GetLauncherItemController( 818 LauncherItemController* ChromeLauncherControllerImpl::GetLauncherItemController(
819 const ash::ShelfID id) { 819 const ash::ShelfID id) {
820 if (!HasShelfIDToAppIDMapping(id)) 820 if (!HasShelfIDToAppIDMapping(id))
821 return NULL; 821 return NULL;
822 return id_to_item_controller_map_[id]; 822 return id_to_item_controller_map_[id];
823 } 823 }
824 824
825 bool ChromeLauncherControllerImpl::ShelfBoundsChangesProbablyWithUser( 825 bool ChromeLauncherControllerImpl::ShelfBoundsChangesProbablyWithUser(
826 ash::Shelf* shelf, 826 ash::WmShelf* shelf,
827 const AccountId& account_id) const { 827 const AccountId& account_id) const {
828 Profile* other_profile = multi_user_util::GetProfileFromAccountId(account_id); 828 Profile* other_profile = multi_user_util::GetProfileFromAccountId(account_id);
829 if (!other_profile || other_profile == profile_) 829 if (!other_profile || other_profile == profile_)
830 return false; 830 return false;
831 831
832 // Note: The Auto hide state from preferences is not the same as the actual 832 // Note: The Auto hide state from preferences is not the same as the actual
833 // visibility of the shelf. Depending on all the various states (full screen, 833 // visibility of the shelf. Depending on all the various states (full screen,
834 // no window on desktop, multi user, ..) the shelf could be shown - or not. 834 // no window on desktop, multi user, ..) the shelf could be shown - or not.
835 PrefService* prefs = profile_->GetPrefs(); 835 PrefService* prefs = profile_->GetPrefs();
836 PrefService* other_prefs = other_profile->GetPrefs(); 836 PrefService* other_prefs = other_profile->GetPrefs();
837 const int64_t display = GetDisplayIDForShelf(shelf->wm_shelf()); 837 const int64_t display = GetDisplayIDForShelf(shelf);
838 const bool currently_shown = 838 const bool currently_shown =
839 ash::SHELF_AUTO_HIDE_BEHAVIOR_NEVER == 839 ash::SHELF_AUTO_HIDE_BEHAVIOR_NEVER ==
840 ash::launcher::GetShelfAutoHideBehaviorPref(prefs, display); 840 ash::launcher::GetShelfAutoHideBehaviorPref(prefs, display);
841 const bool other_shown = 841 const bool other_shown =
842 ash::SHELF_AUTO_HIDE_BEHAVIOR_NEVER == 842 ash::SHELF_AUTO_HIDE_BEHAVIOR_NEVER ==
843 ash::launcher::GetShelfAutoHideBehaviorPref(other_prefs, display); 843 ash::launcher::GetShelfAutoHideBehaviorPref(other_prefs, display);
844 844
845 return currently_shown != other_shown || 845 return currently_shown != other_shown ||
846 ash::launcher::GetShelfAlignmentPref(prefs, display) != 846 ash::launcher::GetShelfAlignmentPref(prefs, display) !=
847 ash::launcher::GetShelfAlignmentPref(other_prefs, display); 847 ash::launcher::GetShelfAlignmentPref(other_prefs, display);
(...skipping 456 matching lines...) Expand 10 before | Expand all | Expand 10 after
1304 ash::ShelfID id = GetShelfIDForAppID(*pref_app_id); 1304 ash::ShelfID id = GetShelfIDForAppID(*pref_app_id);
1305 int source_index = model_->ItemIndexByID(id); 1305 int source_index = model_->ItemIndexByID(id);
1306 if (source_index != target_index) 1306 if (source_index != target_index)
1307 model_->Move(source_index, target_index); 1307 model_->Move(source_index, target_index);
1308 } 1308 }
1309 } 1309 }
1310 } 1310 }
1311 1311
1312 void ChromeLauncherControllerImpl::SetShelfAutoHideBehaviorFromPrefs() { 1312 void ChromeLauncherControllerImpl::SetShelfAutoHideBehaviorFromPrefs() {
1313 for (ash::WmWindow* window : ash::WmShell::Get()->GetAllRootWindows()) { 1313 for (ash::WmWindow* window : ash::WmShell::Get()->GetAllRootWindows()) {
1314 ash::Shelf* shelf = ash::Shelf::ForWindow(window); 1314 ash::WmShelf* shelf = ash::WmShelf::ForWindow(window);
1315 if (shelf) { 1315 // TODO(jamescook): This check should not be necessary, but otherwise this
1316 shelf->wm_shelf()->SetAutoHideBehavior( 1316 // tries to set autohide state on a secondary display during login before
1317 ash::launcher::GetShelfAutoHideBehaviorPref( 1317 // the ShelfView is created, which is not allowed.
1318 profile_->GetPrefs(), GetDisplayIDForShelf(shelf->wm_shelf()))); 1318 if (shelf->IsShelfInitialized()) {
1319 shelf->SetAutoHideBehavior(ash::launcher::GetShelfAutoHideBehaviorPref(
1320 profile_->GetPrefs(), GetDisplayIDForShelf(shelf)));
1319 } 1321 }
1320 } 1322 }
1321 } 1323 }
1322 1324
1323 void ChromeLauncherControllerImpl::SetShelfAlignmentFromPrefs() { 1325 void ChromeLauncherControllerImpl::SetShelfAlignmentFromPrefs() {
1324 if (!ash::ShelfWidget::ShelfAlignmentAllowed()) 1326 if (!ash::ShelfWidget::ShelfAlignmentAllowed())
1325 return; 1327 return;
1326 1328
1327 for (ash::WmWindow* window : ash::WmShell::Get()->GetAllRootWindows()) { 1329 for (ash::WmWindow* window : ash::WmShell::Get()->GetAllRootWindows()) {
1328 ash::Shelf* shelf = ash::Shelf::ForWindow(window); 1330 ash::WmShelf* shelf = ash::WmShelf::ForWindow(window);
1329 if (shelf) { 1331 // TODO(jamescook): This check should not be necessary, but otherwise this
1330 shelf->wm_shelf()->SetAlignment(ash::launcher::GetShelfAlignmentPref( 1332 // tries to set the alignment on a secondary display during login before the
1331 profile_->GetPrefs(), GetDisplayIDForShelf(shelf->wm_shelf()))); 1333 // ShelfLockingManager and ShelfView are created, which is not allowed.
1334 if (shelf->IsShelfInitialized()) {
1335 shelf->SetAlignment(ash::launcher::GetShelfAlignmentPref(
1336 profile_->GetPrefs(), GetDisplayIDForShelf(shelf)));
1332 } 1337 }
1333 } 1338 }
1334 } 1339 }
1335 1340
1336 void ChromeLauncherControllerImpl::SetShelfBehaviorsFromPrefs() { 1341 void ChromeLauncherControllerImpl::SetShelfBehaviorsFromPrefs() {
1337 SetShelfAutoHideBehaviorFromPrefs(); 1342 SetShelfAutoHideBehaviorFromPrefs();
1338 SetShelfAlignmentFromPrefs(); 1343 SetShelfAlignmentFromPrefs();
1339 } 1344 }
1340 1345
1341 void ChromeLauncherControllerImpl::SetVirtualKeyboardBehaviorFromPrefs() { 1346 void ChromeLauncherControllerImpl::SetVirtualKeyboardBehaviorFromPrefs() {
(...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after
1640 id_to_item_controller_map_.erase(iter); 1645 id_to_item_controller_map_.erase(iter);
1641 } 1646 }
1642 1647
1643 /////////////////////////////////////////////////////////////////////////////// 1648 ///////////////////////////////////////////////////////////////////////////////
1644 // ash::WindowTreeHostManager::Observer: 1649 // ash::WindowTreeHostManager::Observer:
1645 1650
1646 void ChromeLauncherControllerImpl::OnDisplayConfigurationChanged() { 1651 void ChromeLauncherControllerImpl::OnDisplayConfigurationChanged() {
1647 // In BOTTOM_LOCKED state, ignore the call of SetShelfBehaviorsFromPrefs. 1652 // In BOTTOM_LOCKED state, ignore the call of SetShelfBehaviorsFromPrefs.
1648 // Because it might be called by some operations, like crbug.com/627040 1653 // Because it might be called by some operations, like crbug.com/627040
1649 // rotating screen. 1654 // rotating screen.
1650 ash::Shelf* shelf = ash::Shelf::ForPrimaryDisplay(); 1655 ash::WmShelf* shelf =
1651 if (!shelf || 1656 ash::WmShelf::ForWindow(ash::WmShell::Get()->GetPrimaryRootWindow());
1652 shelf->wm_shelf()->alignment() != ash::SHELF_ALIGNMENT_BOTTOM_LOCKED) 1657 if (shelf->alignment() != ash::SHELF_ALIGNMENT_BOTTOM_LOCKED)
1653 SetShelfBehaviorsFromPrefs(); 1658 SetShelfBehaviorsFromPrefs();
1654 } 1659 }
1655 1660
1656 /////////////////////////////////////////////////////////////////////////////// 1661 ///////////////////////////////////////////////////////////////////////////////
1657 // AppSyncUIStateObserver: 1662 // AppSyncUIStateObserver:
1658 1663
1659 void ChromeLauncherControllerImpl::OnAppSyncUIStatusChanged() { 1664 void ChromeLauncherControllerImpl::OnAppSyncUIStatusChanged() {
1660 if (app_sync_ui_state_->status() == AppSyncUIState::STATUS_SYNCING) 1665 if (app_sync_ui_state_->status() == AppSyncUIState::STATUS_SYNCING)
1661 model_->set_status(ash::ShelfModel::STATUS_LOADING); 1666 model_->set_status(ash::ShelfModel::STATUS_LOADING);
1662 else 1667 else
(...skipping 19 matching lines...) Expand all
1682 if (index == -1) 1687 if (index == -1)
1683 continue; 1688 continue;
1684 ash::ShelfItem item = model_->items()[index]; 1689 ash::ShelfItem item = model_->items()[index];
1685 item.image = image; 1690 item.image = image;
1686 if (arc_deferred_launcher_) 1691 if (arc_deferred_launcher_)
1687 arc_deferred_launcher_->MaybeApplySpinningEffect(id, &item.image); 1692 arc_deferred_launcher_->MaybeApplySpinningEffect(id, &item.image);
1688 model_->Set(index, item); 1693 model_->Set(index, item);
1689 // It's possible we're waiting on more than one item, so don't break. 1694 // It's possible we're waiting on more than one item, so don't break.
1690 } 1695 }
1691 } 1696 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698