diff options
author | sky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-11-02 01:18:56 +0000 |
---|---|---|
committer | sky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-11-02 01:18:56 +0000 |
commit | fd183d21e6558c822a63e98062aa21b71e91b60d (patch) | |
tree | 85d36c71ffc7eee8a3fabe56f9925d08664217dd /ui | |
parent | 60f0be8ec2cf44a1a9274dd8ea9802f6cc083b3b (diff) | |
download | chromium_src-fd183d21e6558c822a63e98062aa21b71e91b60d.zip chromium_src-fd183d21e6558c822a63e98062aa21b71e91b60d.tar.gz chromium_src-fd183d21e6558c822a63e98062aa21b71e91b60d.tar.bz2 |
Adds View::GetNativeTheme() to get the NativeTheme. The interesting
bit is in DesktopRootWindowHostWin that decides when to use the native
or aura versions.
BUG=none
TEST=none
R=ben@chromium.org
Review URL: https://chromiumcodereview.appspot.com/11367041
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@165585 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui')
-rw-r--r-- | ui/base/native_theme/native_theme_aura.cc | 2 | ||||
-rw-r--r-- | ui/base/native_theme/native_theme_aura.h | 2 | ||||
-rw-r--r-- | ui/base/native_theme/native_theme_base.h | 2 | ||||
-rw-r--r-- | ui/ui.gyp | 2 | ||||
-rw-r--r-- | ui/views/view.cc | 5 | ||||
-rw-r--r-- | ui/views/view.h | 6 | ||||
-rw-r--r-- | ui/views/widget/desktop_native_widget_aura.cc | 5 | ||||
-rw-r--r-- | ui/views/widget/desktop_native_widget_aura.h | 1 | ||||
-rw-r--r-- | ui/views/widget/desktop_root_window_host.h | 7 | ||||
-rw-r--r-- | ui/views/widget/desktop_root_window_host_linux.cc | 6 | ||||
-rw-r--r-- | ui/views/widget/desktop_root_window_host_win.cc | 20 | ||||
-rw-r--r-- | ui/views/widget/native_widget_aura.cc | 12 | ||||
-rw-r--r-- | ui/views/widget/native_widget_aura.h | 1 | ||||
-rw-r--r-- | ui/views/widget/native_widget_private.h | 2 | ||||
-rw-r--r-- | ui/views/widget/native_widget_win.cc | 5 | ||||
-rw-r--r-- | ui/views/widget/native_widget_win.h | 1 | ||||
-rw-r--r-- | ui/views/widget/widget.cc | 4 | ||||
-rw-r--r-- | ui/views/widget/widget.h | 3 |
18 files changed, 80 insertions, 6 deletions
diff --git a/ui/base/native_theme/native_theme_aura.cc b/ui/base/native_theme/native_theme_aura.cc index 542d822..19ff7e3 100644 --- a/ui/base/native_theme/native_theme_aura.cc +++ b/ui/base/native_theme/native_theme_aura.cc @@ -53,10 +53,12 @@ const SkColor kTextfieldSelectionColor = namespace ui { +#if !defined(OS_WIN) // static NativeTheme* NativeTheme::instance() { return NativeThemeAura::instance(); } +#endif // static NativeThemeAura* NativeThemeAura::instance() { diff --git a/ui/base/native_theme/native_theme_aura.h b/ui/base/native_theme/native_theme_aura.h index aa2bcc8..c3807e1 100644 --- a/ui/base/native_theme/native_theme_aura.h +++ b/ui/base/native_theme/native_theme_aura.h @@ -12,7 +12,7 @@ namespace ui { // Aura implementation of native theme support. -class NativeThemeAura : public NativeThemeBase { +class UI_EXPORT NativeThemeAura : public NativeThemeBase { public: static NativeThemeAura* instance(); diff --git a/ui/base/native_theme/native_theme_base.h b/ui/base/native_theme/native_theme_base.h index 41a9c6a..08a8549 100644 --- a/ui/base/native_theme/native_theme_base.h +++ b/ui/base/native_theme/native_theme_base.h @@ -19,7 +19,7 @@ class Size; namespace ui { // Theme support for non-Windows toolkits. -class NativeThemeBase : public NativeTheme { +class UI_EXPORT NativeThemeBase : public NativeTheme { public: // NativeTheme implementation: virtual gfx::Size GetPartSize(Part part, @@ -614,8 +614,6 @@ 'sources/': [ ['exclude', 'base/dragdrop/os_exchange_data_provider_win.cc'], ['exclude', 'base/dragdrop/os_exchange_data_provider_win.h'], - ['exclude', 'base/native_theme/native_theme_win.cc'], - ['exclude', 'base/native_theme/native_theme_win.h'], ], }], ['use_aura==0 and toolkit_views==0', { diff --git a/ui/views/view.cc b/ui/views/view.cc index 3f36ec1..a0b774c 100644 --- a/ui/views/view.cc +++ b/ui/views/view.cc @@ -734,6 +734,11 @@ ui::ThemeProvider* View::GetThemeProvider() const { return widget ? widget->GetThemeProvider() : NULL; } +ui::NativeTheme* View::GetNativeTheme() { + Widget* widget = GetWidget(); + return widget ? widget->GetNativeTheme() : NULL; +} + // Accelerated Painting -------------------------------------------------------- // static diff --git a/ui/views/view.h b/ui/views/view.h index 76d09d4..7e663c9 100644 --- a/ui/views/view.h +++ b/ui/views/view.h @@ -46,6 +46,7 @@ namespace ui { struct AccessibleViewState; class Compositor; class Layer; +class NativeTheme; class TextInputClient; class Texture; class ThemeProvider; @@ -471,6 +472,11 @@ class VIEWS_EXPORT View : public ui::LayerDelegate, // Get the theme provider from the parent widget. virtual ui::ThemeProvider* GetThemeProvider() const; + // Returns the NativeTheme to use for this View. This calls through to + // GetNativeTheme() on the Widget this View is in. If this View is not in a + // Widget this returns NULL. + ui::NativeTheme* GetNativeTheme(); + // RTL painting -------------------------------------------------------------- // This method determines whether the gfx::Canvas object passed to diff --git a/ui/views/widget/desktop_native_widget_aura.cc b/ui/views/widget/desktop_native_widget_aura.cc index 8167153d..085ff4e 100644 --- a/ui/views/widget/desktop_native_widget_aura.cc +++ b/ui/views/widget/desktop_native_widget_aura.cc @@ -12,6 +12,7 @@ #include "ui/aura/window.h" #include "ui/aura/window_property.h" #include "ui/base/hit_test.h" +#include "ui/base/native_theme/native_theme.h" #include "ui/compositor/layer.h" #include "ui/gfx/canvas.h" #include "ui/views/ime/input_method.h" @@ -413,6 +414,10 @@ void DesktopNativeWidgetAura::SetVisibilityChangedAnimationsEnabled( desktop_root_window_host_->SetVisibilityChangedAnimationsEnabled(value); } +ui::NativeTheme* DesktopNativeWidgetAura::GetNativeTheme() { + return DesktopRootWindowHost::GetNativeTheme(window_); +} + //////////////////////////////////////////////////////////////////////////////// // DesktopNativeWidgetAura, aura::WindowDelegate implementation: diff --git a/ui/views/widget/desktop_native_widget_aura.h b/ui/views/widget/desktop_native_widget_aura.h index 608cd86..1efc3be 100644 --- a/ui/views/widget/desktop_native_widget_aura.h +++ b/ui/views/widget/desktop_native_widget_aura.h @@ -123,6 +123,7 @@ class VIEWS_EXPORT DesktopNativeWidgetAura const gfx::Vector2d& drag_offset) OVERRIDE; virtual void EndMoveLoop() OVERRIDE; virtual void SetVisibilityChangedAnimationsEnabled(bool value) OVERRIDE; + virtual ui::NativeTheme* GetNativeTheme() OVERRIDE; // Overridden from aura::WindowDelegate: virtual gfx::Size GetMinimumSize() const OVERRIDE; diff --git a/ui/views/widget/desktop_root_window_host.h b/ui/views/widget/desktop_root_window_host.h index 0f175d3..7557413 100644 --- a/ui/views/widget/desktop_root_window_host.h +++ b/ui/views/widget/desktop_root_window_host.h @@ -19,6 +19,10 @@ class ImageSkia; class Rect; } +namespace ui { +class NativeTheme; +} + namespace views { class DesktopNativeWidgetAura; namespace internal { @@ -35,6 +39,9 @@ class VIEWS_EXPORT DesktopRootWindowHost { DesktopNativeWidgetAura* desktop_native_widget_aura, const gfx::Rect& initial_bounds); + // Return the NativeTheme to use for |window|. + static ui::NativeTheme* GetNativeTheme(aura::Window* window); + // Creates the aura resources associated with the native window we built. // Caller takes ownership of returned RootWindow. virtual aura::RootWindow* Init(aura::Window* content_window, diff --git a/ui/views/widget/desktop_root_window_host_linux.cc b/ui/views/widget/desktop_root_window_host_linux.cc index 829cfd2..a0682ea 100644 --- a/ui/views/widget/desktop_root_window_host_linux.cc +++ b/ui/views/widget/desktop_root_window_host_linux.cc @@ -21,6 +21,7 @@ #include "ui/aura/shared/compound_event_filter.h" #include "ui/aura/shared/input_method_event_filter.h" #include "ui/aura/window_property.h" +#include "ui/base/native_theme/native_theme.h" #include "ui/base/touch/touch_factory.h" #include "ui/base/x/x11_util.h" #include "ui/views/ime/input_method_bridge.h" @@ -87,6 +88,11 @@ DesktopRootWindowHostLinux::DesktopRootWindowHostLinux( DesktopRootWindowHostLinux::~DesktopRootWindowHostLinux() { } +// static +ui::NativeTheme* DesktopRootWindowLinux::GetNativeTheme(aura::Window* window) { + return NativeTheme::instance(); +} + //////////////////////////////////////////////////////////////////////////////// // DesktopRootWindowHostLinux, private: diff --git a/ui/views/widget/desktop_root_window_host_win.cc b/ui/views/widget/desktop_root_window_host_win.cc index c5b14f9..8cb9bf3 100644 --- a/ui/views/widget/desktop_root_window_host_win.cc +++ b/ui/views/widget/desktop_root_window_host_win.cc @@ -16,6 +16,8 @@ #include "ui/aura/shared/input_method_event_filter.h" #include "ui/aura/window_property.h" #include "ui/base/cursor/cursor_loader_win.h" +#include "ui/base/native_theme/native_theme_aura.h" +#include "ui/base/native_theme/native_theme_win.h" #include "ui/base/win/shell.h" #include "ui/gfx/native_widget_types.h" #include "ui/gfx/path_win.h" @@ -31,8 +33,7 @@ namespace views { -DEFINE_WINDOW_PROPERTY_KEY( - aura::Window*, kContentWindowForRootWindow, NULL); +DEFINE_WINDOW_PROPERTY_KEY(aura::Window*, kContentWindowForRootWindow, NULL); //////////////////////////////////////////////////////////////////////////////// // DesktopRootWindowHostWin, public: @@ -58,6 +59,21 @@ aura::Window* DesktopRootWindowHostWin::GetContentWindowForHWND(HWND hwnd) { return root ? root->GetProperty(kContentWindowForRootWindow) : NULL; } +// static +ui::NativeTheme* DesktopRootWindowHost::GetNativeTheme(aura::Window* window) { + // Use NativeThemeWin for windows shown on the desktop, those not on the + // desktop come from Ash and get NativeThemeAura. + aura::RootWindow* root = window->GetRootWindow(); + if (root) { + HWND root_hwnd = root->GetAcceleratedWidget(); + if (root_hwnd && + DesktopRootWindowHostWin::GetContentWindowForHWND(root_hwnd)) { + return ui::NativeThemeWin::instance(); + } + } + return ui::NativeThemeAura::instance(); +} + //////////////////////////////////////////////////////////////////////////////// // DesktopRootWindowHostWin, DesktopRootWindowHost implementation: diff --git a/ui/views/widget/native_widget_aura.cc b/ui/views/widget/native_widget_aura.cc index 9ce9723..84f59dc 100644 --- a/ui/views/widget/native_widget_aura.cc +++ b/ui/views/widget/native_widget_aura.cc @@ -23,6 +23,7 @@ #include "ui/aura/window_observer.h" #include "ui/base/dragdrop/os_exchange_data.h" #include "ui/base/events/event.h" +#include "ui/base/native_theme/native_theme_aura.h" #include "ui/base/ui_base_types.h" #include "ui/compositor/layer.h" #include "ui/gfx/canvas.h" @@ -46,6 +47,10 @@ #include "ui/base/l10n/l10n_util_win.h" #endif +#if !defined(OS_CHROMEOS) +#include "ui/views/widget/desktop_root_window_host.h" +#endif + namespace views { namespace { @@ -615,6 +620,13 @@ void NativeWidgetAura::SetVisibilityChangedAnimationsEnabled(bool value) { window_->SetProperty(aura::client::kAnimationsDisabledKey, !value); } +ui::NativeTheme* NativeWidgetAura::GetNativeTheme() { +#if !defined(OS_CHROMEOS) + return DesktopRootWindowHost::GetNativeTheme(window_); +#endif + return ui::NativeThemeAura::instance(); +} + //////////////////////////////////////////////////////////////////////////////// // NativeWidgetAura, views::InputMethodDelegate implementation: diff --git a/ui/views/widget/native_widget_aura.h b/ui/views/widget/native_widget_aura.h index 8f6157f..04a91ca 100644 --- a/ui/views/widget/native_widget_aura.h +++ b/ui/views/widget/native_widget_aura.h @@ -124,6 +124,7 @@ class VIEWS_EXPORT NativeWidgetAura : public internal::NativeWidgetPrivate, const gfx::Vector2d& drag_offset) OVERRIDE; virtual void EndMoveLoop() OVERRIDE; virtual void SetVisibilityChangedAnimationsEnabled(bool value) OVERRIDE; + virtual ui::NativeTheme* GetNativeTheme() OVERRIDE; // Overridden from views::InputMethodDelegate: virtual void DispatchKeyEventPostIME(const ui::KeyEvent& key) OVERRIDE; diff --git a/ui/views/widget/native_widget_private.h b/ui/views/widget/native_widget_private.h index c210a20..f86da87 100644 --- a/ui/views/widget/native_widget_private.h +++ b/ui/views/widget/native_widget_private.h @@ -17,6 +17,7 @@ class Rect; } namespace ui { +class NativeTheme; class OSExchangeData; } @@ -214,6 +215,7 @@ class VIEWS_EXPORT NativeWidgetPrivate : public NativeWidget { const gfx::Vector2d& drag_offset) = 0; virtual void EndMoveLoop() = 0; virtual void SetVisibilityChangedAnimationsEnabled(bool value) = 0; + virtual ui::NativeTheme* GetNativeTheme() = 0; // Overridden from NativeWidget: virtual internal::NativeWidgetPrivate* AsNativeWidgetPrivate() OVERRIDE; diff --git a/ui/views/widget/native_widget_win.cc b/ui/views/widget/native_widget_win.cc index 628b0cc..0692f0d 100644 --- a/ui/views/widget/native_widget_win.cc +++ b/ui/views/widget/native_widget_win.cc @@ -21,6 +21,7 @@ #include "ui/base/events/event.h" #include "ui/base/keycodes/keyboard_code_conversion_win.h" #include "ui/base/l10n/l10n_util_win.h" +#include "ui/base/native_theme/native_theme.h" #include "ui/base/theme_provider.h" #include "ui/base/view_prop.h" #include "ui/base/win/hwnd_util.h" @@ -484,6 +485,10 @@ void NativeWidgetWin::SetVisibilityChangedAnimationsEnabled(bool value) { message_handler_->SetVisibilityChangedAnimationsEnabled(value); } +ui::NativeTheme* NativeWidgetWin::GetNativeTheme() { + return ui::NativeTheme::instance(); +} + //////////////////////////////////////////////////////////////////////////////// // NativeWidgetWin, protected: diff --git a/ui/views/widget/native_widget_win.h b/ui/views/widget/native_widget_win.h index b50e925..e51a4da 100644 --- a/ui/views/widget/native_widget_win.h +++ b/ui/views/widget/native_widget_win.h @@ -167,6 +167,7 @@ class VIEWS_EXPORT NativeWidgetWin : public internal::NativeWidgetPrivate, const gfx::Vector2d& drag_offset) OVERRIDE; virtual void EndMoveLoop() OVERRIDE; virtual void SetVisibilityChangedAnimationsEnabled(bool value) OVERRIDE; + virtual ui::NativeTheme* GetNativeTheme() OVERRIDE; protected: // Deletes this window as it is destroyed, override to provide different diff --git a/ui/views/widget/widget.cc b/ui/views/widget/widget.cc index a4d48bb..41752a5 100644 --- a/ui/views/widget/widget.cc +++ b/ui/views/widget/widget.cc @@ -672,6 +672,10 @@ ui::ThemeProvider* Widget::GetThemeProvider() const { return default_theme_provider_.get(); } +ui::NativeTheme* Widget::GetNativeTheme() { + return native_widget_->GetNativeTheme(); +} + FocusManager* Widget::GetFocusManager() { Widget* toplevel_widget = GetTopLevelWidget(); return toplevel_widget ? toplevel_widget->focus_manager_.get() : NULL; diff --git a/ui/views/widget/widget.h b/ui/views/widget/widget.h index e906327..3c382eb 100644 --- a/ui/views/widget/widget.h +++ b/ui/views/widget/widget.h @@ -45,6 +45,7 @@ namespace ui { class Accelerator; class Compositor; class Layer; +class NativeTheme; class OSExchangeData; class ThemeProvider; } @@ -431,6 +432,8 @@ class VIEWS_EXPORT Widget : public internal::NativeWidgetDelegate, // Returns the ThemeProvider that provides theme resources for this Widget. virtual ui::ThemeProvider* GetThemeProvider() const; + ui::NativeTheme* GetNativeTheme(); + // Returns the FocusManager for this widget. // Note that all widgets in a widget hierarchy share the same focus manager. FocusManager* GetFocusManager(); |