| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include "base/macros.h" | 9 #include "base/macros.h" |
| 10 #include "build/build_config.h" | 10 #include "build/build_config.h" |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 #include "extensions/common/manifest_handlers/icons_handler.h" | 26 #include "extensions/common/manifest_handlers/icons_handler.h" |
| 27 #include "extensions/common/manifest_url_handlers.h" | 27 #include "extensions/common/manifest_url_handlers.h" |
| 28 #include "grit/theme_resources.h" | 28 #include "grit/theme_resources.h" |
| 29 #include "sync/api/string_ordinal.h" | 29 #include "sync/api/string_ordinal.h" |
| 30 #include "ui/base/resource/resource_bundle.h" | 30 #include "ui/base/resource/resource_bundle.h" |
| 31 #include "ui/events/event_constants.h" | 31 #include "ui/events/event_constants.h" |
| 32 #include "ui/gfx/canvas.h" | 32 #include "ui/gfx/canvas.h" |
| 33 #include "ui/gfx/geometry/rect.h" | 33 #include "ui/gfx/geometry/rect.h" |
| 34 #include "ui/gfx/image/canvas_image_source.h" | 34 #include "ui/gfx/image/canvas_image_source.h" |
| 35 | 35 |
| 36 #if defined(OS_CHROMEOS) |
| 37 #include "chrome/browser/chromeos/extensions/gfx_utils.h" |
| 38 #endif |
| 39 |
| 36 using extensions::Extension; | 40 using extensions::Extension; |
| 37 | 41 |
| 38 namespace { | 42 namespace { |
| 39 | 43 |
| 40 // Overlays a shortcut icon over the bottom left corner of a given image. | 44 // Overlays a shortcut icon over the bottom left corner of a given image. |
| 41 class ShortcutOverlayImageSource : public gfx::CanvasImageSource { | 45 class ShortcutOverlayImageSource : public gfx::CanvasImageSource { |
| 42 public: | 46 public: |
| 43 explicit ShortcutOverlayImageSource(const gfx::ImageSkia& icon) | 47 explicit ShortcutOverlayImageSource(const gfx::ImageSkia& icon) |
| 44 : gfx::CanvasImageSource(icon.size(), false), | 48 : gfx::CanvasImageSource(icon.size(), false), |
| 45 icon_(icon) { | 49 icon_(icon) { |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 162 | 166 |
| 163 void ExtensionAppItem::UpdateIcon() { | 167 void ExtensionAppItem::UpdateIcon() { |
| 164 gfx::ImageSkia icon = installing_icon_; | 168 gfx::ImageSkia icon = installing_icon_; |
| 165 | 169 |
| 166 // Use the app icon if the app exists. Turn the image greyscale if the app is | 170 // Use the app icon if the app exists. Turn the image greyscale if the app is |
| 167 // not launchable. | 171 // not launchable. |
| 168 if (GetExtension() && icon_) { | 172 if (GetExtension() && icon_) { |
| 169 icon = icon_->image_skia(); | 173 icon = icon_->image_skia(); |
| 170 const bool enabled = extensions::util::IsAppLaunchable(extension_id(), | 174 const bool enabled = extensions::util::IsAppLaunchable(extension_id(), |
| 171 profile()); | 175 profile()); |
| 176 #if defined(OS_CHROMEOS) |
| 177 extensions::util::MaybeApplyChromeBadge(profile(), id(), &icon); |
| 178 #endif |
| 179 |
| 172 if (!enabled) | 180 if (!enabled) |
| 173 icon = CreateDisabledIcon(icon); | 181 icon = CreateDisabledIcon(icon); |
| 174 | 182 |
| 175 if (GetExtension()->from_bookmark()) | 183 if (GetExtension()->from_bookmark()) |
| 176 icon = gfx::ImageSkia(new RoundedCornersImageSource(icon), icon.size()); | 184 icon = gfx::ImageSkia(new RoundedCornersImageSource(icon), icon.size()); |
| 177 } | 185 } |
| 178 // Paint the shortcut overlay if necessary. | 186 // Paint the shortcut overlay if necessary. |
| 179 has_overlay_ = NeedsOverlay(); | 187 has_overlay_ = NeedsOverlay(); |
| 180 if (has_overlay_) | 188 if (has_overlay_) |
| 181 icon = gfx::ImageSkia(new ShortcutOverlayImageSource(icon), icon.size()); | 189 icon = gfx::ImageSkia(new ShortcutOverlayImageSource(icon), icon.size()); |
| (...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 336 } | 344 } |
| 337 | 345 |
| 338 void ExtensionAppItem::UpdatePositionFromOrdering() { | 346 void ExtensionAppItem::UpdatePositionFromOrdering() { |
| 339 const syncer::StringOrdinal& page = | 347 const syncer::StringOrdinal& page = |
| 340 GetAppSorting()->GetPageOrdinal(extension_id()); | 348 GetAppSorting()->GetPageOrdinal(extension_id()); |
| 341 const syncer::StringOrdinal& launch = | 349 const syncer::StringOrdinal& launch = |
| 342 GetAppSorting()->GetAppLaunchOrdinal(extension_id()); | 350 GetAppSorting()->GetAppLaunchOrdinal(extension_id()); |
| 343 set_position(syncer::StringOrdinal( | 351 set_position(syncer::StringOrdinal( |
| 344 page.ToInternalValue() + launch.ToInternalValue())); | 352 page.ToInternalValue() + launch.ToInternalValue())); |
| 345 } | 353 } |
| OLD | NEW |