| OLD | NEW |
| (Empty) | |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "chrome/browser/resource_delegate_mac.h" |
| 6 |
| 7 #import <Cocoa/Cocoa.h> |
| 8 |
| 9 #include "ui/resources/grit/ui_resources.h" |
| 10 #include "ui/views/resources/grit/views_resources.h" |
| 11 |
| 12 namespace { |
| 13 |
| 14 const int kFolderIconReportedSizeDIP = 16; |
| 15 |
| 16 // Returns the icon for the given |hfs_type| defined in Cocoa's IconsCore.h, as |
| 17 // a gfx::Image of dimensions |width| X |height|. |
| 18 gfx::Image ImageForHFSType(int hfs_type, int width, int height) { |
| 19 NSImage* icon = [[NSWorkspace sharedWorkspace] |
| 20 iconForFileType:NSFileTypeForHFSTypeCode(hfs_type)]; |
| 21 DCHECK(icon); |
| 22 [icon setSize:NSMakeSize(width, height)]; |
| 23 return gfx::Image([icon retain]); |
| 24 } |
| 25 |
| 26 } // namespace |
| 27 |
| 28 MacResourceDelegate::MacResourceDelegate() {} |
| 29 |
| 30 MacResourceDelegate::~MacResourceDelegate() {} |
| 31 |
| 32 base::FilePath MacResourceDelegate::GetPathForResourcePack( |
| 33 const base::FilePath& pack_path, |
| 34 ui::ScaleFactor scale_factor) { |
| 35 return pack_path; |
| 36 } |
| 37 |
| 38 base::FilePath MacResourceDelegate::GetPathForLocalePack( |
| 39 const base::FilePath& pack_path, |
| 40 const std::string& locale) { |
| 41 return pack_path; |
| 42 } |
| 43 |
| 44 gfx::Image MacResourceDelegate::GetImageNamed(int resource_id) { |
| 45 return GetNativeImageNamed(resource_id); |
| 46 } |
| 47 |
| 48 gfx::Image MacResourceDelegate::GetNativeImageNamed(int resource_id) { |
| 49 switch (resource_id) { |
| 50 // On Mac, return the same assets for the _RTL resources. Consistent with, |
| 51 // e.g., Safari. |
| 52 case IDR_FOLDER_OPEN: |
| 53 case IDR_FOLDER_OPEN_RTL: |
| 54 return ImageForHFSType(kOpenFolderIcon, kFolderIconReportedSizeDIP, |
| 55 kFolderIconReportedSizeDIP); |
| 56 case IDR_FOLDER_CLOSED: |
| 57 case IDR_FOLDER_CLOSED_RTL: |
| 58 return ImageForHFSType(kGenericFolderIcon, kFolderIconReportedSizeDIP, |
| 59 kFolderIconReportedSizeDIP); |
| 60 } |
| 61 return gfx::Image(); |
| 62 } |
| 63 |
| 64 base::RefCountedStaticMemory* MacResourceDelegate::LoadDataResourceBytes( |
| 65 int resource_id, |
| 66 ui::ScaleFactor scale_factor) { |
| 67 return nullptr; |
| 68 } |
| 69 |
| 70 bool MacResourceDelegate::GetRawDataResource(int resource_id, |
| 71 ui::ScaleFactor scale_factor, |
| 72 base::StringPiece* value) { |
| 73 return false; |
| 74 } |
| 75 |
| 76 bool MacResourceDelegate::GetLocalizedString(int message_id, |
| 77 base::string16* value) { |
| 78 return false; |
| 79 } |
| 80 |
| 81 scoped_ptr<gfx::Font> MacResourceDelegate::GetFont( |
| 82 ui::ResourceBundle::FontStyle style) { |
| 83 return nullptr; |
| 84 } |
| OLD | NEW |