Chromium Code Reviews| Index: athena/content/web_activity.cc |
| diff --git a/athena/content/web_activity.cc b/athena/content/web_activity.cc |
| index 85ede624a7f6383ceb3c3bc5f9e846e920038617..f779e0187870029777fc2d99bd2158ebc368a8c3 100644 |
| --- a/athena/content/web_activity.cc |
| +++ b/athena/content/web_activity.cc |
| @@ -10,11 +10,13 @@ |
| #include "base/bind.h" |
| #include "base/command_line.h" |
| #include "base/strings/utf_string_conversions.h" |
| +#include "components/favicon_base/select_favicon_frames.h" |
| #include "content/public/browser/native_web_keyboard_event.h" |
| #include "content/public/browser/navigation_controller.h" |
| #include "content/public/browser/web_contents.h" |
| #include "content/public/browser/web_contents_delegate.h" |
| #include "content/public/common/content_switches.h" |
| +#include "content/public/common/favicon_url.h" |
| #include "ui/aura/window.h" |
| #include "ui/compositor/closure_animation_observer.h" |
| #include "ui/compositor/scoped_layer_animation_settings.h" |
| @@ -145,6 +147,7 @@ class WebActivityController : public AcceleratorHandler { |
| const SkColor kDefaultTitleColor = SkColorSetRGB(0xf2, 0xf2, 0xf2); |
| const SkColor kDefaultUnavailableColor = SkColorSetRGB(0xbb, 0x77, 0x77); |
| +const int kIconSize = 32; |
| } // namespace |
| @@ -421,7 +424,6 @@ void WebActivity::Init() { |
| } |
| SkColor WebActivity::GetRepresentativeColor() const { |
| - // TODO(sad): Compute the color from the favicon. |
| return web_view_ ? title_color_ : kDefaultUnavailableColor; |
| } |
| @@ -434,6 +436,10 @@ base::string16 WebActivity::GetTitle() const { |
| : base::string16(); |
| } |
| +gfx::ImageSkia WebActivity::GetIcon() const { |
| + return icon_; |
| +} |
| + |
| bool WebActivity::UsesFrame() const { |
| return true; |
| } |
| @@ -481,8 +487,39 @@ void WebActivity::TitleWasSet(content::NavigationEntry* entry, |
| ActivityManager::Get()->UpdateActivity(this); |
| } |
| +void WebActivity::DidNavigateMainFrame( |
| + const content::LoadCommittedDetails& details, |
| + const content::FrameNavigateParams& params) { |
| + icon_ = gfx::ImageSkia(); |
| + ActivityManager::Get()->UpdateActivity(this); |
| +} |
| + |
| void WebActivity::DidUpdateFaviconURL( |
| const std::vector<content::FaviconURL>& candidates) { |
| + // Pick an arbitrary favicon of type FAVICON to use. |
| + // TODO(pkotwicz): Do something better once the favicon code is componentized. |
| + // (crbug.com/401997) |
| + for (size_t i = 0; i < candidates.size(); ++i) { |
| + if (candidates[i].icon_type == content::FaviconURL::FAVICON) { |
| + web_view_->GetWebContents()->DownloadImage( |
| + candidates[i].icon_url, |
| + true, |
| + 0, |
| + base::Bind(&WebActivity::OnDidDownloadFavicon, |
| + base::Unretained(this))); |
|
sadrul
2014/09/07 05:39:18
Use a weak-ptr here instead.
pkotwicz
2014/09/08 21:36:17
Done.
|
| + break; |
| + } |
| + } |
| +} |
| + |
| +void WebActivity::OnDidDownloadFavicon( |
| + int id, |
| + int http_status_code, |
| + const GURL& url, |
| + const std::vector<SkBitmap>& bitmaps, |
| + const std::vector<gfx::Size>& original_bitmap_sizes) { |
| + icon_ = CreateFaviconImageSkia( |
|
sadrul
2014/09/07 05:39:18
You should probably look at |http_status_code| bef
pkotwicz
2014/09/08 21:36:17
According to MultiResolutionImageResourceFetcher::
|
| + bitmaps, original_bitmap_sizes, kIconSize, NULL); |
| ActivityManager::Get()->UpdateActivity(this); |
| } |