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

Side by Side Diff: chrome/browser/ui/cocoa/tab_contents/favicon_util_mac.mm

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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/ui/cocoa/tab_contents/favicon_util_mac.h" 5 #include "chrome/browser/ui/cocoa/tab_contents/favicon_util_mac.h"
6 6
7 #import <Cocoa/Cocoa.h> 7 #import <Cocoa/Cocoa.h>
8 8
9 #include "base/mac/scoped_nsobject.h" 9 #include "base/mac/scoped_nsobject.h"
10 #include "components/favicon/content/content_favicon_driver.h" 10 #include "chrome/browser/favicon/favicon_utils.h"
11 #include "skia/ext/skia_utils_mac.h" 11 #include "skia/ext/skia_utils_mac.h"
12 #include "ui/base/material_design/material_design_controller.h" 12 #include "ui/base/material_design/material_design_controller.h"
13 #include "ui/base/resource/resource_bundle.h" 13 #include "ui/base/resource/resource_bundle.h"
14 #include "ui/gfx/image/image_skia_util_mac.h" 14 #include "ui/gfx/image/image_skia_util_mac.h"
15 #include "ui/gfx/paint_vector_icon.h" 15 #include "ui/gfx/paint_vector_icon.h"
16 #include "ui/gfx/vector_icons_public.h" 16 #include "ui/gfx/vector_icons_public.h"
17 #include "ui/resources/grit/ui_resources.h" 17 #include "ui/resources/grit/ui_resources.h"
18 18
19 namespace { 19 namespace {
20 20
21 const CGFloat kVectorIconSize = 16; 21 const CGFloat kVectorIconSize = 16;
22 22
23 } // namespace 23 } // namespace
24 24
25 namespace mac { 25 namespace mac {
26 26
27 NSImage* FaviconForWebContents(content::WebContents* contents, SkColor color) { 27 NSImage* FaviconForWebContents(content::WebContents* contents, SkColor color) {
28 favicon::FaviconDriver* favicon_driver = 28 if (contents) {
29 contents ? favicon::ContentFaviconDriver::FromWebContents(contents) 29 NSImage* image = favicon::TabFaviconFromWebContents(contents).AsNSImage();
30 : nullptr; 30
31 if (favicon_driver && favicon_driver->FaviconIsValid()) {
32 NSImage* image = favicon_driver->GetFavicon().AsNSImage();
33 // The |image| could be nil if the bitmap is null. In that case, fallback 31 // The |image| could be nil if the bitmap is null. In that case, fallback
34 // to the default image. 32 // to the default image.
35 if (image) { 33 if (image)
36 return image; 34 return image;
37 }
38 } 35 }
39 36
40 if (ui::MaterialDesignController::IsModeMaterial()) { 37 if (ui::MaterialDesignController::IsModeMaterial()) {
41 return NSImageFromImageSkia(gfx::CreateVectorIcon( 38 return NSImageFromImageSkia(gfx::CreateVectorIcon(
42 gfx::VectorIconId::DEFAULT_FAVICON, kVectorIconSize, color)); 39 gfx::VectorIconId::DEFAULT_FAVICON, kVectorIconSize, color));
43 } 40 }
44 41
45 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); 42 ResourceBundle& rb = ResourceBundle::GetSharedInstance();
46 return rb.GetNativeImageNamed(IDR_DEFAULT_FAVICON).ToNSImage(); 43 return rb.GetNativeImageNamed(IDR_DEFAULT_FAVICON).ToNSImage();
47 } 44 }
48 45
49 } // namespace mac 46 } // namespace mac
OLDNEW
« no previous file with comments | « chrome/browser/favicon/favicon_utils.cc ('k') | chrome/browser/ui/views/tabs/browser_tab_strip_controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698