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

Unified Diff: chrome/browser/favicon/favicon_utils.cc

Issue 2321833002: [Mac] Desaturate the Favicon for Network Errors (Closed)
Patch Set: Fix for Views Created 4 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
« no previous file with comments | « chrome/browser/favicon/favicon_utils.h ('k') | chrome/browser/ui/cocoa/tab_contents/favicon_util_mac.mm » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/favicon/favicon_utils.cc
diff --git a/chrome/browser/favicon/favicon_utils.cc b/chrome/browser/favicon/favicon_utils.cc
index a662aeb28f226ad69a0284474c9dd97b8d498e71..18c9bc53d9da0e9dc0b677a560e0c7cca278b708 100644
--- a/chrome/browser/favicon/favicon_utils.cc
+++ b/chrome/browser/favicon/favicon_utils.cc
@@ -10,10 +10,24 @@
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/search/search.h"
#include "chrome/common/url_constants.h"
+#include "components/favicon/content/content_favicon_driver.h"
+#include "content/public/browser/navigation_controller.h"
+#include "content/public/browser/navigation_entry.h"
#include "content/public/common/favicon_url.h"
+#include "ui/gfx/image/image.h"
+#include "ui/gfx/image/image_skia.h"
+#include "ui/gfx/image/image_skia_operations.h"
namespace favicon {
+namespace {
+
+// Desaturate favicon HSL shift values.
+const double kDesaturateHue = -1.0;
+const double kDesaturateSaturation = 0.0;
+const double kDesaturateLightness = 0.6;
+}
+
void CreateContentFaviconDriverForWebContents(
content::WebContents* web_contents) {
DCHECK(web_contents);
@@ -51,4 +65,27 @@ bool ShouldDisplayFavicon(content::WebContents* web_contents) {
return true;
}
+gfx::Image TabFaviconFromWebContents(content::WebContents* contents) {
+ DCHECK(contents);
+
+ favicon::FaviconDriver* favicon_driver =
+ favicon::ContentFaviconDriver::FromWebContents(contents);
+ gfx::Image favicon = favicon_driver->GetFavicon();
+
+ // Desaturate the favicon if the navigation entry contains a network error.
+ if (!contents->IsLoadingToDifferentDocument()) {
+ const content::NavigationController& controller = contents->GetController();
+
+ content::NavigationEntry* entry = controller.GetLastCommittedEntry();
+ if (entry && (entry->GetPageType() == content::PAGE_TYPE_ERROR)) {
+ color_utils::HSL shift = {kDesaturateHue, kDesaturateSaturation,
+ kDesaturateLightness};
+ return gfx::Image(gfx::ImageSkiaOperations::CreateHSLShiftedImage(
+ *favicon.ToImageSkia(), shift));
+ }
+ }
+
+ return favicon;
+}
+
} // namespace favicon
« no previous file with comments | « chrome/browser/favicon/favicon_utils.h ('k') | chrome/browser/ui/cocoa/tab_contents/favicon_util_mac.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698