| 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" |
| 11 #include "chrome/browser/extensions/extension_system.h" | 11 #include "chrome/browser/extensions/extension_system.h" |
| 12 #include "chrome/browser/profiles/profile.h" | 12 #include "chrome/browser/profiles/profile.h" |
| 13 #include "chrome/browser/ui/app_list/app_context_menu.h" | 13 #include "chrome/browser/ui/app_list/app_context_menu.h" |
| 14 #include "chrome/browser/ui/app_list/app_list_controller_delegate.h" | 14 #include "chrome/browser/ui/app_list/app_list_controller_delegate.h" |
| 15 #include "chrome/browser/ui/extensions/extension_enable_flow.h" | 15 #include "chrome/browser/ui/extensions/extension_enable_flow.h" |
| 16 #include "chrome/browser/ui/webui/ntp/core_app_launcher_handler.h" | 16 #include "chrome/browser/ui/webui/ntp/core_app_launcher_handler.h" |
| 17 #include "chrome/common/extensions/extension.h" | 17 #include "chrome/common/extensions/extension.h" |
| 18 #include "chrome/common/extensions/extension_constants.h" | 18 #include "chrome/common/extensions/extension_constants.h" |
| 19 #include "chrome/common/extensions/extension_icon_set.h" | 19 #include "chrome/common/extensions/extension_icon_set.h" |
| 20 #include "chrome/common/extensions/manifest_handlers/icons_handler.h" | 20 #include "chrome/common/extensions/manifest_handlers/icons_handler.h" |
| 21 #include "chrome/common/extensions/manifest_url_handler.h" | 21 #include "chrome/common/extensions/manifest_url_handler.h" |
| 22 #include "content/public/browser/user_metrics.h" |
| 22 #include "grit/theme_resources.h" | 23 #include "grit/theme_resources.h" |
| 23 #include "ui/base/resource/resource_bundle.h" | 24 #include "ui/base/resource/resource_bundle.h" |
| 24 #include "ui/gfx/canvas.h" | 25 #include "ui/gfx/canvas.h" |
| 25 #include "ui/gfx/color_utils.h" | 26 #include "ui/gfx/color_utils.h" |
| 26 #include "ui/gfx/image/canvas_image_source.h" | 27 #include "ui/gfx/image/canvas_image_source.h" |
| 27 #include "ui/gfx/image/image_skia_operations.h" | 28 #include "ui/gfx/image/image_skia_operations.h" |
| 28 | 29 |
| 29 using extensions::Extension; | 30 using extensions::Extension; |
| 30 | 31 |
| 31 namespace { | 32 namespace { |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 64 const color_utils::HSL shift = {-1, 0, 0.6}; | 65 const color_utils::HSL shift = {-1, 0, 0.6}; |
| 65 | 66 |
| 66 } // namespace | 67 } // namespace |
| 67 | 68 |
| 68 ExtensionAppItem::ExtensionAppItem(Profile* profile, | 69 ExtensionAppItem::ExtensionAppItem(Profile* profile, |
| 69 const std::string& extension_id, | 70 const std::string& extension_id, |
| 70 AppListControllerDelegate* controller, | 71 AppListControllerDelegate* controller, |
| 71 const std::string& extension_name, | 72 const std::string& extension_name, |
| 72 const gfx::ImageSkia& installing_icon, | 73 const gfx::ImageSkia& installing_icon, |
| 73 bool is_platform_app) | 74 bool is_platform_app) |
| 74 : ChromeAppListItem(TYPE_APP), | 75 : profile_(profile), |
| 75 profile_(profile), | |
| 76 extension_id_(extension_id), | 76 extension_id_(extension_id), |
| 77 controller_(controller), | 77 controller_(controller), |
| 78 extension_name_(extension_name), | 78 extension_name_(extension_name), |
| 79 installing_icon_( | 79 installing_icon_( |
| 80 gfx::ImageSkiaOperations::CreateHSLShiftedImage(installing_icon, | 80 gfx::ImageSkiaOperations::CreateHSLShiftedImage(installing_icon, |
| 81 shift)), | 81 shift)), |
| 82 is_platform_app_(is_platform_app) { | 82 is_platform_app_(is_platform_app) { |
| 83 Reload(); | 83 Reload(); |
| 84 GetExtensionSorting(profile_)->EnsureValidOrdinals(extension_id_, | 84 GetExtensionSorting(profile_)->EnsureValidOrdinals(extension_id_, |
| 85 syncer::StringOrdinal()); | 85 syncer::StringOrdinal()); |
| (...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 256 | 256 |
| 257 void ExtensionAppItem::Activate(int event_flags) { | 257 void ExtensionAppItem::Activate(int event_flags) { |
| 258 // |extension| could be NULL when it is being unloaded for updating. | 258 // |extension| could be NULL when it is being unloaded for updating. |
| 259 const Extension* extension = GetExtension(); | 259 const Extension* extension = GetExtension(); |
| 260 if (!extension) | 260 if (!extension) |
| 261 return; | 261 return; |
| 262 | 262 |
| 263 if (RunExtensionEnableFlow()) | 263 if (RunExtensionEnableFlow()) |
| 264 return; | 264 return; |
| 265 | 265 |
| 266 content::RecordAction(content::UserMetricsAction("AppList_ClickOnApp")); |
| 266 CoreAppLauncherHandler::RecordAppListMainLaunch(extension); | 267 CoreAppLauncherHandler::RecordAppListMainLaunch(extension); |
| 267 controller_->ActivateApp(profile_, | 268 controller_->ActivateApp(profile_, |
| 268 extension, | 269 extension, |
| 269 AppListControllerDelegate::LAUNCH_FROM_APP_LIST, | 270 AppListControllerDelegate::LAUNCH_FROM_APP_LIST, |
| 270 event_flags); | 271 event_flags); |
| 271 } | 272 } |
| 272 | 273 |
| 273 ui::MenuModel* ExtensionAppItem::GetContextMenuModel() { | 274 ui::MenuModel* ExtensionAppItem::GetContextMenuModel() { |
| 274 if (!context_menu_) { | 275 if (!context_menu_) { |
| 275 context_menu_.reset(new app_list::AppContextMenu( | 276 context_menu_.reset(new app_list::AppContextMenu( |
| 276 this, profile_, extension_id_, controller_, is_platform_app_, false)); | 277 this, profile_, extension_id_, controller_, is_platform_app_, false)); |
| 277 } | 278 } |
| 278 | 279 |
| 279 return context_menu_->GetMenuModel(); | 280 return context_menu_->GetMenuModel(); |
| 280 } | 281 } |
| 281 | 282 |
| 282 void ExtensionAppItem::ExecuteLaunchCommand(int event_flags) { | 283 void ExtensionAppItem::ExecuteLaunchCommand(int event_flags) { |
| 283 Launch(event_flags); | 284 Launch(event_flags); |
| 284 } | 285 } |
| OLD | NEW |