Chromium Code Reviews| Index: chrome/browser/resource_delegate_mac.h |
| diff --git a/chrome/browser/resource_delegate_mac.h b/chrome/browser/resource_delegate_mac.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..74c80af40040d17f12f2743e8e2a8ff94aefc172 |
| --- /dev/null |
| +++ b/chrome/browser/resource_delegate_mac.h |
| @@ -0,0 +1,87 @@ |
| +// 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. |
| + |
| +#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.
|
| +#define UI_BASE_RESOURCE_RESOURCE_DELEGATE_MAC_H_ |
| + |
| +#include <map> |
| + |
| +#include "base/macros.h" |
| +#include "ui/base/resource/resource_bundle.h" |
| +#include "ui/gfx/image/image.h" |
| + |
| +#if defined(__OBJC__) |
| +@class NSString; |
| +#else |
| +class NSString; |
| +#endif |
| + |
| +namespace ui { |
| + |
| +// A singleton resource bundle delegate. Primary purpose is to intercept certain |
| +// resource ids and to provide Mac specific assets for them at runtime. |
| +class UI_BASE_EXPORT MacResourceDelegate : public ui::ResourceBundle::Delegate { |
| + public: |
| + MacResourceDelegate(); |
| + ~MacResourceDelegate() override; |
| + |
| + // ui:ResourceBundle::Delegate implementation: |
| + base::FilePath GetPathForResourcePack(const base::FilePath& pack_path, |
| + ui::ScaleFactor scale_factor) override; |
| + base::FilePath GetPathForLocalePack(const base::FilePath& pack_path, |
| + const std::string& locale) override; |
| + gfx::Image GetImageNamed(int resource_id) override; |
| + gfx::Image GetNativeImageNamed(int resource_id, |
| + ui::ResourceBundle::ImageRTL rtl) override; |
| + base::RefCountedStaticMemory* LoadDataResourceBytes( |
| + int resource_id, |
| + ui::ScaleFactor scale_factor) override; |
| + bool GetRawDataResource(int resource_id, |
| + ui::ScaleFactor scale_factor, |
| + base::StringPiece* value) override; |
| + bool GetLocalizedString(int message_id, base::string16* value) override; |
| + scoped_ptr<gfx::Font> GetFont(ui::ResourceBundle::FontStyle style) override; |
| + |
| + private: |
| + enum IconSize { |
| + SMALL, // 16X16. |
| + BIG // 32X32. |
| + }; |
| + |
| + 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.
|
| + public: |
| + explicit InterceptedIcon(NSString* file_type, |
| + bool flip_icon, |
| + IconSize icon_size); |
| + ~InterceptedIcon(); |
| + // Returns the image for this icon. The image is loaded lazily. An empty |
| + // image is returned in case the image can't be loaded. |
| + const gfx::Image GetImage() const; |
| + |
| + private: |
| + // File type to which this icon corresponds. |
| + NSString* file_type_; |
| + // Image for this icon type. |
| + mutable gfx::Image icon_image_; |
| + // If true, the icon image is flipped. Used to create images for RTL |
| + // contexts. |
| + bool flip_icon_; |
| + // The desired icon size. |
| + IconSize icon_size_; |
| + // True if the image has been loaded. For lazy loading of images. |
| + mutable bool is_image_loaded_; |
| + }; |
| + |
| + typedef std::map<int, InterceptedIcon> InterceptedIconsMap; |
| + |
| + // A map from intercepted resource_ids to corresponding InterceptedIcon |
| + // resource. |
| + 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.
|
| + |
| + DISALLOW_COPY_AND_ASSIGN(MacResourceDelegate); |
| +}; |
| + |
| +} // namespace ui |
| + |
| +#endif // UI_BASE_RESOURCE_RESOURCE_DELEGATE_MAC_H_ |