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

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

Issue 198063003: Revert of Shelf Cleanup (- binary files) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 9 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 1073 matching lines...) Expand 10 before | Expand all | Expand 10 after
1084 void ChromeLauncherController::OnShelfDestroyed(ash::Shelf* shelf) { 1084 void ChromeLauncherController::OnShelfDestroyed(ash::Shelf* shelf) {
1085 shelves_.erase(shelf); 1085 shelves_.erase(shelf);
1086 // RemoveObserver is not called here, since by the time this method is called 1086 // RemoveObserver is not called here, since by the time this method is called
1087 // Shelf is already in its destructor. 1087 // Shelf is already in its destructor.
1088 } 1088 }
1089 1089
1090 void ChromeLauncherController::ShelfItemAdded(int index) { 1090 void ChromeLauncherController::ShelfItemAdded(int index) {
1091 // The app list launcher can get added to the shelf after we applied the 1091 // The app list launcher can get added to the shelf after we applied the
1092 // preferences. In that case the item might be at the wrong spot. As such we 1092 // preferences. In that case the item might be at the wrong spot. As such we
1093 // call the function again. 1093 // call the function again.
1094 if (model_->items()[index].type == ash::TYPE_APP_LIST) 1094 if (model_->items()[index].type == ash::TYPE_APP_LIST &&
1095 ash::switches::UseAlternateShelfLayout())
1095 UpdateAppLaunchersFromPref(); 1096 UpdateAppLaunchersFromPref();
1096 } 1097 }
1097 1098
1098 void ChromeLauncherController::ShelfItemRemoved(int index, ash::ShelfID id) { 1099 void ChromeLauncherController::ShelfItemRemoved(int index, ash::ShelfID id) {
1099 } 1100 }
1100 1101
1101 void ChromeLauncherController::ShelfItemMoved(int start_index, 1102 void ChromeLauncherController::ShelfItemMoved(int start_index,
1102 int target_index) { 1103 int target_index) {
1103 const ash::ShelfItem& item = model_->items()[target_index]; 1104 const ash::ShelfItem& item = model_->items()[target_index];
1104 // We remember the moved item position if it is either pinnable or 1105 // We remember the moved item position if it is either pinnable or
1105 // it is the app list with the alternate shelf layout. 1106 // it is the app list with the alternate shelf layout.
1106 if ((HasItemController(item.id) && IsPinned(item.id)) || 1107 if ((HasItemController(item.id) && IsPinned(item.id)) ||
1107 item.type == ash::TYPE_APP_LIST) 1108 (ash::switches::UseAlternateShelfLayout() &&
1109 item.type == ash::TYPE_APP_LIST))
1108 PersistPinnedState(); 1110 PersistPinnedState();
1109 } 1111 }
1110 1112
1111 void ChromeLauncherController::ShelfItemChanged( 1113 void ChromeLauncherController::ShelfItemChanged(
1112 int index, 1114 int index,
1113 const ash::ShelfItem& old_item) { 1115 const ash::ShelfItem& old_item) {
1114 } 1116 }
1115 1117
1116 void ChromeLauncherController::ShelfStatusChanged() { 1118 void ChromeLauncherController::ShelfStatusChanged() {
1117 } 1119 }
(...skipping 742 matching lines...) Expand 10 before | Expand all | Expand 10 after
1860 model_->Move(*app_list_index, target_index); 1862 model_->Move(*app_list_index, target_index);
1861 if (*chrome_index != -1 && 1863 if (*chrome_index != -1 &&
1862 *app_list_index < *chrome_index && 1864 *app_list_index < *chrome_index &&
1863 target_index > *chrome_index) 1865 target_index > *chrome_index)
1864 --(*chrome_index); 1866 --(*chrome_index);
1865 *app_list_index = -1; 1867 *app_list_index = -1;
1866 } 1868 }
1867 } 1869 }
1868 1870
1869 int ChromeLauncherController::FindInsertionPoint(bool is_app_list) { 1871 int ChromeLauncherController::FindInsertionPoint(bool is_app_list) {
1872 bool alternate = ash::switches::UseAlternateShelfLayout();
1870 // Keeping this change small to backport to M33&32 (see crbug.com/329597). 1873 // Keeping this change small to backport to M33&32 (see crbug.com/329597).
1871 // TODO(skuhne): With the removal of the legacy shelf layout we should remove 1874 // TODO(skuhne): With the removal of the legacy shelf layout we should remove
1872 // the ability to move the app list item since this was never used. We should 1875 // the ability to move the app list item since this was never used. We should
1873 // instead ask the ShelfModel::ValidateInsertionIndex or similir for an index. 1876 // instead ask the ShelfModel::ValidateInsertionIndex or similir for an index.
1874 if (is_app_list) 1877 if (is_app_list && alternate)
1875 return 0; 1878 return 0;
1876 1879
1877 for (int i = model_->item_count() - 1; i > 0; --i) { 1880 for (int i = model_->item_count() - 1; i > 0; --i) {
1878 ash::ShelfItemType type = model_->items()[i].type; 1881 ash::ShelfItemType type = model_->items()[i].type;
1879 if (type == ash::TYPE_APP_SHORTCUT || 1882 if (type == ash::TYPE_APP_SHORTCUT ||
1880 type == ash::TYPE_APP_LIST || 1883 ((is_app_list || alternate) && type == ash::TYPE_APP_LIST) ||
1881 type == ash::TYPE_BROWSER_SHORTCUT || 1884 type == ash::TYPE_BROWSER_SHORTCUT ||
1882 type == ash::TYPE_WINDOWED_APP) 1885 type == ash::TYPE_WINDOWED_APP)
1883 return i; 1886 return i;
1884 } 1887 }
1885 return 0; 1888 return 0;
1886 } 1889 }
1887 1890
1888 int ChromeLauncherController::GetChromeIconIndexForCreation() { 1891 int ChromeLauncherController::GetChromeIconIndexForCreation() {
1889 // We get the list of pinned apps as they currently would get pinned. 1892 // We get the list of pinned apps as they currently would get pinned.
1890 // Within this list the chrome icon will be the correct location. 1893 // Within this list the chrome icon will be the correct location.
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
1959 } 1962 }
1960 } 1963 }
1961 } 1964 }
1962 1965
1963 // If not added yet, the chrome item will be the last item in the list. 1966 // If not added yet, the chrome item will be the last item in the list.
1964 if (!chrome_icon_added) 1967 if (!chrome_icon_added)
1965 pinned_apps.push_back(extension_misc::kChromeAppId); 1968 pinned_apps.push_back(extension_misc::kChromeAppId);
1966 1969
1967 // If not added yet, add the app list item either at the end or at the 1970 // If not added yet, add the app list item either at the end or at the
1968 // beginning - depending on the shelf layout. 1971 // beginning - depending on the shelf layout.
1969 if (!app_list_icon_added) 1972 if (!app_list_icon_added) {
1970 pinned_apps.insert(pinned_apps.begin(), kAppShelfIdPlaceholder); 1973 if (ash::switches::UseAlternateShelfLayout())
1974 pinned_apps.insert(pinned_apps.begin(), kAppShelfIdPlaceholder);
1975 else
1976 pinned_apps.push_back(kAppShelfIdPlaceholder);
1977 }
1971 return pinned_apps; 1978 return pinned_apps;
1972 } 1979 }
1973 1980
1974 bool ChromeLauncherController::IsIncognito( 1981 bool ChromeLauncherController::IsIncognito(
1975 const content::WebContents* web_contents) const { 1982 const content::WebContents* web_contents) const {
1976 const Profile* profile = 1983 const Profile* profile =
1977 Profile::FromBrowserContext(web_contents->GetBrowserContext()); 1984 Profile::FromBrowserContext(web_contents->GetBrowserContext());
1978 return profile->IsOffTheRecord() && !profile->IsGuestSession(); 1985 return profile->IsOffTheRecord() && !profile->IsGuestSession();
1979 } 1986 }
1980 1987
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
2051 } 2058 }
2052 2059
2053 void ChromeLauncherController::ReleaseProfile() { 2060 void ChromeLauncherController::ReleaseProfile() {
2054 if (app_sync_ui_state_) 2061 if (app_sync_ui_state_)
2055 app_sync_ui_state_->RemoveObserver(this); 2062 app_sync_ui_state_->RemoveObserver(this);
2056 2063
2057 PrefServiceSyncable::FromProfile(profile_)->RemoveObserver(this); 2064 PrefServiceSyncable::FromProfile(profile_)->RemoveObserver(this);
2058 2065
2059 pref_change_registrar_.RemoveAll(); 2066 pref_change_registrar_.RemoveAll();
2060 } 2067 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698