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

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

Issue 140323010: Ash:Shelf - Cleanup of Alternate Shelf (part 1) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 11 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 | Annotate | Revision Log
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.h" 5 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller.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/desktop_background/desktop_background_controller.h" 10 #include "ash/desktop_background/desktop_background_controller.h"
(...skipping 1103 matching lines...) Expand 10 before | Expand all | Expand 10 after
1114 void ChromeLauncherController::OnShelfDestroyed(ash::Shelf* shelf) { 1114 void ChromeLauncherController::OnShelfDestroyed(ash::Shelf* shelf) {
1115 shelves_.erase(shelf); 1115 shelves_.erase(shelf);
1116 // RemoveObserver is not called here, since by the time this method is called 1116 // RemoveObserver is not called here, since by the time this method is called
1117 // Shelf is already in its destructor. 1117 // Shelf is already in its destructor.
1118 } 1118 }
1119 1119
1120 void ChromeLauncherController::ShelfItemAdded(int index) { 1120 void ChromeLauncherController::ShelfItemAdded(int index) {
1121 // The app list launcher can get added to the shelf after we applied the 1121 // The app list launcher can get added to the shelf after we applied the
1122 // preferences. In that case the item might be at the wrong spot. As such we 1122 // preferences. In that case the item might be at the wrong spot. As such we
1123 // call the function again. 1123 // call the function again.
1124 if (model_->items()[index].type == ash::TYPE_APP_LIST && 1124 if (model_->items()[index].type == ash::TYPE_APP_LIST)
1125 ash::switches::UseAlternateShelfLayout())
1126 UpdateAppLaunchersFromPref(); 1125 UpdateAppLaunchersFromPref();
1127 } 1126 }
1128 1127
1129 void ChromeLauncherController::ShelfItemRemoved(int index, ash::LauncherID id) { 1128 void ChromeLauncherController::ShelfItemRemoved(int index, ash::LauncherID id) {
1130 } 1129 }
1131 1130
1132 void ChromeLauncherController::ShelfItemMoved(int start_index, 1131 void ChromeLauncherController::ShelfItemMoved(int start_index,
1133 int target_index) { 1132 int target_index) {
1134 const ash::LauncherItem& item = model_->items()[target_index]; 1133 const ash::LauncherItem& item = model_->items()[target_index];
1135 // We remember the moved item position if it is either pinnable or 1134 // We remember the moved item position if it is either pinnable or
1136 // it is the app list with the alternate shelf layout. 1135 // it is the app list with the alternate shelf layout.
1137 if ((HasItemController(item.id) && IsPinned(item.id)) || 1136 if ((HasItemController(item.id) && IsPinned(item.id)) ||
1138 (ash::switches::UseAlternateShelfLayout() && 1137 item.type == ash::TYPE_APP_LIST)
1139 item.type == ash::TYPE_APP_LIST))
1140 PersistPinnedState(); 1138 PersistPinnedState();
1141 } 1139 }
1142 1140
1143 void ChromeLauncherController::ShelfItemChanged( 1141 void ChromeLauncherController::ShelfItemChanged(
1144 int index, 1142 int index,
1145 const ash::LauncherItem& old_item) { 1143 const ash::LauncherItem& old_item) {
1146 } 1144 }
1147 1145
1148 void ChromeLauncherController::ShelfStatusChanged() { 1146 void ChromeLauncherController::ShelfStatusChanged() {
1149 } 1147 }
(...skipping 720 matching lines...) Expand 10 before | Expand all | Expand 10 after
1870 model_->Move(*app_list_index, target_index); 1868 model_->Move(*app_list_index, target_index);
1871 if (*chrome_index != -1 && 1869 if (*chrome_index != -1 &&
1872 *app_list_index < *chrome_index && 1870 *app_list_index < *chrome_index &&
1873 target_index > *chrome_index) 1871 target_index > *chrome_index)
1874 --(*chrome_index); 1872 --(*chrome_index);
1875 *app_list_index = -1; 1873 *app_list_index = -1;
1876 } 1874 }
1877 } 1875 }
1878 1876
1879 int ChromeLauncherController::FindInsertionPoint(bool is_app_list) { 1877 int ChromeLauncherController::FindInsertionPoint(bool is_app_list) {
1880 bool alternate = ash::switches::UseAlternateShelfLayout();
1881 // Keeping this change small to backport to M33&32 (see crbug.com/329597). 1878 // Keeping this change small to backport to M33&32 (see crbug.com/329597).
1882 // TODO(skuhne): With the removal of the legacy shelf layout we should remove 1879 // TODO(skuhne): With the removal of the legacy shelf layout we should remove
1883 // the ability to move the app list item since this was never used. We should 1880 // the ability to move the app list item since this was never used. We should
1884 // instead ask the ShelfModel::ValidateInsertionIndex or similir for an index. 1881 // instead ask the ShelfModel::ValidateInsertionIndex or similir for an index.
1885 if (is_app_list && alternate) 1882 if (is_app_list)
1886 return 0; 1883 return 0;
1887 1884
1888 for (int i = model_->item_count() - 1; i > 0; --i) { 1885 for (int i = model_->item_count() - 1; i > 0; --i) {
1889 ash::LauncherItemType type = model_->items()[i].type; 1886 ash::LauncherItemType type = model_->items()[i].type;
1890 if (type == ash::TYPE_APP_SHORTCUT || 1887 if (type == ash::TYPE_APP_SHORTCUT ||
1891 ((is_app_list || alternate) && type == ash::TYPE_APP_LIST) || 1888 type == ash::TYPE_APP_LIST ||
1892 type == ash::TYPE_BROWSER_SHORTCUT || 1889 type == ash::TYPE_BROWSER_SHORTCUT ||
1893 type == ash::TYPE_WINDOWED_APP) 1890 type == ash::TYPE_WINDOWED_APP)
1894 return i; 1891 return i;
1895 } 1892 }
1896 return 0; 1893 return 0;
1897 } 1894 }
1898 1895
1899 int ChromeLauncherController::GetChromeIconIndexForCreation() { 1896 int ChromeLauncherController::GetChromeIconIndexForCreation() {
1900 // We get the list of pinned apps as they currently would get pinned. 1897 // We get the list of pinned apps as they currently would get pinned.
1901 // Within this list the chrome icon will be the correct location. 1898 // Within this list the chrome icon will be the correct location.
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
1970 } 1967 }
1971 } 1968 }
1972 } 1969 }
1973 1970
1974 // If not added yet, the chrome item will be the last item in the list. 1971 // If not added yet, the chrome item will be the last item in the list.
1975 if (!chrome_icon_added) 1972 if (!chrome_icon_added)
1976 pinned_apps.push_back(extension_misc::kChromeAppId); 1973 pinned_apps.push_back(extension_misc::kChromeAppId);
1977 1974
1978 // If not added yet, add the app list item either at the end or at the 1975 // If not added yet, add the app list item either at the end or at the
1979 // beginning - depending on the shelf layout. 1976 // beginning - depending on the shelf layout.
1980 if (!app_list_icon_added) { 1977 if (!app_list_icon_added)
1981 if (ash::switches::UseAlternateShelfLayout()) 1978 pinned_apps.insert(pinned_apps.begin(), kAppLauncherIdPlaceholder);
1982 pinned_apps.insert(pinned_apps.begin(), kAppLauncherIdPlaceholder);
1983 else
1984 pinned_apps.push_back(kAppLauncherIdPlaceholder);
1985 }
1986 return pinned_apps; 1979 return pinned_apps;
1987 } 1980 }
1988 1981
1989 bool ChromeLauncherController::IsIncognito( 1982 bool ChromeLauncherController::IsIncognito(
1990 const content::WebContents* web_contents) const { 1983 const content::WebContents* web_contents) const {
1991 const Profile* profile = 1984 const Profile* profile =
1992 Profile::FromBrowserContext(web_contents->GetBrowserContext()); 1985 Profile::FromBrowserContext(web_contents->GetBrowserContext());
1993 return profile->IsOffTheRecord() && !profile->IsGuestSession(); 1986 return profile->IsOffTheRecord() && !profile->IsGuestSession();
1994 } 1987 }
1995 1988
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
2066 } 2059 }
2067 2060
2068 void ChromeLauncherController::ReleaseProfile() { 2061 void ChromeLauncherController::ReleaseProfile() {
2069 if (app_sync_ui_state_) 2062 if (app_sync_ui_state_)
2070 app_sync_ui_state_->RemoveObserver(this); 2063 app_sync_ui_state_->RemoveObserver(this);
2071 2064
2072 PrefServiceSyncable::FromProfile(profile_)->RemoveObserver(this); 2065 PrefServiceSyncable::FromProfile(profile_)->RemoveObserver(this);
2073 2066
2074 pref_change_registrar_.RemoveAll(); 2067 pref_change_registrar_.RemoveAll();
2075 } 2068 }
OLDNEW
« ash/system/tray/tray_background_view.cc ('K') | « chrome/browser/about_flags.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698