Chromium Code Reviews| Index: chrome/browser/resource_delegate_mac.mm |
| diff --git a/chrome/browser/resource_delegate_mac.mm b/chrome/browser/resource_delegate_mac.mm |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..26c564385b13325c2a5607db82a8c8f8f0706055 |
| --- /dev/null |
| +++ b/chrome/browser/resource_delegate_mac.mm |
| @@ -0,0 +1,93 @@ |
| +// Copyright 2016 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "chrome/browser/resource_delegate_mac.h" |
| + |
| +#import <Cocoa/Cocoa.h> |
| + |
| +#include "ui/resources/grit/ui_resources.h" |
| +#include "ui/views/resources/grit/views_resources.h" |
| + |
| +namespace ui { |
| + |
| +namespace { |
| + |
| +const int kFolderIconReportedSizeDIP = 16; |
| + |
| +// Returns the icon for the given |hfs_type| defined in Cocoa's IconsCore.h, as |
| +// a gfx::Image of dimensions |width| X |height|. |
| +gfx::Image ImageForHFSType(int hfs_type, int width, int height) { |
| + NSImage* icon = [[NSWorkspace sharedWorkspace] |
| + iconForFileType:NSFileTypeForHFSTypeCode(hfs_type)]; |
| + DCHECK(icon); |
| + [icon setSize:NSMakeSize(width, height)]; |
| + return gfx::Image([icon retain]); |
| +} |
| + |
| +} // namespace |
| + |
| +MacResourceDelegate::MacResourceDelegate() {} |
| + |
| +MacResourceDelegate::~MacResourceDelegate() {} |
| + |
| +base::FilePath MacResourceDelegate::GetPathForResourcePack( |
| + const base::FilePath& pack_path, |
| + ui::ScaleFactor scale_factor) { |
| + return pack_path; |
| +}; |
|
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.
|
| + |
| +base::FilePath MacResourceDelegate::GetPathForLocalePack( |
| + const base::FilePath& pack_path, |
| + const std::string& locale) { |
| + return pack_path; |
| +}; |
| + |
| +gfx::Image MacResourceDelegate::GetImageNamed(int resource_id) { |
| + return GetNativeImageNamed(resource_id, ui::ResourceBundle::RTL_DISABLED); |
| +}; |
| + |
| +gfx::Image MacResourceDelegate::GetNativeImageNamed( |
| + int resource_id, |
| + ui::ResourceBundle::ImageRTL rtl) { |
| + // Flipped images are not used on Mac. |
| + DCHECK_EQ(rtl, ui::ResourceBundle::RTL_DISABLED); |
| + |
| + switch (resource_id) { |
| + // On Mac, return the same assets for the _RTL resources. Consistent with, |
| + // e.g., Safari. |
| + case IDR_FOLDER_OPEN: |
| + case IDR_FOLDER_OPEN_RTL: |
| + return ImageForHFSType(kOpenFolderIcon, kFolderIconReportedSizeDIP, |
| + kFolderIconReportedSizeDIP); |
| + case IDR_FOLDER_CLOSED: |
| + case IDR_FOLDER_CLOSED_RTL: |
| + return ImageForHFSType(kGenericFolderIcon, kFolderIconReportedSizeDIP, |
| + kFolderIconReportedSizeDIP); |
| + } |
| + return gfx::Image(); |
| +}; |
| + |
| +base::RefCountedStaticMemory* MacResourceDelegate::LoadDataResourceBytes( |
| + int resource_id, |
| + ui::ScaleFactor scale_factor) { |
| + return nullptr; |
| +}; |
| + |
| +bool MacResourceDelegate::GetRawDataResource(int resource_id, |
| + ui::ScaleFactor scale_factor, |
| + base::StringPiece* value) { |
| + return false; |
| +}; |
| + |
| +bool MacResourceDelegate::GetLocalizedString(int message_id, |
| + base::string16* value) { |
| + return false; |
| +}; |
| + |
| +scoped_ptr<gfx::Font> MacResourceDelegate::GetFont( |
| + ui::ResourceBundle::FontStyle style) { |
| + 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.
|
| +}; |
| + |
| +} // namespace ui |