| OLD | NEW |
| 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 "chrome/browser/favicon/favicon_utils.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/gfx/image/image.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 if (contents) { | 28 if (contents) { |
| 29 NSImage* image = favicon::TabFaviconFromWebContents(contents).AsNSImage(); | 29 NSImage* image = favicon::TabFaviconFromWebContents(contents).AsNSImage(); |
| 30 | 30 |
| 31 // 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 |
| 32 // to the default image. | 32 // to the default image. |
| 33 if (image) | 33 if (image) |
| 34 return image; | 34 return image; |
| 35 } | 35 } |
| 36 | 36 |
| 37 if (ui::MaterialDesignController::IsModeMaterial()) { | 37 return NSImageFromImageSkia(gfx::CreateVectorIcon( |
| 38 return NSImageFromImageSkia(gfx::CreateVectorIcon( | 38 gfx::VectorIconId::DEFAULT_FAVICON, kVectorIconSize, color)); |
| 39 gfx::VectorIconId::DEFAULT_FAVICON, kVectorIconSize, color)); | |
| 40 } | |
| 41 | |
| 42 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); | |
| 43 return rb.GetNativeImageNamed(IDR_DEFAULT_FAVICON).ToNSImage(); | |
| 44 } | 39 } |
| 45 | 40 |
| 46 } // namespace mac | 41 } // namespace mac |
| OLD | NEW |