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

Side by Side Diff: chrome/browser/resource_delegate_mac.h

Issue 1585013002: MacViews: Use Cocoa folder icons in tree views. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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 unified diff | Download patch
OLDNEW
(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 #ifndef UI_BASE_RESOURCE_RESOURCE_DELEGATE_MAC_H_
tapted 2016/01/14 23:43:50 include guard isn't right
karandeepb 2016/01/18 00:31:17 Done.
6 #define UI_BASE_RESOURCE_RESOURCE_DELEGATE_MAC_H_
7
8 #include <map>
9
10 #include "base/macros.h"
11 #include "ui/base/resource/resource_bundle.h"
12 #include "ui/gfx/image/image.h"
13
14 #if defined(__OBJC__)
15 @class NSString;
16 #else
17 class NSString;
18 #endif
19
20 namespace ui {
21
22 // A singleton resource bundle delegate. Primary purpose is to intercept certain
23 // resource ids and to provide Mac specific assets for them at runtime.
24 class UI_BASE_EXPORT MacResourceDelegate : public ui::ResourceBundle::Delegate {
25 public:
26 MacResourceDelegate();
27 ~MacResourceDelegate() override;
28
29 // ui:ResourceBundle::Delegate implementation:
30 base::FilePath GetPathForResourcePack(const base::FilePath& pack_path,
31 ui::ScaleFactor scale_factor) override;
32 base::FilePath GetPathForLocalePack(const base::FilePath& pack_path,
33 const std::string& locale) override;
34 gfx::Image GetImageNamed(int resource_id) override;
35 gfx::Image GetNativeImageNamed(int resource_id,
36 ui::ResourceBundle::ImageRTL rtl) override;
37 base::RefCountedStaticMemory* LoadDataResourceBytes(
38 int resource_id,
39 ui::ScaleFactor scale_factor) override;
40 bool GetRawDataResource(int resource_id,
41 ui::ScaleFactor scale_factor,
42 base::StringPiece* value) override;
43 bool GetLocalizedString(int message_id, base::string16* value) override;
44 scoped_ptr<gfx::Font> GetFont(ui::ResourceBundle::FontStyle style) override;
45
46 private:
47 enum IconSize {
48 SMALL, // 16X16.
49 BIG // 32X32.
50 };
51
52 class InterceptedIcon {
tapted 2016/01/14 23:43:50 Skia does some crazy stuff around image loading. T
karandeepb 2016/01/18 00:31:17 Done.
53 public:
54 explicit InterceptedIcon(NSString* file_type,
55 bool flip_icon,
56 IconSize icon_size);
57 ~InterceptedIcon();
58 // Returns the image for this icon. The image is loaded lazily. An empty
59 // image is returned in case the image can't be loaded.
60 const gfx::Image GetImage() const;
61
62 private:
63 // File type to which this icon corresponds.
64 NSString* file_type_;
65 // Image for this icon type.
66 mutable gfx::Image icon_image_;
67 // If true, the icon image is flipped. Used to create images for RTL
68 // contexts.
69 bool flip_icon_;
70 // The desired icon size.
71 IconSize icon_size_;
72 // True if the image has been loaded. For lazy loading of images.
73 mutable bool is_image_loaded_;
74 };
75
76 typedef std::map<int, InterceptedIcon> InterceptedIconsMap;
77
78 // A map from intercepted resource_ids to corresponding InterceptedIcon
79 // resource.
80 InterceptedIconsMap intercepted_icons_map_;
tapted 2016/01/14 23:43:50 I don't think you need this
karandeepb 2016/01/18 00:31:17 Done.
81
82 DISALLOW_COPY_AND_ASSIGN(MacResourceDelegate);
83 };
84
85 } // namespace ui
86
87 #endif // UI_BASE_RESOURCE_RESOURCE_DELEGATE_MAC_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698