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

Unified Diff: chrome/browser/ui/views/tabs/tab.cc

Issue 2217273002: Desaturate the favicon shown in the tab when a network error is encountered (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Merge Created 4 years, 4 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: chrome/browser/ui/views/tabs/tab.cc
diff --git a/chrome/browser/ui/views/tabs/tab.cc b/chrome/browser/ui/views/tabs/tab.cc
index 4b854bcfbe4b1bf089ab06e6bbaf58f9954d4cd4..fa4554d56d6d7d17ed67090d25d2f96e332c423a 100644
--- a/chrome/browser/ui/views/tabs/tab.cc
+++ b/chrome/browser/ui/views/tabs/tab.cc
@@ -31,6 +31,7 @@
#include "grit/components_strings.h"
#include "grit/theme_resources.h"
#include "third_party/skia/include/effects/SkGradientShader.h"
+#include "third_party/skia/include/effects/SkLumaColorFilter.h"
#include "third_party/skia/include/pathops/SkPathOps.h"
#include "ui/accessibility/ax_view_state.h"
#include "ui/base/l10n/l10n_util.h"
@@ -897,7 +898,6 @@ bool Tab::IsSelected() const {
void Tab::SetData(const TabRendererData& data) {
DCHECK(GetWidget());
-
if (data_.Equals(data))
return;
@@ -1657,9 +1657,25 @@ void Tab::PaintIcon(gfx::Canvas* canvas) {
!should_display_crashed_favicon_) {
PaintPinnedTabTitleChangedIndicatorAndIcon(canvas, bounds);
} else if (!favicon_.isNull()) {
- canvas->DrawImageInt(favicon_, 0, 0, bounds.width(), bounds.height(),
- bounds.x(), bounds.y(), bounds.width(),
- bounds.height(), false);
+ // Desaturate favicons of tabs with network errors.
+ if (data().network_error) {
+ SkPaint paint;
+ paint.setStyle(SkPaint::kFill_Style);
+ paint.setAntiAlias(true);
+ SkScalar desaturate[20] = {0.3086f, 0.6094f, 0.0820f, 0.0f, 0.0f,
+ 0.3086f, 0.6094f, 0.0820f, 0.0f, 0.0f,
+ 0.3086f, 0.6094f, 0.0820f, 0.0f, 0.0f,
+ 0.0f, 0.0f, 0.0f, 0.8f, 0.0f};
+ paint.setColorFilter(
+ SkColorFilter::MakeMatrixFilterRowMajor255(desaturate));
+ canvas->DrawImageInt(favicon_, 0, 0, bounds.width(), bounds.height(),
+ bounds.x(), bounds.y(), bounds.width(),
+ bounds.height(), false, paint);
+ } else {
+ canvas->DrawImageInt(favicon_, 0, 0, bounds.width(), bounds.height(),
+ bounds.x(), bounds.y(), bounds.width(),
+ bounds.height(), false);
+ }
}
}

Powered by Google App Engine
This is Rietveld 408576698