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 7df3954b504836f2fd675079e95c4e3afa9bf122..cfae6d9b50916ae57c3de11086c5698ad947dbe3 100644 |
| --- a/extensions/browser/app_window/app_window.cc |
| +++ b/extensions/browser/app_window/app_window.cc |
| @@ -57,6 +57,7 @@ |
| #include "ui/display/display.h" |
| #include "ui/display/screen.h" |
| #include "ui/events/keycodes/keyboard_codes.h" |
| +#include "ui/gfx/image/image_skia_operations.h" |
| #if !defined(OS_MACOSX) |
| #include "components/prefs/pref_service.h" |
| @@ -298,6 +299,7 @@ void AppWindow::Init(const GURL& url, |
| requested_alpha_enabled_ = new_params.alpha_enabled; |
| is_ime_window_ = params.is_ime_window; |
| show_in_shelf_ = params.show_in_shelf; |
| + window_icon_url_ = params.window_icon_url; |
| AppWindowClient* app_window_client = AppWindowClient::Get(); |
| native_app_window_.reset( |
| @@ -307,6 +309,15 @@ void AppWindow::Init(const GURL& url, |
| browser_context_, extension_id_, web_contents(), app_delegate_.get())); |
| UpdateExtensionAppIcon(); |
| + // Download showInShelf=true window icon. |
| + image_loader_ptr_factory_.InvalidateWeakPtrs(); |
| + web_contents()->DownloadImage( |
| + window_icon_url_, |
|
stevenjb
2016/08/08 22:26:46
We should test that window_icon_url_ is valid firs
Andra Paraschiv
2016/08/09 11:34:47
Done.
|
| + true, // is a favicon |
| + 0, // no maximum size |
| + false, // normal cache policy |
| + base::Bind(&AppWindow::DidDownloadFavicon, |
| + image_loader_ptr_factory_.GetWeakPtr())); |
| AppWindowRegistry::Get(browser_context_)->AddAppWindow(this); |
| if (new_params.hidden) { |
| @@ -605,7 +616,12 @@ void AppWindow::UpdateDraggableRegions( |
| void AppWindow::UpdateAppIcon(const gfx::Image& image) { |
| if (image.IsEmpty()) |
| return; |
| - app_icon_ = image; |
| + if (!window_icon_url_.is_empty()) { |
|
stevenjb
2016/08/08 22:26:45
We should test that app_icon_image_ is valid.
Andra Paraschiv
2016/08/09 11:34:47
Done.
|
| + app_icon_ = gfx::Image(gfx::ImageSkiaOperations::CreateImageWithBadge( |
| + image.AsImageSkia(), app_icon_image_->image_skia())); |
| + } else { |
| + app_icon_ = image; |
| + } |
| native_app_window_->UpdateWindowIcon(); |
| AppWindowRegistry::Get(browser_context_)->AppWindowIconChanged(this); |
| } |
| @@ -814,7 +830,8 @@ void AppWindow::DidDownloadFavicon( |
| const GURL& image_url, |
| const std::vector<SkBitmap>& bitmaps, |
| const std::vector<gfx::Size>& original_bitmap_sizes) { |
| - if (image_url != app_icon_url_ || bitmaps.empty()) |
| + if (((image_url != app_icon_url_) && (image_url != window_icon_url_)) || |
| + bitmaps.empty()) |
| return; |
|
stevenjb
2016/08/08 22:26:46
{}
Andra Paraschiv
2016/08/09 11:34:47
Done.
|
| // Bitmaps are ordered largest to smallest. Choose the smallest bitmap |