Chromium Code Reviews| 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() { |