theme_provider.h 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. // Copyright (c) 2012 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. #ifndef UI_BASE_THEME_PROVIDER_H_
  5. #define UI_BASE_THEME_PROVIDER_H_
  6. #include "base/component_export.h"
  7. #include "third_party/skia/include/core/SkColor.h"
  8. #include "ui/base/layout.h"
  9. namespace base {
  10. class RefCountedMemory;
  11. }
  12. namespace color_utils {
  13. struct HSL;
  14. }
  15. namespace gfx {
  16. class ImageSkia;
  17. }
  18. namespace ui {
  19. ////////////////////////////////////////////////////////////////////////////////
  20. //
  21. // ThemeProvider
  22. //
  23. // ThemeProvider is an abstract class that defines the API that should be
  24. // implemented to provide bitmaps and color information for a given theme.
  25. //
  26. ////////////////////////////////////////////////////////////////////////////////
  27. class COMPONENT_EXPORT(UI_BASE) ThemeProvider {
  28. public:
  29. virtual ~ThemeProvider();
  30. // Get the image specified by |id|. An implementation of ThemeProvider should
  31. // have its own source of ids (e.g. an enum, or external resource bundle).
  32. virtual gfx::ImageSkia* GetImageSkiaNamed(int id) const = 0;
  33. // Get the HSL shift specified by |id|.
  34. virtual color_utils::HSL GetTint(int id) const = 0;
  35. // Get the property (e.g. an alignment expressed in an enum, or a width or
  36. // height) specified by |id|.
  37. virtual int GetDisplayProperty(int id) const = 0;
  38. // Whether we should use the native system frame (typically Aero glass) or
  39. // a custom frame.
  40. virtual bool ShouldUseNativeFrame() const = 0;
  41. // Whether or not we have a certain image. Used for when the default theme
  42. // doesn't provide a certain image, but custom themes might (badges, etc).
  43. virtual bool HasCustomImage(int id) const = 0;
  44. // Reads the image data from the theme file into the specified vector. Only
  45. // valid for un-themed resources and the themed IDR_THEME_NTP_* in most
  46. // implementations of ThemeProvider. Returns NULL on error.
  47. virtual base::RefCountedMemory* GetRawData(
  48. int id,
  49. ui::ResourceScaleFactor scale_factor) const = 0;
  50. };
  51. } // namespace ui
  52. #endif // UI_BASE_THEME_PROVIDER_H_