Chromium Code Reviews| 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 ui { | |
| 13 | |
| 14 namespace { | |
| 15 | |
| 16 const int kFolderIconReportedSizeDIP = 16; | |
| 17 | |
| 18 // Returns the icon for the given |hfs_type| defined in Cocoa's IconsCore.h, as | |
| 19 // a gfx::Image of dimensions |width| X |height|. | |
| 20 gfx::Image ImageForHFSType(int hfs_type, int width, int height) { | |
| 21 NSImage* icon = [[NSWorkspace sharedWorkspace] | |
| 22 iconForFileType:NSFileTypeForHFSTypeCode(hfs_type)]; | |
| 23 DCHECK(icon); | |
| 24 [icon setSize:NSMakeSize(width, height)]; | |
| 25 return gfx::Image([icon retain]); | |
| 26 } | |
| 27 | |
| 28 } // namespace | |
| 29 | |
| 30 MacResourceDelegate::MacResourceDelegate() {} | |
| 31 | |
| 32 MacResourceDelegate::~MacResourceDelegate() {} | |
| 33 | |
| 34 base::FilePath MacResourceDelegate::GetPathForResourcePack( | |
| 35 const base::FilePath& pack_path, | |
| 36 ui::ScaleFactor scale_factor) { | |
| 37 return pack_path; | |
| 38 }; | |
|
tapted
2016/01/19 00:38:47
oh and there shouldn't be semicolons after all the
karandeepb
2016/01/20 10:22:37
Done.
| |
| 39 | |
| 40 base::FilePath MacResourceDelegate::GetPathForLocalePack( | |
| 41 const base::FilePath& pack_path, | |
| 42 const std::string& locale) { | |
| 43 return pack_path; | |
| 44 }; | |
| 45 | |
| 46 gfx::Image MacResourceDelegate::GetImageNamed(int resource_id) { | |
| 47 return GetNativeImageNamed(resource_id, ui::ResourceBundle::RTL_DISABLED); | |
| 48 }; | |
| 49 | |
| 50 gfx::Image MacResourceDelegate::GetNativeImageNamed( | |
| 51 int resource_id, | |
| 52 ui::ResourceBundle::ImageRTL rtl) { | |
| 53 // Flipped images are not used on Mac. | |
| 54 DCHECK_EQ(rtl, ui::ResourceBundle::RTL_DISABLED); | |
| 55 | |
| 56 switch (resource_id) { | |
| 57 // On Mac, return the same assets for the _RTL resources. Consistent with, | |
| 58 // e.g., Safari. | |
| 59 case IDR_FOLDER_OPEN: | |
| 60 case IDR_FOLDER_OPEN_RTL: | |
| 61 return ImageForHFSType(kOpenFolderIcon, kFolderIconReportedSizeDIP, | |
| 62 kFolderIconReportedSizeDIP); | |
| 63 case IDR_FOLDER_CLOSED: | |
| 64 case IDR_FOLDER_CLOSED_RTL: | |
| 65 return ImageForHFSType(kGenericFolderIcon, kFolderIconReportedSizeDIP, | |
| 66 kFolderIconReportedSizeDIP); | |
| 67 } | |
| 68 return gfx::Image(); | |
| 69 }; | |
| 70 | |
| 71 base::RefCountedStaticMemory* MacResourceDelegate::LoadDataResourceBytes( | |
| 72 int resource_id, | |
| 73 ui::ScaleFactor scale_factor) { | |
| 74 return nullptr; | |
| 75 }; | |
| 76 | |
| 77 bool MacResourceDelegate::GetRawDataResource(int resource_id, | |
| 78 ui::ScaleFactor scale_factor, | |
| 79 base::StringPiece* value) { | |
| 80 return false; | |
| 81 }; | |
| 82 | |
| 83 bool MacResourceDelegate::GetLocalizedString(int message_id, | |
| 84 base::string16* value) { | |
| 85 return false; | |
| 86 }; | |
| 87 | |
| 88 scoped_ptr<gfx::Font> MacResourceDelegate::GetFont( | |
| 89 ui::ResourceBundle::FontStyle style) { | |
| 90 return scoped_ptr<gfx::Font>(); | |
|
tapted
2016/01/19 00:36:52
I think `return nullptr` should work now that we h
karandeepb
2016/01/20 10:22:37
Done.
| |
| 91 }; | |
| 92 | |
| 93 } // namespace ui | |
| OLD | NEW |