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" | |
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 Loading... | |
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 Loading... | |
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 if (shelf->IsShelfCreated()) { |
1316 shelf->wm_shelf()->SetAutoHideBehavior( | 1316 shelf->SetAutoHideBehavior(ash::launcher::GetShelfAutoHideBehaviorPref( |
1317 ash::launcher::GetShelfAutoHideBehaviorPref( | 1317 profile_->GetPrefs(), GetDisplayIDForShelf(shelf))); |
1318 profile_->GetPrefs(), GetDisplayIDForShelf(shelf->wm_shelf()))); | |
1319 } | 1318 } |
1320 } | 1319 } |
1321 } | 1320 } |
1322 | 1321 |
1323 void ChromeLauncherControllerImpl::SetShelfAlignmentFromPrefs() { | 1322 void ChromeLauncherControllerImpl::SetShelfAlignmentFromPrefs() { |
1324 if (!ash::ShelfWidget::ShelfAlignmentAllowed()) | 1323 if (!ash::ShelfWidget::ShelfAlignmentAllowed()) |
1325 return; | 1324 return; |
1326 | 1325 |
1327 for (ash::WmWindow* window : ash::WmShell::Get()->GetAllRootWindows()) { | 1326 for (ash::WmWindow* window : ash::WmShell::Get()->GetAllRootWindows()) { |
1328 ash::Shelf* shelf = ash::Shelf::ForWindow(window); | 1327 ash::WmShelf* shelf = ash::WmShelf::ForWindow(window); |
1329 if (shelf) { | 1328 // TODO(jamescook): This check should not be necessary, but otherwise this |
msw
2016/08/30 22:02:07
nit: duplicate comment above; or should we no-op i
James Cook
2016/08/30 23:00:57
I duplicated the comment. (I think this code is su
| |
1330 shelf->wm_shelf()->SetAlignment(ash::launcher::GetShelfAlignmentPref( | 1329 // tries to set the alignment on a secondary display during login before the |
1331 profile_->GetPrefs(), GetDisplayIDForShelf(shelf->wm_shelf()))); | 1330 // ShelfLockingManager and ShelfView are created, which is not allowed. |
1331 if (shelf->IsShelfCreated()) { | |
1332 shelf->SetAlignment(ash::launcher::GetShelfAlignmentPref( | |
1333 profile_->GetPrefs(), GetDisplayIDForShelf(shelf))); | |
1332 } | 1334 } |
1333 } | 1335 } |
1334 } | 1336 } |
1335 | 1337 |
1336 void ChromeLauncherControllerImpl::SetShelfBehaviorsFromPrefs() { | 1338 void ChromeLauncherControllerImpl::SetShelfBehaviorsFromPrefs() { |
1337 SetShelfAutoHideBehaviorFromPrefs(); | 1339 SetShelfAutoHideBehaviorFromPrefs(); |
1338 SetShelfAlignmentFromPrefs(); | 1340 SetShelfAlignmentFromPrefs(); |
1339 } | 1341 } |
1340 | 1342 |
1341 void ChromeLauncherControllerImpl::SetVirtualKeyboardBehaviorFromPrefs() { | 1343 void ChromeLauncherControllerImpl::SetVirtualKeyboardBehaviorFromPrefs() { |
(...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1640 id_to_item_controller_map_.erase(iter); | 1642 id_to_item_controller_map_.erase(iter); |
1641 } | 1643 } |
1642 | 1644 |
1643 /////////////////////////////////////////////////////////////////////////////// | 1645 /////////////////////////////////////////////////////////////////////////////// |
1644 // ash::WindowTreeHostManager::Observer: | 1646 // ash::WindowTreeHostManager::Observer: |
1645 | 1647 |
1646 void ChromeLauncherControllerImpl::OnDisplayConfigurationChanged() { | 1648 void ChromeLauncherControllerImpl::OnDisplayConfigurationChanged() { |
1647 // In BOTTOM_LOCKED state, ignore the call of SetShelfBehaviorsFromPrefs. | 1649 // In BOTTOM_LOCKED state, ignore the call of SetShelfBehaviorsFromPrefs. |
1648 // Because it might be called by some operations, like crbug.com/627040 | 1650 // Because it might be called by some operations, like crbug.com/627040 |
1649 // rotating screen. | 1651 // rotating screen. |
1650 ash::Shelf* shelf = ash::Shelf::ForPrimaryDisplay(); | 1652 ash::WmShelf* shelf = |
1651 if (!shelf || | 1653 ash::WmShelf::ForWindow(ash::WmShell::Get()->GetPrimaryRootWindow()); |
1652 shelf->wm_shelf()->alignment() != ash::SHELF_ALIGNMENT_BOTTOM_LOCKED) | 1654 if (shelf->alignment() != ash::SHELF_ALIGNMENT_BOTTOM_LOCKED) |
1653 SetShelfBehaviorsFromPrefs(); | 1655 SetShelfBehaviorsFromPrefs(); |
1654 } | 1656 } |
1655 | 1657 |
1656 /////////////////////////////////////////////////////////////////////////////// | 1658 /////////////////////////////////////////////////////////////////////////////// |
1657 // AppSyncUIStateObserver: | 1659 // AppSyncUIStateObserver: |
1658 | 1660 |
1659 void ChromeLauncherControllerImpl::OnAppSyncUIStatusChanged() { | 1661 void ChromeLauncherControllerImpl::OnAppSyncUIStatusChanged() { |
1660 if (app_sync_ui_state_->status() == AppSyncUIState::STATUS_SYNCING) | 1662 if (app_sync_ui_state_->status() == AppSyncUIState::STATUS_SYNCING) |
1661 model_->set_status(ash::ShelfModel::STATUS_LOADING); | 1663 model_->set_status(ash::ShelfModel::STATUS_LOADING); |
1662 else | 1664 else |
(...skipping 19 matching lines...) Expand all Loading... | |
1682 if (index == -1) | 1684 if (index == -1) |
1683 continue; | 1685 continue; |
1684 ash::ShelfItem item = model_->items()[index]; | 1686 ash::ShelfItem item = model_->items()[index]; |
1685 item.image = image; | 1687 item.image = image; |
1686 if (arc_deferred_launcher_) | 1688 if (arc_deferred_launcher_) |
1687 arc_deferred_launcher_->MaybeApplySpinningEffect(id, &item.image); | 1689 arc_deferred_launcher_->MaybeApplySpinningEffect(id, &item.image); |
1688 model_->Set(index, item); | 1690 model_->Set(index, item); |
1689 // It's possible we're waiting on more than one item, so don't break. | 1691 // It's possible we're waiting on more than one item, so don't break. |
1690 } | 1692 } |
1691 } | 1693 } |
OLD | NEW |