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

Unified Diff: athena/content/web_activity.cc

Issue 550643002: [Athena] Hack to display favicons for web activities in overview mode (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 months 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
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);
}

Powered by Google App Engine
This is Rietveld 408576698