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/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/prefs/pref_service.h" | 8 #include "base/prefs/pref_service.h" |
9 #include "chrome/browser/extensions/extension_service.h" | 9 #include "chrome/browser/extensions/extension_service.h" |
10 #include "chrome/browser/extensions/extension_util.h" | 10 #include "chrome/browser/extensions/extension_util.h" |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
97 canvas->DrawImageInt( | 97 canvas->DrawImageInt( |
98 gfx::ImageSkia(masking_canvas->ExtractImageRep()), 0, 0, masking_paint); | 98 gfx::ImageSkia(masking_canvas->ExtractImageRep()), 0, 0, masking_paint); |
99 } | 99 } |
100 | 100 |
101 gfx::ImageSkia icon_; | 101 gfx::ImageSkia icon_; |
102 | 102 |
103 DISALLOW_COPY_AND_ASSIGN(RoundedCornersImageSource); | 103 DISALLOW_COPY_AND_ASSIGN(RoundedCornersImageSource); |
104 }; | 104 }; |
105 | 105 |
106 extensions::AppSorting* GetAppSorting(Profile* profile) { | 106 extensions::AppSorting* GetAppSorting(Profile* profile) { |
107 ExtensionService* service = | 107 return extensions::ExtensionPrefs::Get(profile)->app_sorting(); |
108 extensions::ExtensionSystem::Get(profile)->extension_service(); | |
109 return service->extension_prefs()->app_sorting(); | |
110 } | 108 } |
111 | 109 |
112 const color_utils::HSL shift = {-1, 0, 0.6}; | 110 const color_utils::HSL shift = {-1, 0, 0.6}; |
113 | 111 |
114 } // namespace | 112 } // namespace |
115 | 113 |
116 ExtensionAppItem::ExtensionAppItem( | 114 ExtensionAppItem::ExtensionAppItem( |
117 Profile* profile, | 115 Profile* profile, |
118 const app_list::AppListSyncableService::SyncItem* sync_item, | 116 const app_list::AppListSyncableService::SyncItem* sync_item, |
119 const std::string& extension_id, | 117 const std::string& extension_id, |
(...skipping 28 matching lines...) Expand all Loading... |
148 | 146 |
149 bool ExtensionAppItem::NeedsOverlay() const { | 147 bool ExtensionAppItem::NeedsOverlay() const { |
150 // The overlay icon is disabled for hosted apps in windowed mode with | 148 // The overlay icon is disabled for hosted apps in windowed mode with |
151 // streamlined hosted apps. | 149 // streamlined hosted apps. |
152 bool streamlined_hosted_apps = CommandLine::ForCurrentProcess()-> | 150 bool streamlined_hosted_apps = CommandLine::ForCurrentProcess()-> |
153 HasSwitch(switches::kEnableStreamlinedHostedApps); | 151 HasSwitch(switches::kEnableStreamlinedHostedApps); |
154 #if defined(OS_CHROMEOS) | 152 #if defined(OS_CHROMEOS) |
155 if (!streamlined_hosted_apps) | 153 if (!streamlined_hosted_apps) |
156 return false; | 154 return false; |
157 #endif | 155 #endif |
158 const ExtensionService* service = | 156 extensions::LaunchType launch_type = |
159 extensions::ExtensionSystem::Get(profile_)->extension_service(); | 157 GetExtension() |
160 | 158 ? extensions::GetLaunchType(extensions::ExtensionPrefs::Get(profile_), |
161 extensions::LaunchType launch_type = GetExtension() | 159 GetExtension()) |
162 ? extensions::GetLaunchType(service->extension_prefs(), GetExtension()) | 160 : extensions::LAUNCH_TYPE_WINDOW; |
163 : extensions::LAUNCH_TYPE_WINDOW; | |
164 | 161 |
165 return !is_platform_app_ && extension_id_ != extension_misc::kChromeAppId && | 162 return !is_platform_app_ && extension_id_ != extension_misc::kChromeAppId && |
166 (!streamlined_hosted_apps || | 163 (!streamlined_hosted_apps || |
167 launch_type != extensions::LAUNCH_TYPE_WINDOW); | 164 launch_type != extensions::LAUNCH_TYPE_WINDOW); |
168 } | 165 } |
169 | 166 |
170 void ExtensionAppItem::Reload() { | 167 void ExtensionAppItem::Reload() { |
171 const Extension* extension = GetExtension(); | 168 const Extension* extension = GetExtension(); |
172 bool is_installing = !extension; | 169 bool is_installing = !extension; |
173 SetIsInstalling(is_installing); | 170 SetIsInstalling(is_installing); |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
210 UpdateIcon(); | 207 UpdateIcon(); |
211 } | 208 } |
212 | 209 |
213 void ExtensionAppItem::Move(const ExtensionAppItem* prev, | 210 void ExtensionAppItem::Move(const ExtensionAppItem* prev, |
214 const ExtensionAppItem* next) { | 211 const ExtensionAppItem* next) { |
215 if (!prev && !next) | 212 if (!prev && !next) |
216 return; // No reordering necessary | 213 return; // No reordering necessary |
217 | 214 |
218 ExtensionService* service = | 215 ExtensionService* service = |
219 extensions::ExtensionSystem::Get(profile_)->extension_service(); | 216 extensions::ExtensionSystem::Get(profile_)->extension_service(); |
220 extensions::AppSorting* sorting = service->extension_prefs()->app_sorting(); | 217 extensions::ExtensionPrefs* prefs = extensions::ExtensionPrefs::Get(profile_); |
| 218 extensions::AppSorting* sorting = GetAppSorting(profile_); |
221 | 219 |
222 syncer::StringOrdinal page; | 220 syncer::StringOrdinal page; |
223 std::string prev_id, next_id; | 221 std::string prev_id, next_id; |
224 if (!prev) { | 222 if (!prev) { |
225 next_id = next->extension_id(); | 223 next_id = next->extension_id(); |
226 page = sorting->GetPageOrdinal(next_id); | 224 page = sorting->GetPageOrdinal(next_id); |
227 } else if (!next) { | 225 } else if (!next) { |
228 prev_id = prev->extension_id(); | 226 prev_id = prev->extension_id(); |
229 page = sorting->GetPageOrdinal(prev_id); | 227 page = sorting->GetPageOrdinal(prev_id); |
230 } else { | 228 } else { |
231 prev_id = prev->extension_id(); | 229 prev_id = prev->extension_id(); |
232 page = sorting->GetPageOrdinal(prev_id); | 230 page = sorting->GetPageOrdinal(prev_id); |
233 // Only set |next_id| if on the same page, otherwise just insert after prev. | 231 // Only set |next_id| if on the same page, otherwise just insert after prev. |
234 if (page.Equals(sorting->GetPageOrdinal(next->extension_id()))) | 232 if (page.Equals(sorting->GetPageOrdinal(next->extension_id()))) |
235 next_id = next->extension_id(); | 233 next_id = next->extension_id(); |
236 } | 234 } |
237 service->extension_prefs()->SetAppDraggedByUser(extension_id_); | 235 prefs->SetAppDraggedByUser(extension_id_); |
238 sorting->SetPageOrdinal(extension_id_, page); | 236 sorting->SetPageOrdinal(extension_id_, page); |
239 service->OnExtensionMoved(extension_id_, prev_id, next_id); | 237 service->OnExtensionMoved(extension_id_, prev_id, next_id); |
240 UpdatePositionFromExtensionOrdering(); | 238 UpdatePositionFromExtensionOrdering(); |
241 } | 239 } |
242 | 240 |
243 const Extension* ExtensionAppItem::GetExtension() const { | 241 const Extension* ExtensionAppItem::GetExtension() const { |
244 const ExtensionService* service = | 242 const ExtensionService* service = |
245 extensions::ExtensionSystem::Get(profile_)->extension_service(); | 243 extensions::ExtensionSystem::Get(profile_)->extension_service(); |
246 const Extension* extension = service->GetInstalledExtension(extension_id_); | 244 const Extension* extension = service->GetInstalledExtension(extension_id_); |
247 return extension; | 245 return extension; |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
353 const syncer::StringOrdinal& launch = | 351 const syncer::StringOrdinal& launch = |
354 GetAppSorting(profile_)->GetAppLaunchOrdinal(extension_id_); | 352 GetAppSorting(profile_)->GetAppLaunchOrdinal(extension_id_); |
355 set_position(syncer::StringOrdinal( | 353 set_position(syncer::StringOrdinal( |
356 page.ToInternalValue() + launch.ToInternalValue())); | 354 page.ToInternalValue() + launch.ToInternalValue())); |
357 } | 355 } |
358 | 356 |
359 AppListControllerDelegate* ExtensionAppItem::GetController() { | 357 AppListControllerDelegate* ExtensionAppItem::GetController() { |
360 return AppListService::Get(chrome::GetActiveDesktop())-> | 358 return AppListService::Get(chrome::GetActiveDesktop())-> |
361 GetControllerDelegate(); | 359 GetControllerDelegate(); |
362 } | 360 } |
OLD | NEW |