Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2557)

Unified Diff: chrome/browser/resource_delegate_mac.mm

Issue 1585013002: MacViews: Use Cocoa folder icons in tree views. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed review comments. Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/resource_delegate_mac.h ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..01f2be7b91f42f3711d6e5faacd53b7865d10a0a
--- /dev/null
+++ b/chrome/browser/resource_delegate_mac.mm
@@ -0,0 +1,84 @@
+// 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 {
+
+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;
+}
+
+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);
+}
+
+gfx::Image MacResourceDelegate::GetNativeImageNamed(int resource_id) {
+ 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 nullptr;
+}
« no previous file with comments | « chrome/browser/resource_delegate_mac.h ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698