OLD | NEW |
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/app_list/extension_app_item.h" | 5 #include "chrome/browser/ui/app_list/extension_app_item.h" |
6 | 6 |
7 #include "base/prefs/pref_service.h" | 7 #include "base/prefs/pref_service.h" |
8 #include "chrome/browser/extensions/extension_prefs.h" | 8 #include "chrome/browser/extensions/extension_prefs.h" |
9 #include "chrome/browser/extensions/extension_service.h" | 9 #include "chrome/browser/extensions/extension_service.h" |
10 #include "chrome/browser/extensions/extension_sorting.h" | 10 #include "chrome/browser/extensions/extension_sorting.h" |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
137 const color_utils::HSL shift = {-1, 0, 0.6}; | 137 const color_utils::HSL shift = {-1, 0, 0.6}; |
138 icon = gfx::ImageSkiaOperations::CreateHSLShiftedImage(icon, shift); | 138 icon = gfx::ImageSkiaOperations::CreateHSLShiftedImage(icon, shift); |
139 } | 139 } |
140 | 140 |
141 if (HasOverlay()) | 141 if (HasOverlay()) |
142 icon = gfx::ImageSkia(new ShortcutOverlayImageSource(icon), icon.size()); | 142 icon = gfx::ImageSkia(new ShortcutOverlayImageSource(icon), icon.size()); |
143 | 143 |
144 SetIcon(icon, !HasOverlay()); | 144 SetIcon(icon, !HasOverlay()); |
145 } | 145 } |
146 | 146 |
| 147 void ExtensionAppItem::Move(const ExtensionAppItem* prev, |
| 148 const ExtensionAppItem* next) { |
| 149 if (!prev && !next) |
| 150 return; // No reordering necessary |
| 151 |
| 152 ExtensionService* service = |
| 153 extensions::ExtensionSystem::Get(profile_)->extension_service(); |
| 154 ExtensionSorting* sorting = service->extension_prefs()->extension_sorting(); |
| 155 |
| 156 syncer::StringOrdinal page; |
| 157 std::string prev_id, next_id; |
| 158 if (!prev) { |
| 159 next_id = next->extension_id(); |
| 160 page = sorting->GetPageOrdinal(next_id); |
| 161 } else if (!next) { |
| 162 prev_id = prev->extension_id(); |
| 163 page = sorting->GetPageOrdinal(prev_id); |
| 164 } else { |
| 165 prev_id = prev->extension_id(); |
| 166 page = sorting->GetPageOrdinal(prev_id); |
| 167 // Only set |next_id| if on the same page, otherwise just insert after prev. |
| 168 if (page.Equals(sorting->GetPageOrdinal(next->extension_id()))) |
| 169 next_id = next->extension_id(); |
| 170 } |
| 171 service->extension_prefs()->SetAppDraggedByUser(extension_id_); |
| 172 sorting->SetPageOrdinal(extension_id_, page); |
| 173 service->OnExtensionMoved(extension_id_, prev_id, next_id); |
| 174 } |
| 175 |
147 const Extension* ExtensionAppItem::GetExtension() const { | 176 const Extension* ExtensionAppItem::GetExtension() const { |
148 const ExtensionService* service = | 177 const ExtensionService* service = |
149 extensions::ExtensionSystem::Get(profile_)->extension_service(); | 178 extensions::ExtensionSystem::Get(profile_)->extension_service(); |
150 const Extension* extension = service->GetInstalledExtension(extension_id_); | 179 const Extension* extension = service->GetInstalledExtension(extension_id_); |
151 return extension; | 180 return extension; |
152 } | 181 } |
153 | 182 |
154 void ExtensionAppItem::LoadImage(const Extension* extension) { | 183 void ExtensionAppItem::LoadImage(const Extension* extension) { |
155 icon_.reset(new extensions::IconImage( | 184 icon_.reset(new extensions::IconImage( |
156 profile_, | 185 profile_, |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
246 // static | 275 // static |
247 const char ExtensionAppItem::kAppType[] = "ExtensionAppItem"; | 276 const char ExtensionAppItem::kAppType[] = "ExtensionAppItem"; |
248 | 277 |
249 const char* ExtensionAppItem::GetAppType() const { | 278 const char* ExtensionAppItem::GetAppType() const { |
250 return ExtensionAppItem::kAppType; | 279 return ExtensionAppItem::kAppType; |
251 } | 280 } |
252 | 281 |
253 void ExtensionAppItem::ExecuteLaunchCommand(int event_flags) { | 282 void ExtensionAppItem::ExecuteLaunchCommand(int event_flags) { |
254 Launch(event_flags); | 283 Launch(event_flags); |
255 } | 284 } |
OLD | NEW |