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

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

Issue 22429004: Refactor LauncherDelegate (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add some comments Created 7 years, 4 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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_per_browser. h" 5 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller_per_browser. h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "ash/ash_switches.h" 9 #include "ash/ash_switches.h"
10 #include "ash/launcher/launcher_model.h" 10 #include "ash/launcher/launcher_model.h"
(...skipping 715 matching lines...) Expand 10 before | Expand all | Expand 10 after
726 void ChromeLauncherControllerPerBrowser::CreateNewWindow() { 726 void ChromeLauncherControllerPerBrowser::CreateNewWindow() {
727 chrome::NewEmptyWindow( 727 chrome::NewEmptyWindow(
728 GetProfileForNewWindows(), chrome::HOST_DESKTOP_TYPE_ASH); 728 GetProfileForNewWindows(), chrome::HOST_DESKTOP_TYPE_ASH);
729 } 729 }
730 730
731 void ChromeLauncherControllerPerBrowser::CreateNewIncognitoWindow() { 731 void ChromeLauncherControllerPerBrowser::CreateNewIncognitoWindow() {
732 chrome::NewEmptyWindow(GetProfileForNewWindows()->GetOffTheRecordProfile(), 732 chrome::NewEmptyWindow(GetProfileForNewWindows()->GetOffTheRecordProfile(),
733 chrome::HOST_DESKTOP_TYPE_ASH); 733 chrome::HOST_DESKTOP_TYPE_ASH);
734 } 734 }
735 735
736 bool ChromeLauncherControllerPerBrowser::CanPin() const {
737 const PrefService::Preference* pref =
738 profile_->GetPrefs()->FindPreference(prefs::kPinnedLauncherApps);
739 return pref && pref->IsUserModifiable();
740 }
741
742 ash::ShelfAutoHideBehavior 736 ash::ShelfAutoHideBehavior
743 ChromeLauncherControllerPerBrowser::GetShelfAutoHideBehavior( 737 ChromeLauncherControllerPerBrowser::GetShelfAutoHideBehavior(
744 aura::RootWindow* root_window) const { 738 aura::RootWindow* root_window) const {
745 // Don't show the shelf in the app mode. 739 // Don't show the shelf in the app mode.
746 if (chrome::IsRunningInAppMode()) 740 if (chrome::IsRunningInAppMode())
747 return ash::SHELF_AUTO_HIDE_ALWAYS_HIDDEN; 741 return ash::SHELF_AUTO_HIDE_ALWAYS_HIDDEN;
748 742
749 // See comment in |kShelfAlignment| as to why we consider two prefs. 743 // See comment in |kShelfAlignment| as to why we consider two prefs.
750 const std::string behavior_value( 744 const std::string behavior_value(
751 GetPrefForRootWindow(profile_->GetPrefs(), 745 GetPrefForRootWindow(profile_->GetPrefs(),
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after
974 launcher->shelf_widget()->shelf_layout_manager()->AddObserver(this); 968 launcher->shelf_widget()->shelf_layout_manager()->AddObserver(this);
975 } 969 }
976 970
977 void ChromeLauncherControllerPerBrowser::OnLauncherDestroyed( 971 void ChromeLauncherControllerPerBrowser::OnLauncherDestroyed(
978 ash::Launcher* launcher) { 972 ash::Launcher* launcher) {
979 launchers_.erase(launcher); 973 launchers_.erase(launcher);
980 // RemoveObserver is not called here, since by the time this method is called 974 // RemoveObserver is not called here, since by the time this method is called
981 // Launcher is already in its destructor. 975 // Launcher is already in its destructor.
982 } 976 }
983 977
978 ash::LauncherItemDelegate*
979 ChromeLauncherControllerPerBrowser::GetLauncherItemDelegate(
980 const ash::LauncherItem& item) {
981 // PerBrowserLauncher don't have LauncherItemController.
982 if (item.type == ash::TYPE_BROWSER_SHORTCUT)
983 return this;
984
985 IDToItemControllerMap::iterator iter =
986 id_to_item_controller_map_.find(item.id);
987 return (iter != id_to_item_controller_map_.end()) ? this : NULL;
988 }
989
990 bool ChromeLauncherControllerPerBrowser::CanPin() const {
991 const PrefService::Preference* pref =
992 profile_->GetPrefs()->FindPreference(prefs::kPinnedLauncherApps);
993 return pref && pref->IsUserModifiable();
994 }
995
984 void ChromeLauncherControllerPerBrowser::LauncherItemAdded(int index) { 996 void ChromeLauncherControllerPerBrowser::LauncherItemAdded(int index) {
985 } 997 }
986 998
987 void ChromeLauncherControllerPerBrowser::LauncherItemRemoved( 999 void ChromeLauncherControllerPerBrowser::LauncherItemRemoved(
988 int index, 1000 int index,
989 ash::LauncherID id) { 1001 ash::LauncherID id) {
990 } 1002 }
991 1003
992 void ChromeLauncherControllerPerBrowser::LauncherItemMoved( 1004 void ChromeLauncherControllerPerBrowser::LauncherItemMoved(
993 int start_index, 1005 int start_index,
994 int target_index) { 1006 int target_index) {
995 ash::LauncherID id = model_->items()[target_index].id; 1007 ash::LauncherID id = model_->items()[target_index].id;
996 if (HasItemController(id) && IsPinned(id)) 1008 if (HasItemController(id) && IsPinned(id))
997 PersistPinnedState(); 1009 PersistPinnedState();
998 else if (!HasItemController(id) && 1010 else if (!HasItemController(id) &&
999 model_->items()[target_index].type == ash::TYPE_BROWSER_SHORTCUT) 1011 model_->items()[target_index].type == ash::TYPE_BROWSER_SHORTCUT)
1000 PersistPinnedState(); 1012 PersistPinnedState();
1001 } 1013 }
1002 1014
1003 void ChromeLauncherControllerPerBrowser::LauncherItemChanged( 1015 void ChromeLauncherControllerPerBrowser::LauncherItemChanged(
1004 int index, 1016 int index,
1005 const ash::LauncherItem& old_item) { 1017 const ash::LauncherItem& old_item) {
1006 ash::LauncherID id = model_->items()[index].id; 1018 ash::LauncherID id = model_->items()[index].id;
1007 id_to_item_controller_map_[id]->LauncherItemChanged(index, old_item); 1019 if (HasItemController(id))
1020 id_to_item_controller_map_[id]->LauncherItemChanged(index, old_item);
1008 } 1021 }
1009 1022
1010 void ChromeLauncherControllerPerBrowser::LauncherStatusChanged() { 1023 void ChromeLauncherControllerPerBrowser::LauncherStatusChanged() {
1011 } 1024 }
1012 1025
1013 void ChromeLauncherControllerPerBrowser::Observe( 1026 void ChromeLauncherControllerPerBrowser::Observe(
1014 int type, 1027 int type,
1015 const content::NotificationSource& source, 1028 const content::NotificationSource& source,
1016 const content::NotificationDetails& details) { 1029 const content::NotificationDetails& details) {
1017 switch (type) { 1030 switch (type) {
(...skipping 450 matching lines...) Expand 10 before | Expand all | Expand 10 after
1468 ash::LauncherID id) { 1481 ash::LauncherID id) {
1469 return id_to_item_controller_map_[id]->app_id(); 1482 return id_to_item_controller_map_[id]->app_id();
1470 } 1483 }
1471 1484
1472 void ChromeLauncherControllerPerBrowser:: 1485 void ChromeLauncherControllerPerBrowser::
1473 MoveItemWithoutPinnedStateChangeNotification(int source_index, 1486 MoveItemWithoutPinnedStateChangeNotification(int source_index,
1474 int target_index) { 1487 int target_index) {
1475 base::AutoReset<bool> auto_reset(&ignore_persist_pinned_state_change_, true); 1488 base::AutoReset<bool> auto_reset(&ignore_persist_pinned_state_change_, true);
1476 model_->Move(source_index, target_index); 1489 model_->Move(source_index, target_index);
1477 } 1490 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698