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..0349f4de089d49bf8914666bbb4c1a7ab858269f 100644 |
| --- a/extensions/browser/app_window/app_window.cc |
| +++ b/extensions/browser/app_window/app_window.cc |
| @@ -298,6 +298,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 +308,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( |
|
Andra Paraschiv
2016/08/04 11:32:57
This function can fetch the icon in an async way a
|
| + window_icon_url_, |
| + 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) { |
| @@ -610,6 +620,14 @@ void AppWindow::UpdateAppIcon(const gfx::Image& image) { |
| AppWindowRegistry::Get(browser_context_)->AppWindowIconChanged(this); |
| } |
| +void AppWindow::UpdateWindowIcon(const gfx::Image& image) { |
| + if (image.IsEmpty()) |
| + return; |
| + window_icon_ = image; |
|
Andra Paraschiv
2016/08/04 11:32:57
Currently, the window icon is the image with the u
|
| + native_app_window_->UpdateWindowIcon(); |
| + AppWindowRegistry::Get(browser_context_)->AppWindowIconChanged(this); |
| +} |
| + |
| void AppWindow::SetFullscreen(FullscreenType type, bool enable) { |
| DCHECK_NE(FULLSCREEN_TYPE_NONE, type); |
| @@ -814,7 +832,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; |
| // Bitmaps are ordered largest to smallest. Choose the smallest bitmap |
| @@ -826,7 +845,11 @@ void AppWindow::DidDownloadFavicon( |
| largest_index = i; |
| } |
| const SkBitmap& largest = bitmaps[largest_index]; |
| - UpdateAppIcon(gfx::Image::CreateFrom1xBitmap(largest)); |
| + if (image_url == app_icon_url_) |
| + UpdateAppIcon(gfx::Image::CreateFrom1xBitmap(largest)); |
| + // Update icon for showInShelf=true window. |
| + if (image_url == window_icon_url_) |
| + UpdateWindowIcon(gfx::Image::CreateFrom1xBitmap(largest)); |
| } |
| void AppWindow::OnExtensionIconImageChanged(IconImage* image) { |