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 enum IconSize { | |
| 17 SMALL, // 16X16. | |
| 18 BIG // 32X32. | |
|
tapted
2016/01/18 04:15:42
`BIG` is unused. I think we want
const int kFolde
karandeepb
2016/01/18 09:25:40
Done. Have attached screenshots on the bug report.
| |
| 19 }; | |
| 20 | |
| 21 // Returns the icon for the given hfs_type defined in Cocoa's IconsCore.h, as a | |
| 22 // gfx::Image. In case the icon can't be retreived, an empty image is returned. | |
|
tapted
2016/01/18 04:15:42
I don't think the "In case the icon..." part is ri
karandeepb
2016/01/18 09:25:40
Done.
| |
| 23 gfx::Image ImageForHFSType(int hfs_type, IconSize icon_size) { | |
|
tapted
2016/01/18 04:15:42
IconSize -> int
karandeepb
2016/01/18 09:25:40
Done.
| |
| 24 NSImage* icon = [[[NSWorkspace sharedWorkspace] | |
| 25 iconForFileType:NSFileTypeForHFSTypeCode(hfs_type)] retain]; | |
|
karandeepb
2016/01/18 00:31:18
Can you check if calling retain here is ok? gfx::I
tapted
2016/01/18 04:15:42
ooh - yeah gfx::Image is weird. the return from ic
karandeepb
2016/01/18 09:25:40
Done.
| |
| 26 NSSize desired_size; | |
| 27 switch (icon_size) { | |
| 28 case IconSize::SMALL: | |
| 29 desired_size = NSMakeSize(16, 16); | |
| 30 break; | |
| 31 case IconSize::BIG: | |
| 32 desired_size = NSMakeSize(32, 32); | |
| 33 break; | |
| 34 } | |
| 35 [icon setSize:desired_size]; | |
| 36 return gfx::Image(icon); | |
| 37 } | |
| 38 | |
| 39 } // namespace | |
| 40 | |
| 41 MacResourceDelegate::MacResourceDelegate() {} | |
| 42 | |
| 43 MacResourceDelegate::~MacResourceDelegate() {} | |
| 44 | |
| 45 base::FilePath MacResourceDelegate::GetPathForResourcePack( | |
| 46 const base::FilePath& pack_path, | |
| 47 ui::ScaleFactor scale_factor) { | |
| 48 return pack_path; | |
| 49 }; | |
| 50 | |
| 51 base::FilePath MacResourceDelegate::GetPathForLocalePack( | |
| 52 const base::FilePath& pack_path, | |
| 53 const std::string& locale) { | |
| 54 return pack_path; | |
| 55 }; | |
| 56 | |
| 57 gfx::Image MacResourceDelegate::GetImageNamed(int resource_id) { | |
| 58 return GetNativeImageNamed(resource_id, ui::ResourceBundle::RTL_DISABLED); | |
| 59 }; | |
| 60 | |
| 61 gfx::Image MacResourceDelegate::GetNativeImageNamed( | |
| 62 int resource_id, | |
| 63 ui::ResourceBundle::ImageRTL rtl) { | |
| 64 // Flipped images are not used on Mac. | |
|
tapted
2016/01/18 04:15:42
I think it was only used for GTK and we can remove
karandeepb
2016/01/18 09:25:40
Will remove once the CL lands.
| |
| 65 DCHECK_EQ(rtl, ui::ResourceBundle::RTL_DISABLED); | |
| 66 | |
| 67 switch (resource_id) { | |
|
tapted
2016/01/18 04:15:42
Needs a comment about why this is correct re: the
karandeepb
2016/01/18 09:25:40
Done.
| |
| 68 case IDR_FOLDER_OPEN: | |
| 69 case IDR_FOLDER_OPEN_RTL: | |
| 70 return ImageForHFSType(kOpenFolderIcon, IconSize::SMALL); | |
| 71 break; | |
|
tapted
2016/01/18 04:15:42
nit: no break required
karandeepb
2016/01/18 09:25:40
Done.
| |
| 72 case IDR_FOLDER_CLOSED: | |
| 73 case IDR_FOLDER_CLOSED_RTL: | |
| 74 return ImageForHFSType(kGenericFolderIcon, IconSize::SMALL); | |
| 75 break; | |
|
tapted
2016/01/18 04:15:42
nit: no break
karandeepb
2016/01/18 09:25:40
Done.
| |
| 76 } | |
| 77 return gfx::Image(); | |
| 78 }; | |
| 79 | |
| 80 base::RefCountedStaticMemory* MacResourceDelegate::LoadDataResourceBytes( | |
| 81 int resource_id, | |
| 82 ui::ScaleFactor scale_factor) { | |
| 83 return nullptr; | |
| 84 }; | |
| 85 | |
| 86 bool MacResourceDelegate::GetRawDataResource(int resource_id, | |
| 87 ui::ScaleFactor scale_factor, | |
| 88 base::StringPiece* value) { | |
| 89 return false; | |
| 90 }; | |
| 91 | |
| 92 bool MacResourceDelegate::GetLocalizedString(int message_id, | |
| 93 base::string16* value) { | |
| 94 return false; | |
| 95 }; | |
| 96 | |
| 97 scoped_ptr<gfx::Font> MacResourceDelegate::GetFont( | |
| 98 ui::ResourceBundle::FontStyle style) { | |
| 99 return scoped_ptr<gfx::Font>(); | |
| 100 }; | |
| 101 | |
| 102 } // namespace ui | |
| OLD | NEW |