summaryrefslogtreecommitdiff
path: root/chromium/ui/views/background.cc
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@qt.io>2017-07-17 13:57:45 +0200
committerAllan Sandfeld Jensen <allan.jensen@qt.io>2017-07-19 13:44:40 +0000
commit6ec7b8da05d21a3878bd21c691b41e675d74bb1c (patch)
treeb87f250bc19413750b9bb9cdbf2da20ef5014820 /chromium/ui/views/background.cc
parentec02ee4181c49b61fce1c8fb99292dbb8139cc90 (diff)
downloadqtwebengine-chromium-6ec7b8da05d21a3878bd21c691b41e675d74bb1c.tar.gz
BASELINE: Update Chromium to 60.0.3112.70
Change-Id: I9911c2280a014d4632f254857876a395d4baed2d Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Diffstat (limited to 'chromium/ui/views/background.cc')
-rw-r--r--chromium/ui/views/background.cc37
1 files changed, 37 insertions, 0 deletions
diff --git a/chromium/ui/views/background.cc b/chromium/ui/views/background.cc
index 190a5a62c34..901aa03b849 100644
--- a/chromium/ui/views/background.cc
+++ b/chromium/ui/views/background.cc
@@ -6,11 +6,14 @@
#include "base/logging.h"
#include "base/macros.h"
+#include "base/scoped_observer.h"
#include "build/build_config.h"
#include "ui/gfx/canvas.h"
+#include "ui/gfx/color_palette.h"
#include "ui/gfx/color_utils.h"
#include "ui/views/painter.h"
#include "ui/views/view.h"
+#include "ui/views/view_observer.h"
#if defined(OS_WIN)
#include "skia/ext/skia_utils_win.h"
@@ -36,6 +39,33 @@ class SolidBackground : public Background {
DISALLOW_COPY_AND_ASSIGN(SolidBackground);
};
+// ThemedSolidBackground is a solid background that stays in sync with a view's
+// native theme.
+class ThemedSolidBackground : public SolidBackground, public ViewObserver {
+ public:
+ explicit ThemedSolidBackground(View* view, ui::NativeTheme::ColorId color_id)
+ : SolidBackground(gfx::kPlaceholderColor),
+ observer_(this),
+ color_id_(color_id) {
+ observer_.Add(view);
+ OnViewNativeThemeChanged(view);
+ }
+ ~ThemedSolidBackground() override {}
+
+ // ViewObserver:
+ void OnViewNativeThemeChanged(View* view) override {
+ SetNativeControlColor(view->GetNativeTheme()->GetSystemColor(color_id_));
+ view->SchedulePaint();
+ }
+ void OnViewIsDeleting(View* view) override { observer_.Remove(view); }
+
+ private:
+ ScopedObserver<View, ViewObserver> observer_;
+ ui::NativeTheme::ColorId color_id_;
+
+ DISALLOW_COPY_AND_ASSIGN(ThemedSolidBackground);
+};
+
class BackgroundPainter : public Background {
public:
explicit BackgroundPainter(std::unique_ptr<Painter> painter)
@@ -73,6 +103,13 @@ Background* Background::CreateSolidBackground(SkColor color) {
}
// static
+Background* Background::CreateThemedSolidBackground(
+ View* view,
+ ui::NativeTheme::ColorId color_id) {
+ return new ThemedSolidBackground(view, color_id);
+}
+
+// static
Background* Background::CreateStandardPanelBackground() {
// TODO(beng): Should be in NativeTheme.
return CreateSolidBackground(SK_ColorWHITE);