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

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: curlies 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())
874 shelf->wm_shelf()->SetAlignment( 872 shelf->SetAlignment(ash::launcher::GetShelfAlignmentPref(prefs, display));
875 ash::launcher::GetShelfAlignmentPref(prefs, display));
876 }
877 } 873 }
878 874
879 void ChromeLauncherControllerImpl::OnShelfDestroyed(ash::Shelf* shelf) {} 875 void ChromeLauncherControllerImpl::OnShelfDestroyed(ash::WmShelf* shelf) {}
880 876
881 void ChromeLauncherControllerImpl::OnShelfAlignmentChanged(ash::Shelf* shelf) { 877 void ChromeLauncherControllerImpl::OnShelfAlignmentChanged(
882 ash::launcher::SetShelfAlignmentPref(profile_->GetPrefs(), 878 ash::WmShelf* shelf) {
883 GetDisplayIDForShelf(shelf), 879 ash::launcher::SetShelfAlignmentPref(
884 shelf->wm_shelf()->alignment()); 880 profile_->GetPrefs(), GetDisplayIDForShelf(shelf), shelf->alignment());
885 } 881 }
886 882
887 void ChromeLauncherControllerImpl::OnShelfAutoHideBehaviorChanged( 883 void ChromeLauncherControllerImpl::OnShelfAutoHideBehaviorChanged(
888 ash::Shelf* shelf) { 884 ash::WmShelf* shelf) {
889 ash::launcher::SetShelfAutoHideBehaviorPref( 885 ash::launcher::SetShelfAutoHideBehaviorPref(profile_->GetPrefs(),
890 profile_->GetPrefs(), GetDisplayIDForShelf(shelf), 886 GetDisplayIDForShelf(shelf),
891 shelf->wm_shelf()->auto_hide_behavior()); 887 shelf->auto_hide_behavior());
892 } 888 }
893 889
894 void ChromeLauncherControllerImpl::OnShelfAutoHideStateChanged( 890 void ChromeLauncherControllerImpl::OnShelfAutoHideStateChanged(
895 ash::Shelf* shelf) {} 891 ash::WmShelf* shelf) {}
896 892
897 void ChromeLauncherControllerImpl::OnShelfVisibilityStateChanged( 893 void ChromeLauncherControllerImpl::OnShelfVisibilityStateChanged(
898 ash::Shelf* shelf) {} 894 ash::WmShelf* shelf) {}
899 895
900 ash::ShelfID ChromeLauncherControllerImpl::GetShelfIDForAppID( 896 ash::ShelfID ChromeLauncherControllerImpl::GetShelfIDForAppID(
901 const std::string& app_id) { 897 const std::string& app_id) {
902 for (IDToItemControllerMap::const_iterator i = 898 for (IDToItemControllerMap::const_iterator i =
903 id_to_item_controller_map_.begin(); 899 id_to_item_controller_map_.begin();
904 i != id_to_item_controller_map_.end(); ++i) { 900 i != id_to_item_controller_map_.end(); ++i) {
905 if (i->second->type() == LauncherItemController::TYPE_APP_PANEL) 901 if (i->second->type() == LauncherItemController::TYPE_APP_PANEL)
906 continue; // Don't include panels 902 continue; // Don't include panels
907 if (i->second->app_id() == app_id) 903 if (i->second->app_id() == app_id)
908 return i->first; 904 return i->first;
(...skipping 403 matching lines...) Expand 10 before | Expand all | Expand 10 after
1312 } 1308 }
1313 } 1309 }
1314 } 1310 }
1315 1311
1316 void ChromeLauncherControllerImpl::SetShelfAutoHideBehaviorFromPrefs() { 1312 void ChromeLauncherControllerImpl::SetShelfAutoHideBehaviorFromPrefs() {
1317 for (ash::WmWindow* window : ash::WmShell::Get()->GetAllRootWindows()) { 1313 for (ash::WmWindow* window : ash::WmShell::Get()->GetAllRootWindows()) {
1318 ash::Shelf* shelf = ash::Shelf::ForWindow(window); 1314 ash::Shelf* shelf = ash::Shelf::ForWindow(window);
1319 if (shelf) { 1315 if (shelf) {
1320 shelf->wm_shelf()->SetAutoHideBehavior( 1316 shelf->wm_shelf()->SetAutoHideBehavior(
1321 ash::launcher::GetShelfAutoHideBehaviorPref( 1317 ash::launcher::GetShelfAutoHideBehaviorPref(
1322 profile_->GetPrefs(), GetDisplayIDForShelf(shelf))); 1318 profile_->GetPrefs(), GetDisplayIDForShelf(shelf->wm_shelf())));
1323 } 1319 }
1324 } 1320 }
1325 } 1321 }
1326 1322
1327 void ChromeLauncherControllerImpl::SetShelfAlignmentFromPrefs() { 1323 void ChromeLauncherControllerImpl::SetShelfAlignmentFromPrefs() {
1328 if (!ash::ShelfWidget::ShelfAlignmentAllowed()) 1324 if (!ash::ShelfWidget::ShelfAlignmentAllowed())
1329 return; 1325 return;
1330 1326
1331 for (ash::WmWindow* window : ash::WmShell::Get()->GetAllRootWindows()) { 1327 for (ash::WmWindow* window : ash::WmShell::Get()->GetAllRootWindows()) {
1332 ash::Shelf* shelf = ash::Shelf::ForWindow(window); 1328 ash::Shelf* shelf = ash::Shelf::ForWindow(window);
1333 if (shelf) { 1329 if (shelf) {
1334 shelf->wm_shelf()->SetAlignment(ash::launcher::GetShelfAlignmentPref( 1330 shelf->wm_shelf()->SetAlignment(ash::launcher::GetShelfAlignmentPref(
1335 profile_->GetPrefs(), GetDisplayIDForShelf(shelf))); 1331 profile_->GetPrefs(), GetDisplayIDForShelf(shelf->wm_shelf())));
1336 } 1332 }
1337 } 1333 }
1338 } 1334 }
1339 1335
1340 void ChromeLauncherControllerImpl::SetShelfBehaviorsFromPrefs() { 1336 void ChromeLauncherControllerImpl::SetShelfBehaviorsFromPrefs() {
1341 SetShelfAutoHideBehaviorFromPrefs(); 1337 SetShelfAutoHideBehaviorFromPrefs();
1342 SetShelfAlignmentFromPrefs(); 1338 SetShelfAlignmentFromPrefs();
1343 } 1339 }
1344 1340
1345 void ChromeLauncherControllerImpl::SetVirtualKeyboardBehaviorFromPrefs() { 1341 void ChromeLauncherControllerImpl::SetVirtualKeyboardBehaviorFromPrefs() {
(...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after
1686 if (index == -1) 1682 if (index == -1)
1687 continue; 1683 continue;
1688 ash::ShelfItem item = model_->items()[index]; 1684 ash::ShelfItem item = model_->items()[index];
1689 item.image = image; 1685 item.image = image;
1690 if (arc_deferred_launcher_) 1686 if (arc_deferred_launcher_)
1691 arc_deferred_launcher_->MaybeApplySpinningEffect(id, &item.image); 1687 arc_deferred_launcher_->MaybeApplySpinningEffect(id, &item.image);
1692 model_->Set(index, item); 1688 model_->Set(index, item);
1693 // It's possible we're waiting on more than one item, so don't break. 1689 // It's possible we're waiting on more than one item, so don't break.
1694 } 1690 }
1695 } 1691 }
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