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

Unified Diff: extensions/browser/app_window/app_window.cc

Issue 2530903002: Fix icon with badge size for items shown in shelf (Closed)
Patch Set: Created 4 years, 1 month 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: extensions/browser/app_window/app_window.cc
diff --git a/extensions/browser/app_window/app_window.cc b/extensions/browser/app_window/app_window.cc
index cee54392ed9a1b388eb6518cebe6e478106169bd..6af5c4766966619012797448da9d48249b70cde8 100644
--- a/extensions/browser/app_window/app_window.cc
+++ b/extensions/browser/app_window/app_window.cc
@@ -310,16 +310,9 @@ void AppWindow::Init(const GURL& url,
UpdateExtensionAppIcon();
// Download showInShelf=true window icon.
- if (window_icon_url_.is_valid()) {
- image_loader_ptr_factory_.InvalidateWeakPtrs();
- web_contents()->DownloadImage(
- window_icon_url_,
- true, // is a favicon
- 0, // no maximum size
- false, // normal cache policy
- base::Bind(&AppWindow::DidDownloadFavicon,
- image_loader_ptr_factory_.GetWeakPtr()));
- }
+ if (window_icon_url_.is_valid())
+ SetAppIconUrl(window_icon_url_);
+
AppWindowRegistry::Get(browser_context_)->AddAppWindow(this);
if (new_params.hidden) {
@@ -601,9 +594,13 @@ void AppWindow::SetAppIconUrl(const GURL& url) {
image_loader_ptr_factory_.InvalidateWeakPtrs();
// Reset |app_icon_image_| to abort pending image load (if any).
- app_icon_image_.reset();
+ if (!show_in_shelf_) {
+ app_icon_image_.reset();
+ app_icon_url_ = url;
+ } else {
+ window_icon_url_ = url;
+ }
- app_icon_url_ = url;
web_contents()->DownloadImage(
url,
true, // is a favicon
@@ -632,8 +629,20 @@ void AppWindow::UpdateAppIcon(const gfx::Image& image) {
? image
: gfx::Image(*ResourceBundle::GetSharedInstance().GetImageSkiaNamed(
IDR_APP_DEFAULT_ICON));
- app_icon_ = gfx::Image(gfx::ImageSkiaOperations::CreateIconWithBadge(
- base_image.AsImageSkia(), app_icon_image_->image_skia()));
+ // Scale down/up the icon size to large.
stevenjb 2016/12/05 16:51:11 nit: // Scale the icon to EXTENSION_ICON_LARGE
Andra Paraschiv 2016/12/06 08:43:43 Done.
+ int large_icon_size = extension_misc::EXTENSION_ICON_LARGE;
+ if (base_image.Width() != large_icon_size ||
+ base_image.Height() != large_icon_size) {
+ gfx::Image resized_image(base_image);
+ resized_image = gfx::Image(gfx::ImageSkiaOperations::CreateResizedImage(
+ resized_image.AsImageSkia(), skia::ImageOperations::RESIZE_BEST,
+ gfx::Size(large_icon_size, large_icon_size)));
+ app_icon_ = gfx::Image(gfx::ImageSkiaOperations::CreateIconWithBadge(
+ resized_image.AsImageSkia(), app_icon_image_->image_skia()));
+ } else {
+ app_icon_ = gfx::Image(gfx::ImageSkiaOperations::CreateIconWithBadge(
+ base_image.AsImageSkia(), app_icon_image_->image_skia()));
+ }
} else {
if (image.IsEmpty())
return;
@@ -868,7 +877,9 @@ void AppWindow::DidDownloadFavicon(
void AppWindow::OnExtensionIconImageChanged(IconImage* image) {
DCHECK_EQ(app_icon_image_.get(), image);
- UpdateAppIcon(gfx::Image(app_icon_image_->image_skia()));
+ // Update app_icon if no valid window icon url is set.
+ if (!window_icon_url_.is_valid())
+ UpdateAppIcon(gfx::Image(app_icon_image_->image_skia()));
}
void AppWindow::UpdateExtensionAppIcon() {
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698