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

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

Issue 2279533002: ash: Convert ShelfDelegate to use WmShelf* instead of Shelf* (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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
« no previous file with comments | « chrome/browser/ui/ash/launcher/chrome_launcher_controller_impl.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 #include "ui/resources/grit/ui_resources.h" 101 #include "ui/resources/grit/ui_resources.h"
102 #include "ui/wm/core/window_animations.h" 102 #include "ui/wm/core/window_animations.h"
103 103
104 using extensions::Extension; 104 using extensions::Extension;
105 using extensions::UnloadedExtensionInfo; 105 using extensions::UnloadedExtensionInfo;
106 using extension_misc::kGmailAppId; 106 using extension_misc::kGmailAppId;
107 using content::WebContents; 107 using content::WebContents;
108 108
109 namespace { 109 namespace {
110 110
111 int64_t GetDisplayIDForShelf(ash::Shelf* shelf) { 111 int64_t GetDisplayIDForShelf(ash::WmShelf* shelf) {
112 aura::Window* root_window =
113 shelf->shelf_widget()->GetNativeWindow()->GetRootWindow();
114 display::Display display = 112 display::Display display =
115 display::Screen::GetScreen()->GetDisplayNearestWindow(root_window); 113 shelf->GetWindow()->GetRootWindow()->GetDisplayNearestWindow();
116 DCHECK(display.is_valid()); 114 DCHECK(display.is_valid());
117 return display.id(); 115 return display.id();
118 } 116 }
119 117
120 } // namespace 118 } // namespace
121 119
122 // A class to get events from ChromeOS when a user gets changed or added. 120 // A class to get events from ChromeOS when a user gets changed or added.
123 class ChromeLauncherControllerUserSwitchObserver 121 class ChromeLauncherControllerUserSwitchObserver
124 : public user_manager::UserManager::UserSessionStateObserver { 122 : public user_manager::UserManager::UserSessionStateObserver {
125 public: 123 public:
(...skipping 703 matching lines...) Expand 10 before | Expand all | Expand 10 after
829 const AccountId& account_id) const { 827 const AccountId& account_id) const {
830 Profile* other_profile = multi_user_util::GetProfileFromAccountId(account_id); 828 Profile* other_profile = multi_user_util::GetProfileFromAccountId(account_id);
831 if (!other_profile || other_profile == profile_) 829 if (!other_profile || other_profile == profile_)
832 return false; 830 return false;
833 831
834 // 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
835 // 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,
836 // 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.
837 PrefService* prefs = profile_->GetPrefs(); 835 PrefService* prefs = profile_->GetPrefs();
838 PrefService* other_prefs = other_profile->GetPrefs(); 836 PrefService* other_prefs = other_profile->GetPrefs();
839 const int64_t display = GetDisplayIDForShelf(shelf); 837 const int64_t display = GetDisplayIDForShelf(shelf->wm_shelf());
840 const bool currently_shown = 838 const bool currently_shown =
841 ash::SHELF_AUTO_HIDE_BEHAVIOR_NEVER == 839 ash::SHELF_AUTO_HIDE_BEHAVIOR_NEVER ==
842 ash::launcher::GetShelfAutoHideBehaviorPref(prefs, display); 840 ash::launcher::GetShelfAutoHideBehaviorPref(prefs, display);
843 const bool other_shown = 841 const bool other_shown =
844 ash::SHELF_AUTO_HIDE_BEHAVIOR_NEVER == 842 ash::SHELF_AUTO_HIDE_BEHAVIOR_NEVER ==
845 ash::launcher::GetShelfAutoHideBehaviorPref(other_prefs, display); 843 ash::launcher::GetShelfAutoHideBehaviorPref(other_prefs, display);
846 844
847 return currently_shown != other_shown || 845 return currently_shown != other_shown ||
848 ash::launcher::GetShelfAlignmentPref(prefs, display) != 846 ash::launcher::GetShelfAlignmentPref(prefs, display) !=
849 ash::launcher::GetShelfAlignmentPref(other_prefs, display); 847 ash::launcher::GetShelfAlignmentPref(other_prefs, display);
850 } 848 }
851 849
852 void ChromeLauncherControllerImpl::OnUserProfileReadyToSwitch( 850 void ChromeLauncherControllerImpl::OnUserProfileReadyToSwitch(
853 Profile* profile) { 851 Profile* profile) {
854 if (user_switch_observer_.get()) 852 if (user_switch_observer_.get())
855 user_switch_observer_->OnUserProfileReadyToSwitch(profile); 853 user_switch_observer_->OnUserProfileReadyToSwitch(profile);
856 } 854 }
857 855
858 ArcAppDeferredLauncherController* 856 ArcAppDeferredLauncherController*
859 ChromeLauncherControllerImpl::GetArcDeferredLauncher() { 857 ChromeLauncherControllerImpl::GetArcDeferredLauncher() {
860 return arc_deferred_launcher_.get(); 858 return arc_deferred_launcher_.get();
861 } 859 }
862 860
863 /////////////////////////////////////////////////////////////////////////////// 861 ///////////////////////////////////////////////////////////////////////////////
864 // ash::ShelfDelegate: 862 // ash::ShelfDelegate:
865 863
866 void ChromeLauncherControllerImpl::OnShelfCreated(ash::Shelf* shelf) { 864 void ChromeLauncherControllerImpl::OnShelfCreated(ash::WmShelf* shelf) {
867 PrefService* prefs = profile_->GetPrefs(); 865 PrefService* prefs = profile_->GetPrefs();
868 const int64_t display = GetDisplayIDForShelf(shelf); 866 const int64_t display = GetDisplayIDForShelf(shelf);
869 867
870 shelf->wm_shelf()->SetAutoHideBehavior( 868 shelf->SetAutoHideBehavior(
871 ash::launcher::GetShelfAutoHideBehaviorPref(prefs, display)); 869 ash::launcher::GetShelfAutoHideBehaviorPref(prefs, display));
872 870
873 if (ash::ShelfWidget::ShelfAlignmentAllowed()) { 871 if (ash::ShelfWidget::ShelfAlignmentAllowed()) {
msw 2016/08/24 19:52:41 nit: nix curlies
James Cook 2016/08/24 19:59:08 Done.
874 shelf->wm_shelf()->SetAlignment( 872 shelf->SetAlignment(ash::launcher::GetShelfAlignmentPref(prefs, display));
875 ash::launcher::GetShelfAlignmentPref(prefs, display));
876 } 873 }
877 } 874 }
878 875
879 void ChromeLauncherControllerImpl::OnShelfDestroyed(ash::Shelf* shelf) {} 876 void ChromeLauncherControllerImpl::OnShelfDestroyed(ash::WmShelf* shelf) {}
880 877
881 void ChromeLauncherControllerImpl::OnShelfAlignmentChanged(ash::Shelf* shelf) { 878 void ChromeLauncherControllerImpl::OnShelfAlignmentChanged(
882 ash::launcher::SetShelfAlignmentPref(profile_->GetPrefs(), 879 ash::WmShelf* shelf) {
883 GetDisplayIDForShelf(shelf), 880 ash::launcher::SetShelfAlignmentPref(
884 shelf->wm_shelf()->alignment()); 881 profile_->GetPrefs(), GetDisplayIDForShelf(shelf), shelf->alignment());
885 } 882 }
886 883
887 void ChromeLauncherControllerImpl::OnShelfAutoHideBehaviorChanged( 884 void ChromeLauncherControllerImpl::OnShelfAutoHideBehaviorChanged(
888 ash::Shelf* shelf) { 885 ash::WmShelf* shelf) {
889 ash::launcher::SetShelfAutoHideBehaviorPref( 886 ash::launcher::SetShelfAutoHideBehaviorPref(profile_->GetPrefs(),
890 profile_->GetPrefs(), GetDisplayIDForShelf(shelf), 887 GetDisplayIDForShelf(shelf),
891 shelf->wm_shelf()->auto_hide_behavior()); 888 shelf->auto_hide_behavior());
892 } 889 }
893 890
894 void ChromeLauncherControllerImpl::OnShelfAutoHideStateChanged( 891 void ChromeLauncherControllerImpl::OnShelfAutoHideStateChanged(
895 ash::Shelf* shelf) {} 892 ash::WmShelf* shelf) {}
896 893
897 void ChromeLauncherControllerImpl::OnShelfVisibilityStateChanged( 894 void ChromeLauncherControllerImpl::OnShelfVisibilityStateChanged(
898 ash::Shelf* shelf) {} 895 ash::WmShelf* shelf) {}
899 896
900 ash::ShelfID ChromeLauncherControllerImpl::GetShelfIDForAppID( 897 ash::ShelfID ChromeLauncherControllerImpl::GetShelfIDForAppID(
901 const std::string& app_id) { 898 const std::string& app_id) {
902 for (IDToItemControllerMap::const_iterator i = 899 for (IDToItemControllerMap::const_iterator i =
903 id_to_item_controller_map_.begin(); 900 id_to_item_controller_map_.begin();
904 i != id_to_item_controller_map_.end(); ++i) { 901 i != id_to_item_controller_map_.end(); ++i) {
905 if (i->second->type() == LauncherItemController::TYPE_APP_PANEL) 902 if (i->second->type() == LauncherItemController::TYPE_APP_PANEL)
906 continue; // Don't include panels 903 continue; // Don't include panels
907 if (i->second->app_id() == app_id) 904 if (i->second->app_id() == app_id)
908 return i->first; 905 return i->first;
(...skipping 403 matching lines...) Expand 10 before | Expand all | Expand 10 after
1312 } 1309 }
1313 } 1310 }
1314 } 1311 }
1315 1312
1316 void ChromeLauncherControllerImpl::SetShelfAutoHideBehaviorFromPrefs() { 1313 void ChromeLauncherControllerImpl::SetShelfAutoHideBehaviorFromPrefs() {
1317 for (ash::WmWindow* window : ash::WmShell::Get()->GetAllRootWindows()) { 1314 for (ash::WmWindow* window : ash::WmShell::Get()->GetAllRootWindows()) {
1318 ash::Shelf* shelf = ash::Shelf::ForWindow(window); 1315 ash::Shelf* shelf = ash::Shelf::ForWindow(window);
1319 if (shelf) { 1316 if (shelf) {
1320 shelf->wm_shelf()->SetAutoHideBehavior( 1317 shelf->wm_shelf()->SetAutoHideBehavior(
1321 ash::launcher::GetShelfAutoHideBehaviorPref( 1318 ash::launcher::GetShelfAutoHideBehaviorPref(
1322 profile_->GetPrefs(), GetDisplayIDForShelf(shelf))); 1319 profile_->GetPrefs(), GetDisplayIDForShelf(shelf->wm_shelf())));
1323 } 1320 }
1324 } 1321 }
1325 } 1322 }
1326 1323
1327 void ChromeLauncherControllerImpl::SetShelfAlignmentFromPrefs() { 1324 void ChromeLauncherControllerImpl::SetShelfAlignmentFromPrefs() {
1328 if (!ash::ShelfWidget::ShelfAlignmentAllowed()) 1325 if (!ash::ShelfWidget::ShelfAlignmentAllowed())
1329 return; 1326 return;
1330 1327
1331 for (ash::WmWindow* window : ash::WmShell::Get()->GetAllRootWindows()) { 1328 for (ash::WmWindow* window : ash::WmShell::Get()->GetAllRootWindows()) {
1332 ash::Shelf* shelf = ash::Shelf::ForWindow(window); 1329 ash::Shelf* shelf = ash::Shelf::ForWindow(window);
1333 if (shelf) { 1330 if (shelf) {
1334 shelf->wm_shelf()->SetAlignment(ash::launcher::GetShelfAlignmentPref( 1331 shelf->wm_shelf()->SetAlignment(ash::launcher::GetShelfAlignmentPref(
1335 profile_->GetPrefs(), GetDisplayIDForShelf(shelf))); 1332 profile_->GetPrefs(), GetDisplayIDForShelf(shelf->wm_shelf())));
1336 } 1333 }
1337 } 1334 }
1338 } 1335 }
1339 1336
1340 void ChromeLauncherControllerImpl::SetShelfBehaviorsFromPrefs() { 1337 void ChromeLauncherControllerImpl::SetShelfBehaviorsFromPrefs() {
1341 SetShelfAutoHideBehaviorFromPrefs(); 1338 SetShelfAutoHideBehaviorFromPrefs();
1342 SetShelfAlignmentFromPrefs(); 1339 SetShelfAlignmentFromPrefs();
1343 } 1340 }
1344 1341
1345 void ChromeLauncherControllerImpl::SetVirtualKeyboardBehaviorFromPrefs() { 1342 void ChromeLauncherControllerImpl::SetVirtualKeyboardBehaviorFromPrefs() {
(...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after
1686 if (index == -1) 1683 if (index == -1)
1687 continue; 1684 continue;
1688 ash::ShelfItem item = model_->items()[index]; 1685 ash::ShelfItem item = model_->items()[index];
1689 item.image = image; 1686 item.image = image;
1690 if (arc_deferred_launcher_) 1687 if (arc_deferred_launcher_)
1691 arc_deferred_launcher_->MaybeApplySpinningEffect(id, &item.image); 1688 arc_deferred_launcher_->MaybeApplySpinningEffect(id, &item.image);
1692 model_->Set(index, item); 1689 model_->Set(index, item);
1693 // It's possible we're waiting on more than one item, so don't break. 1690 // It's possible we're waiting on more than one item, so don't break.
1694 } 1691 }
1695 } 1692 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/ash/launcher/chrome_launcher_controller_impl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698