summaryrefslogtreecommitdiffstats
path: root/views/widget
diff options
context:
space:
mode:
authorben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-06-15 19:51:25 +0000
committerben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-06-15 19:51:25 +0000
commit958d3b6a8536203ad30439eeee82fb280150c15e (patch)
tree5548c8affb44ebf50e7598e7ec4fedfa366b1314 /views/widget
parent217d63f8020735f190237b3cfc337a794df1d212 (diff)
downloadchromium_src-958d3b6a8536203ad30439eeee82fb280150c15e.zip
chromium_src-958d3b6a8536203ad30439eeee82fb280150c15e.tar.gz
chromium_src-958d3b6a8536203ad30439eeee82fb280150c15e.tar.bz2
Revert 89216 - Move private NativeWidget methods to new internal interface NativeWidgetPrivate.
This should make it harder to abuse accidentally. BUG=72040 TEST=none Review URL: http://codereview.chromium.org/7170019 TBR=ben@chromium.org Review URL: http://codereview.chromium.org/7097016 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@89232 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'views/widget')
-rw-r--r--views/widget/native_widget.h192
-rw-r--r--views/widget/native_widget_gtk.cc90
-rw-r--r--views/widget/native_widget_gtk.h6
-rw-r--r--views/widget/native_widget_private.h206
-rw-r--r--views/widget/native_widget_test_utils.h8
-rw-r--r--views/widget/native_widget_test_utils_gtk.cc12
-rw-r--r--views/widget/native_widget_test_utils_win.cc12
-rw-r--r--views/widget/native_widget_unittest.cc16
-rw-r--r--views/widget/native_widget_views.cc11
-rw-r--r--views/widget/native_widget_views.h10
-rw-r--r--views/widget/native_widget_win.cc69
-rw-r--r--views/widget/native_widget_win.h6
-rw-r--r--views/widget/widget.cc78
-rw-r--r--views/widget/widget.h40
14 files changed, 319 insertions, 437 deletions
diff --git a/views/widget/native_widget.h b/views/widget/native_widget.h
index 9ed37e7..1e5b2df 100644
--- a/views/widget/native_widget.h
+++ b/views/widget/native_widget.h
@@ -6,31 +6,199 @@
#define VIEWS_WIDGET_NATIVE_WIDGET_H_
#pragma once
+#include <set>
+
+#include "ui/gfx/native_widget_types.h"
#include "views/widget/widget.h"
-namespace views {
-namespace internal {
-class NativeWidgetPrivate;
+namespace gfx {
+class Rect;
}
+namespace ui {
+class OSExchangeData;
+}
+
+namespace views {
+
+class InputMethod;
+class TooltipManager;
+
////////////////////////////////////////////////////////////////////////////////
// NativeWidget interface
//
-// An interface that serves as the public API base for the
-// internal::NativeWidget interface that Widget uses to communicate with a
-// backend-specific native widget implementation. This is the only component of
-// this interface that is publicly visible, and exists solely for exposure via
-// Widget's native_widget() accessor, which code occasionally static_casts to
-// a known implementation in platform-specific code.
+// An interface implemented by an object that encapsulates rendering, event
+// handling and widget management provided by an underlying native toolkit.
//
class NativeWidget {
public:
+ typedef std::set<NativeWidget*> NativeWidgets;
+
virtual ~NativeWidget() {}
- private:
- friend class Widget;
+ // Creates an appropriate default NativeWidget implementation for the current
+ // OS/circumstance.
+ static NativeWidget* CreateNativeWidget(
+ internal::NativeWidgetDelegate* delegate);
+
+ // Retrieves the NativeWidget implementation associated with the given
+ // NativeView or Window, or NULL if the supplied handle has no associated
+ // NativeView.
+ static NativeWidget* GetNativeWidgetForNativeView(
+ gfx::NativeView native_view);
+ static NativeWidget* GetNativeWidgetForNativeWindow(
+ gfx::NativeWindow native_window);
+
+ // Retrieves the top NativeWidget in the hierarchy containing the given
+ // NativeView, or NULL if there is no NativeWidget that contains it.
+ static NativeWidget* GetTopLevelNativeWidget(gfx::NativeView native_view);
+
+ // Returns all NativeWidgets in |native_view|'s hierarchy, including itself if
+ // it is one.
+ static void GetAllNativeWidgets(gfx::NativeView native_view,
+ NativeWidgets* children);
+
+ // Reparent a NativeView and notify all NativeWidgets in
+ // |native_view|'s hierarchy of the change.
+ static void ReparentNativeView(gfx::NativeView native_view,
+ gfx::NativeView new_parent);
+
+ // Initializes the NativeWidget.
+ virtual void InitNativeWidget(const Widget::InitParams& params) = 0;
+
+ // Returns a NonClientFrameView for the widget's NonClientView, or NULL if
+ // the NativeWidget wants no special NonClientFrameView.
+ virtual NonClientFrameView* CreateNonClientFrameView() = 0;
+
+ virtual void UpdateFrameAfterFrameChange() = 0;
+ virtual bool ShouldUseNativeFrame() const = 0;
+ virtual void FrameTypeChanged() = 0;
+
+ // Returns the Widget associated with this NativeWidget. This function is
+ // guaranteed to return non-NULL for the lifetime of the NativeWidget.
+ virtual Widget* GetWidget() = 0;
+ virtual const Widget* GetWidget() const = 0;
+
+ // Returns the NativeView/Window associated with this NativeWidget.
+ virtual gfx::NativeView GetNativeView() const = 0;
+ virtual gfx::NativeWindow GetNativeWindow() const = 0;
+
+ // Notifies the NativeWidget that a view was removed from the Widget's view
+ // hierarchy.
+ virtual void ViewRemoved(View* view) = 0;
+
+ // Sets/Gets a native window property on the underlying native window object.
+ // Returns NULL if the property does not exist. Setting the property value to
+ // NULL removes the property.
+ virtual void SetNativeWindowProperty(const char* name, void* value) = 0;
+ virtual void* GetNativeWindowProperty(const char* name) const = 0;
+
+ // Returns the native widget's tooltip manager. Called from the View hierarchy
+ // to update tooltips.
+ virtual TooltipManager* GetTooltipManager() const = 0;
+
+ // Returns true if a system screen reader is active for the NativeWidget.
+ virtual bool IsScreenReaderActive() const = 0;
+
+ // Notify native Accessibility clients of an event.
+ virtual void SendNativeAccessibilityEvent(
+ View* view,
+ ui::AccessibilityTypes::Event event_type) = 0;
+
+ // Sets or releases event capturing for this native widget.
+ virtual void SetMouseCapture() = 0;
+ virtual void ReleaseMouseCapture() = 0;
+
+ // Returns true if this native widget is capturing all events.
+ virtual bool HasMouseCapture() const = 0;
+
+ // Returns true if any mouse button is currently pressed.
+ virtual bool IsMouseButtonDown() const = 0;
+
+ // Returns the InputMethod for this native widget.
+ // Note that all widgets in a widget hierarchy share the same input method.
+ // TODO(suzhe): rename to GetInputMethod() when NativeWidget implementation
+ // class doesn't inherit Widget anymore.
+ virtual InputMethod* GetInputMethodNative() = 0;
+
+ // Sets a different InputMethod instance to this native widget. The instance
+ // must not be initialized, the ownership will be assumed by the native
+ // widget. It's only for testing purpose.
+ virtual void ReplaceInputMethod(InputMethod* input_method) = 0;
+
+ // Centers the window and sizes it to the specified size.
+ virtual void CenterWindow(const gfx::Size& size) = 0;
+
+ // Retrieves the window's current restored bounds and maximized state, for
+ // persisting.
+ virtual void GetWindowBoundsAndMaximizedState(gfx::Rect* bounds,
+ bool* maximized) const = 0;
+
+ // Sets the NativeWindow title.
+ virtual void SetWindowTitle(const std::wstring& title) = 0;
+
+ // Sets the Window icons. |window_icon| is a 16x16 icon suitable for use in
+ // a title bar. |app_icon| is a larger size for use in the host environment
+ // app switching UI.
+ virtual void SetWindowIcons(const SkBitmap& window_icon,
+ const SkBitmap& app_icon) = 0;
+
+ // Update native accessibility properties on the native window.
+ virtual void SetAccessibleName(const std::wstring& name) = 0;
+ virtual void SetAccessibleRole(ui::AccessibilityTypes::Role role) = 0;
+ virtual void SetAccessibleState(ui::AccessibilityTypes::State state) = 0;
+
+ enum ShowState {
+ SHOW_RESTORED,
+ SHOW_MAXIMIZED,
+ SHOW_INACTIVE
+ };
+
+ // Returns a handle for the underlying native widget that can be used for
+ // accelerated drawing.
+ virtual gfx::AcceleratedWidget GetAcceleratedWidget() = 0;
+
+ // Makes the NativeWindow modal.
+ virtual void BecomeModal() = 0;
- virtual internal::NativeWidgetPrivate* AsNativeWidgetPrivate() = 0;
+ // Widget pass-thrus, private to Views. --------------------------------------
+ // See method documentation in Widget.
+ virtual gfx::Rect GetWindowScreenBounds() const = 0;
+ virtual gfx::Rect GetClientAreaScreenBounds() const = 0;
+ virtual gfx::Rect GetRestoredBounds() const = 0;
+ virtual void SetBounds(const gfx::Rect& bounds) = 0;
+ virtual void SetSize(const gfx::Size& size) = 0;
+ virtual void SetBoundsConstrained(const gfx::Rect& bounds,
+ Widget* other_widget) = 0;
+ virtual void MoveAbove(gfx::NativeView native_view) = 0;
+ virtual void SetShape(gfx::NativeRegion shape) = 0;
+ virtual void Close() = 0;
+ virtual void CloseNow() = 0;
+ virtual void EnableClose(bool enable) = 0;
+ virtual void Show() = 0;
+ virtual void Hide() = 0;
+ virtual void ShowNativeWidget(ShowState state) = 0;
+ virtual bool IsVisible() const = 0;
+ virtual void Activate() = 0;
+ virtual void Deactivate() = 0;
+ virtual bool IsActive() const = 0;
+ virtual void SetAlwaysOnTop(bool always_on_top) = 0;
+ virtual void Maximize() = 0;
+ virtual void Minimize() = 0;
+ virtual bool IsMaximized() const = 0;
+ virtual bool IsMinimized() const = 0;
+ virtual void Restore() = 0;
+ virtual void SetFullscreen(bool fullscreen) = 0;
+ virtual bool IsFullscreen() const = 0;
+ virtual void SetOpacity(unsigned char opacity) = 0;
+ virtual void SetUseDragFrame(bool use_drag_frame) = 0;
+ virtual bool IsAccessibleWidget() const = 0;
+ virtual bool ContainsNativeView(gfx::NativeView native_view) const = 0;
+ virtual void RunShellDrag(View* view,
+ const ui::OSExchangeData& data,
+ int operation) = 0;
+ virtual void SchedulePaintInRect(const gfx::Rect& rect) = 0;
+ virtual void SetCursor(gfx::NativeCursor cursor) = 0;
};
} // namespace views
diff --git a/views/widget/native_widget_gtk.cc b/views/widget/native_widget_gtk.cc
index 6a1c0d8..74795e9 100644
--- a/views/widget/native_widget_gtk.cc
+++ b/views/widget/native_widget_gtk.cc
@@ -163,10 +163,12 @@ void EnumerateChildWidgetsForNativeWidgets(GtkWidget* child_widget,
param);
}
- Widget* widget = Widget::GetWidgetForNativeView(child_widget);
- if (widget) {
- Widget::Widgets* widgets = reinterpret_cast<Widget::Widgets*>(param);
- widgets->insert(widget);
+ NativeWidget* native_widget =
+ NativeWidget::GetNativeWidgetForNativeView(child_widget);
+ if (native_widget) {
+ NativeWidget::NativeWidgets* widgets =
+ reinterpret_cast<NativeWidget::NativeWidgets*>(param);
+ widgets->insert(native_widget);
}
}
@@ -278,8 +280,7 @@ class NativeWidgetGtk::DropObserver : public MessageLoopForUI::Observer {
return NULL;
return static_cast<NativeWidgetGtk*>(
- internal::NativeWidgetPrivate::GetNativeWidgetForNativeView(
- gtk_widget));
+ NativeWidget::GetNativeWidgetForNativeView(gtk_widget));
}
DISALLOW_COPY_AND_ASSIGN(DropObserver);
@@ -1001,7 +1002,7 @@ void NativeWidgetGtk::SetBounds(const gfx::Rect& bounds) {
GtkWidget* parent = gtk_widget_get_parent(widget_);
if (GTK_IS_VIEWS_FIXED(parent)) {
NativeWidgetGtk* parent_widget = static_cast<NativeWidgetGtk*>(
- internal::NativeWidgetPrivate::GetNativeWidgetForNativeView(parent));
+ NativeWidget::GetNativeWidgetForNativeView(parent));
parent_widget->PositionChild(widget_, bounds.x(), bounds.y(),
bounds.width(), bounds.height());
} else {
@@ -1111,7 +1112,7 @@ void NativeWidgetGtk::Hide() {
void NativeWidgetGtk::ShowNativeWidget(ShowState state) {
// No concept of maximization (yet) on ChromeOS.
- if (state == internal::NativeWidgetPrivate::SHOW_INACTIVE)
+ if (state == NativeWidget::SHOW_INACTIVE)
gtk_window_set_focus_on_map(GetNativeWindow(), false);
gtk_widget_show(GetNativeView());
}
@@ -1755,10 +1756,10 @@ gboolean NativeWidgetGtk::ChildExposeHandler(GtkWidget* widget,
GdkEventExpose* event) {
GtkWidget* toplevel = gtk_widget_get_ancestor(widget, GTK_TYPE_WINDOW);
CHECK(toplevel);
- Widget* views_widget = Widget::GetWidgetForNativeView(toplevel);
- CHECK(views_widget);
- NativeWidgetGtk* widget_gtk =
- static_cast<NativeWidgetGtk*>(views_widget->native_widget());
+ NativeWidget* native_widget =
+ NativeWidget::GetNativeWidgetForNativeView(toplevel);
+ CHECK(native_widget);
+ NativeWidgetGtk* widget_gtk = static_cast<NativeWidgetGtk*>(native_widget);
widget_gtk->OnChildExpose(widget);
return false;
}
@@ -1953,10 +1954,10 @@ void NativeWidgetGtk::SaveWindowPosition() {
void Widget::NotifyLocaleChanged() {
GList *window_list = gtk_window_list_toplevels();
for (GList* element = window_list; element; element = g_list_next(element)) {
- Widget* widget =
- Widget::GetWidgetForNativeWindow(GTK_WINDOW(element->data));
- if (widget)
- widget->LocaleChanged();
+ NativeWidget* native_widget =
+ NativeWidget::GetNativeWidgetForNativeWindow(GTK_WINDOW(element->data));
+ if (native_widget)
+ native_widget->GetWidget()->LocaleChanged();
}
g_list_free(window_list);
}
@@ -1966,9 +1967,13 @@ void Widget::CloseAllSecondaryWidgets() {
GList* windows = gtk_window_list_toplevels();
for (GList* window = windows; window;
window = g_list_next(window)) {
- Widget* widget = Widget::GetWidgetForNativeView(GTK_WIDGET(window->data));
- if (widget && widget->is_secondary_widget())
- widget->Close();
+ NativeWidget* native_widget = NativeWidget::GetNativeWidgetForNativeView(
+ GTK_WIDGET(window->data));
+ if (native_widget) {
+ Widget* widget = native_widget->GetWidget();
+ if (widget->is_secondary_widget())
+ widget->Close();
+ }
}
g_list_free(windows);
}
@@ -1999,19 +2004,17 @@ bool Widget::ConvertRect(const Widget* source,
return false;
}
-namespace internal {
-
////////////////////////////////////////////////////////////////////////////////
-// NativeWidgetPrivate, public:
+// NativeWidget, public:
// static
-NativeWidgetPrivate* NativeWidgetPrivate::CreateNativeWidget(
- NativeWidgetDelegate* delegate) {
+NativeWidget* NativeWidget::CreateNativeWidget(
+ internal::NativeWidgetDelegate* delegate) {
return new NativeWidgetGtk(delegate);
}
// static
-NativeWidgetPrivate* NativeWidgetPrivate::GetNativeWidgetForNativeView(
+NativeWidget* NativeWidget::GetNativeWidgetForNativeView(
gfx::NativeView native_view) {
if (!native_view)
return NULL;
@@ -2020,7 +2023,7 @@ NativeWidgetPrivate* NativeWidgetPrivate::GetNativeWidgetForNativeView(
}
// static
-NativeWidgetPrivate* NativeWidgetPrivate::GetNativeWidgetForNativeWindow(
+NativeWidget* NativeWidget::GetNativeWidgetForNativeWindow(
gfx::NativeWindow native_window) {
if (!native_window)
return NULL;
@@ -2029,15 +2032,15 @@ NativeWidgetPrivate* NativeWidgetPrivate::GetNativeWidgetForNativeWindow(
}
// static
-NativeWidgetPrivate* NativeWidgetPrivate::GetTopLevelNativeWidget(
+NativeWidget* NativeWidget::GetTopLevelNativeWidget(
gfx::NativeView native_view) {
if (!native_view)
return NULL;
- NativeWidgetPrivate* widget = NULL;
+ NativeWidget* widget = NULL;
GtkWidget* parent_gtkwidget = native_view;
- NativeWidgetPrivate* parent_widget;
+ NativeWidget* parent_widget;
do {
parent_widget = GetNativeWidgetForNativeView(parent_gtkwidget);
if (parent_widget)
@@ -2049,22 +2052,22 @@ NativeWidgetPrivate* NativeWidgetPrivate::GetTopLevelNativeWidget(
}
// static
-void NativeWidgetPrivate::GetAllChildWidgets(gfx::NativeView native_view,
- Widget::Widgets* children) {
+void NativeWidget::GetAllNativeWidgets(gfx::NativeView native_view,
+ NativeWidgets* children) {
if (!native_view)
return;
- Widget* widget = Widget::GetWidgetForNativeView(native_view);
- if (widget)
- children->insert(widget);
+ NativeWidget* native_widget = GetNativeWidgetForNativeView(native_view);
+ if (native_widget)
+ children->insert(native_widget);
gtk_container_foreach(GTK_CONTAINER(native_view),
EnumerateChildWidgetsForNativeWidgets,
reinterpret_cast<gpointer>(children));
}
// static
-void NativeWidgetPrivate::ReparentNativeView(gfx::NativeView native_view,
- gfx::NativeView new_parent) {
+void NativeWidget::ReparentNativeView(gfx::NativeView native_view,
+ gfx::NativeView new_parent) {
if (!native_view)
return;
@@ -2072,16 +2075,17 @@ void NativeWidgetPrivate::ReparentNativeView(gfx::NativeView native_view,
if (previous_parent == new_parent)
return;
- Widget::Widgets widgets;
- GetAllChildWidgets(native_view, &widgets);
+ NativeWidgets widgets;
+ GetAllNativeWidgets(native_view, &widgets);
// First notify all the widgets that they are being disassociated
// from their previous parent.
- for (Widget::Widgets::iterator it = widgets.begin();
+ for (NativeWidgets::iterator it = widgets.begin();
it != widgets.end(); ++it) {
// TODO(beng): Rename this notification to NotifyNativeViewChanging()
// and eliminate the bool parameter.
- (*it)->NotifyNativeViewHierarchyChanged(false, previous_parent);
+ (*it)->GetWidget()->NotifyNativeViewHierarchyChanged(false,
+ previous_parent);
}
if (gtk_widget_get_parent(native_view))
@@ -2090,11 +2094,11 @@ void NativeWidgetPrivate::ReparentNativeView(gfx::NativeView native_view,
gtk_container_add(GTK_CONTAINER(new_parent), native_view);
// And now, notify them that they have a brand new parent.
- for (Widget::Widgets::iterator it = widgets.begin();
+ for (NativeWidgets::iterator it = widgets.begin();
it != widgets.end(); ++it) {
- (*it)->NotifyNativeViewHierarchyChanged(true, new_parent);
+ (*it)->GetWidget()->NotifyNativeViewHierarchyChanged(true,
+ new_parent);
}
}
-} // namespace internal
} // namespace views
diff --git a/views/widget/native_widget_gtk.h b/views/widget/native_widget_gtk.h
index 4565b39..559d98c 100644
--- a/views/widget/native_widget_gtk.h
+++ b/views/widget/native_widget_gtk.h
@@ -14,7 +14,7 @@
#include "ui/gfx/size.h"
#include "views/focus/focus_manager.h"
#include "views/ime/input_method_delegate.h"
-#include "views/widget/native_widget_private.h"
+#include "views/widget/native_widget.h"
#include "views/widget/widget.h"
namespace gfx {
@@ -40,7 +40,7 @@ class NativeWidgetDelegate;
}
// Widget implementation for GTK.
-class NativeWidgetGtk : public internal::NativeWidgetPrivate,
+class NativeWidgetGtk : public NativeWidget,
public ui::ActiveWindowWatcherX::Observer,
public internal::InputMethodDelegate {
public:
@@ -153,7 +153,7 @@ class NativeWidgetGtk : public internal::NativeWidgetPrivate,
focus_on_creation_ = focus_on_creation;
}
- // Overridden from internal::NativeWidgetPrivate:
+ // Overridden from NativeWidget:
virtual void InitNativeWidget(const Widget::InitParams& params) OVERRIDE;
virtual NonClientFrameView* CreateNonClientFrameView() OVERRIDE;
virtual void UpdateFrameAfterFrameChange() OVERRIDE;
diff --git a/views/widget/native_widget_private.h b/views/widget/native_widget_private.h
deleted file mode 100644
index 1e08184..0000000
--- a/views/widget/native_widget_private.h
+++ /dev/null
@@ -1,206 +0,0 @@
-// Copyright (c) 2011 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 VIEWS_WIDGET_NATIVE_WIDGET_PRIVATE_H_
-#define VIEWS_WIDGET_NATIVE_WIDGET_PRIVATE_H_
-#pragma once
-
-#include "ui/gfx/native_widget_types.h"
-#include "views/widget/native_widget.h"
-
-namespace gfx {
-class Rect;
-}
-
-namespace ui {
-class OSExchangeData;
-}
-
-namespace views {
-class InputMethod;
-class TooltipManager;
-namespace internal {
-
-////////////////////////////////////////////////////////////////////////////////
-// NativeWidgetPrivate interface
-//
-// A NativeWidget subclass internal to views that provides Widget a conduit for
-// communication with a backend-specific native widget implementation.
-//
-// Many of the methods here are pass-thrus for Widget, and as such there is no
-// documentation for them here. In that case, see methods of the same name in
-// widget.h.
-//
-// IMPORTANT: This type is intended for use only by the views system and for
-// NativeWidget implementations. This file should not be included
-// in code that does not fall into one of these use cases.
-//
-class NativeWidgetPrivate : public NativeWidget {
- public:
- virtual ~NativeWidgetPrivate() {}
-
- // Creates an appropriate default NativeWidgetPrivate implementation for the
- // current OS/circumstance.
- static NativeWidgetPrivate* CreateNativeWidget(
- internal::NativeWidgetDelegate* delegate);
-
- static NativeWidgetPrivate* GetNativeWidgetForNativeView(
- gfx::NativeView native_view);
- static NativeWidgetPrivate* GetNativeWidgetForNativeWindow(
- gfx::NativeWindow native_window);
-
- // Retrieves the top NativeWidgetPrivate in the hierarchy containing the given
- // NativeView, or NULL if there is no NativeWidgetPrivate that contains it.
- static NativeWidgetPrivate* GetTopLevelNativeWidget(
- gfx::NativeView native_view);
-
- static void GetAllChildWidgets(gfx::NativeView native_view,
- Widget::Widgets* children);
- static void ReparentNativeView(gfx::NativeView native_view,
- gfx::NativeView new_parent);
-
- // Initializes the NativeWidget.
- virtual void InitNativeWidget(const Widget::InitParams& params) = 0;
-
- // Returns a NonClientFrameView for the widget's NonClientView, or NULL if
- // the NativeWidget wants no special NonClientFrameView.
- virtual NonClientFrameView* CreateNonClientFrameView() = 0;
-
- virtual void UpdateFrameAfterFrameChange() = 0;
- virtual bool ShouldUseNativeFrame() const = 0;
- virtual void FrameTypeChanged() = 0;
-
- // Returns the Widget associated with this NativeWidget. This function is
- // guaranteed to return non-NULL for the lifetime of the NativeWidget.
- virtual Widget* GetWidget() = 0;
- virtual const Widget* GetWidget() const = 0;
-
- // Returns the NativeView/Window associated with this NativeWidget.
- virtual gfx::NativeView GetNativeView() const = 0;
- virtual gfx::NativeWindow GetNativeWindow() const = 0;
-
- // Notifies the NativeWidget that a view was removed from the Widget's view
- // hierarchy.
- virtual void ViewRemoved(View* view) = 0;
-
- // Sets/Gets a native window property on the underlying native window object.
- // Returns NULL if the property does not exist. Setting the property value to
- // NULL removes the property.
- virtual void SetNativeWindowProperty(const char* name, void* value) = 0;
- virtual void* GetNativeWindowProperty(const char* name) const = 0;
-
- // Returns the native widget's tooltip manager. Called from the View hierarchy
- // to update tooltips.
- virtual TooltipManager* GetTooltipManager() const = 0;
-
- // Returns true if a system screen reader is active for the NativeWidget.
- virtual bool IsScreenReaderActive() const = 0;
-
- // Notify native Accessibility clients of an event.
- virtual void SendNativeAccessibilityEvent(
- View* view,
- ui::AccessibilityTypes::Event event_type) = 0;
-
- // Sets or releases event capturing for this native widget.
- virtual void SetMouseCapture() = 0;
- virtual void ReleaseMouseCapture() = 0;
-
- // Returns true if this native widget is capturing all events.
- virtual bool HasMouseCapture() const = 0;
-
- // Returns true if any mouse button is currently pressed.
- virtual bool IsMouseButtonDown() const = 0;
-
- // Returns the InputMethod for this native widget.
- // Note that all widgets in a widget hierarchy share the same input method.
- // TODO(suzhe): rename to GetInputMethod() when NativeWidget implementation
- // class doesn't inherit Widget anymore.
- virtual InputMethod* GetInputMethodNative() = 0;
-
- // Sets a different InputMethod instance to this native widget. The instance
- // must not be initialized, the ownership will be assumed by the native
- // widget. It's only for testing purpose.
- virtual void ReplaceInputMethod(InputMethod* input_method) = 0;
-
- // Centers the window and sizes it to the specified size.
- virtual void CenterWindow(const gfx::Size& size) = 0;
-
- // Retrieves the window's current restored bounds and maximized state, for
- // persisting.
- virtual void GetWindowBoundsAndMaximizedState(gfx::Rect* bounds,
- bool* maximized) const = 0;
-
- // Sets the NativeWindow title.
- virtual void SetWindowTitle(const std::wstring& title) = 0;
-
- // Sets the Window icons. |window_icon| is a 16x16 icon suitable for use in
- // a title bar. |app_icon| is a larger size for use in the host environment
- // app switching UI.
- virtual void SetWindowIcons(const SkBitmap& window_icon,
- const SkBitmap& app_icon) = 0;
-
- // Update native accessibility properties on the native window.
- virtual void SetAccessibleName(const std::wstring& name) = 0;
- virtual void SetAccessibleRole(ui::AccessibilityTypes::Role role) = 0;
- virtual void SetAccessibleState(ui::AccessibilityTypes::State state) = 0;
-
- enum ShowState {
- SHOW_RESTORED,
- SHOW_MAXIMIZED,
- SHOW_INACTIVE
- };
-
- // Returns a handle for the underlying native widget that can be used for
- // accelerated drawing.
- virtual gfx::AcceleratedWidget GetAcceleratedWidget() = 0;
-
- // Makes the NativeWindow modal.
- virtual void BecomeModal() = 0;
-
- // See method documentation in Widget.
- virtual gfx::Rect GetWindowScreenBounds() const = 0;
- virtual gfx::Rect GetClientAreaScreenBounds() const = 0;
- virtual gfx::Rect GetRestoredBounds() const = 0;
- virtual void SetBounds(const gfx::Rect& bounds) = 0;
- virtual void SetSize(const gfx::Size& size) = 0;
- virtual void SetBoundsConstrained(const gfx::Rect& bounds,
- Widget* other_widget) = 0;
- virtual void MoveAbove(gfx::NativeView native_view) = 0;
- virtual void SetShape(gfx::NativeRegion shape) = 0;
- virtual void Close() = 0;
- virtual void CloseNow() = 0;
- virtual void EnableClose(bool enable) = 0;
- virtual void Show() = 0;
- virtual void Hide() = 0;
- virtual void ShowNativeWidget(ShowState state) = 0;
- virtual bool IsVisible() const = 0;
- virtual void Activate() = 0;
- virtual void Deactivate() = 0;
- virtual bool IsActive() const = 0;
- virtual void SetAlwaysOnTop(bool always_on_top) = 0;
- virtual void Maximize() = 0;
- virtual void Minimize() = 0;
- virtual bool IsMaximized() const = 0;
- virtual bool IsMinimized() const = 0;
- virtual void Restore() = 0;
- virtual void SetFullscreen(bool fullscreen) = 0;
- virtual bool IsFullscreen() const = 0;
- virtual void SetOpacity(unsigned char opacity) = 0;
- virtual void SetUseDragFrame(bool use_drag_frame) = 0;
- virtual bool IsAccessibleWidget() const = 0;
- virtual bool ContainsNativeView(gfx::NativeView native_view) const = 0;
- virtual void RunShellDrag(View* view,
- const ui::OSExchangeData& data,
- int operation) = 0;
- virtual void SchedulePaintInRect(const gfx::Rect& rect) = 0;
- virtual void SetCursor(gfx::NativeCursor cursor) = 0;
-
- // Overridden from NativeWidget:
- virtual internal::NativeWidgetPrivate* AsNativeWidgetPrivate() OVERRIDE;
-};
-
-} // namespace internal
-} // namespace views
-
-#endif // VIEWS_WIDGET_NATIVE_WIDGET_PRIVATE_H_
diff --git a/views/widget/native_widget_test_utils.h b/views/widget/native_widget_test_utils.h
index 2499a76..ac3e5b4 100644
--- a/views/widget/native_widget_test_utils.h
+++ b/views/widget/native_widget_test_utils.h
@@ -8,13 +8,13 @@
namespace views {
class View;
+class NativeWidget;
namespace internal {
-class NativeWidgetPrivate;
// Create dummy Widgets for use in testing.
-NativeWidgetPrivate* CreateNativeWidget();
-NativeWidgetPrivate* CreateNativeWidgetWithContents(View* contents_view);
-NativeWidgetPrivate* CreateNativeWidgetWithParent(NativeWidgetPrivate* parent);
+NativeWidget* CreateNativeWidget();
+NativeWidget* CreateNativeWidgetWithContents(View* contents_view);
+NativeWidget* CreateNativeWidgetWithParent(NativeWidget* parent);
} // namespace internal
} // namespace views
diff --git a/views/widget/native_widget_test_utils_gtk.cc b/views/widget/native_widget_test_utils_gtk.cc
index dbb1529..cd84b56 100644
--- a/views/widget/native_widget_test_utils_gtk.cc
+++ b/views/widget/native_widget_test_utils_gtk.cc
@@ -5,33 +5,33 @@
#include "views/widget/native_widget_test_utils.h"
#include "views/view.h"
-#include "views/widget/native_widget_private.h"
+#include "views/widget/native_widget.h"
#include "views/widget/widget.h"
namespace views {
namespace internal {
-NativeWidgetPrivate* CreateNativeWidget() {
+NativeWidget* CreateNativeWidget() {
return CreateNativeWidgetWithContents(new View);
}
-NativeWidgetPrivate* CreateNativeWidgetWithContents(View* contents_view) {
+NativeWidget* CreateNativeWidgetWithContents(View* contents_view) {
Widget* widget = new Widget;
Widget::InitParams params(Widget::InitParams::TYPE_POPUP);
params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
params.bounds = gfx::Rect(10, 10, 200, 200);
widget->Init(params);
- return widget->native_widget_private();
+ return widget->native_widget();
}
-NativeWidgetPrivate* CreateNativeWidgetWithParent(NativeWidgetPrivate* parent) {
+NativeWidget* CreateNativeWidgetWithParent(NativeWidget* parent) {
Widget* widget = new Widget;
Widget::InitParams params(Widget::InitParams::TYPE_CONTROL);
params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
params.parent = parent ? parent->GetWidget()->GetNativeView() : NULL;
params.bounds = gfx::Rect(10, 10, 200, 200);
widget->Init(params);
- return widget->native_widget_private();
+ return widget->native_widget();
}
} // namespace internal
diff --git a/views/widget/native_widget_test_utils_win.cc b/views/widget/native_widget_test_utils_win.cc
index b6a4184..49cd063 100644
--- a/views/widget/native_widget_test_utils_win.cc
+++ b/views/widget/native_widget_test_utils_win.cc
@@ -5,26 +5,26 @@
#include "views/widget/native_widget_test_utils.h"
#include "views/view.h"
-#include "views/widget/native_widget_private.h"
+#include "views/widget/native_widget.h"
#include "views/widget/widget.h"
namespace views {
namespace internal {
-NativeWidgetPrivate* CreateNativeWidget() {
+NativeWidget* CreateNativeWidget() {
return CreateNativeWidgetWithContents(new View);
}
-NativeWidgetPrivate* CreateNativeWidgetWithContents(View* contents_view) {
+NativeWidget* CreateNativeWidgetWithContents(View* contents_view) {
Widget* widget = new Widget;
Widget::InitParams params(Widget::InitParams::TYPE_POPUP);
params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
params.bounds = gfx::Rect(10, 10, 200, 200);
widget->Init(params);
- return widget->native_widget_private();
+ return widget->native_widget();
}
-NativeWidgetPrivate* CreateNativeWidgetWithParent(NativeWidgetPrivate* parent) {
+NativeWidget* CreateNativeWidgetWithParent(NativeWidget* parent) {
Widget* widget = new Widget;
Widget::InitParams params(Widget::InitParams::TYPE_CONTROL);
params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
@@ -32,7 +32,7 @@ NativeWidgetPrivate* CreateNativeWidgetWithParent(NativeWidgetPrivate* parent) {
params.parent = parent ? parent->GetWidget()->GetNativeView() : NULL;
params.bounds = gfx::Rect(10, 10, 200, 200);
widget->Init(params);
- return widget->native_widget_private();
+ return widget->native_widget();
}
} // namespace internal
diff --git a/views/widget/native_widget_unittest.cc b/views/widget/native_widget_unittest.cc
index 158f7c6..7370840 100644
--- a/views/widget/native_widget_unittest.cc
+++ b/views/widget/native_widget_unittest.cc
@@ -6,7 +6,7 @@
#include "views/test/views_test_base.h"
#include "views/view.h"
#include "views/controls/native/native_view_host.h"
-#include "views/widget/native_widget_private.h"
+#include "views/widget/native_widget.h"
#include "views/widget/widget.h"
#include "views/widget/native_widget_test_utils.h"
@@ -14,20 +14,20 @@ namespace views {
class ScopedTestWidget {
public:
- ScopedTestWidget(internal::NativeWidgetPrivate* native_widget)
+ ScopedTestWidget(NativeWidget* native_widget)
: native_widget_(native_widget) {
}
~ScopedTestWidget() {
native_widget_->GetWidget()->CloseNow();
}
- internal::NativeWidgetPrivate* operator->() const {
+ NativeWidget* operator->() const {
return native_widget_.get();
}
- internal::NativeWidgetPrivate* get() const { return native_widget_.get(); }
+ NativeWidget* get() const { return native_widget_.get(); }
private:
- scoped_ptr<internal::NativeWidgetPrivate> native_widget_;
+ scoped_ptr<NativeWidget> native_widget_;
DISALLOW_COPY_AND_ASSIGN(ScopedTestWidget);
};
@@ -48,7 +48,7 @@ TEST_F(NativeWidgetTest, CreateNativeWidget) {
TEST_F(NativeWidgetTest, GetNativeWidgetForNativeView) {
ScopedTestWidget widget(internal::CreateNativeWidget());
EXPECT_EQ(widget.get(),
- internal::NativeWidgetPrivate::GetNativeWidgetForNativeView(
+ NativeWidget::GetNativeWidgetForNativeView(
widget->GetWidget()->GetNativeView()));
}
@@ -56,7 +56,7 @@ TEST_F(NativeWidgetTest, GetNativeWidgetForNativeView) {
TEST_F(NativeWidgetTest, GetTopLevelNativeWidget1) {
ScopedTestWidget widget(internal::CreateNativeWidget());
EXPECT_EQ(widget.get(),
- internal::NativeWidgetPrivate::GetTopLevelNativeWidget(
+ NativeWidget::GetTopLevelNativeWidget(
widget->GetWidget()->GetNativeView()));
}
@@ -70,7 +70,7 @@ TEST_F(NativeWidgetTest, GetTopLevelNativeWidget2) {
child_host->Attach(child_widget->GetWidget()->GetNativeView());
EXPECT_EQ(toplevel_widget.get(),
- internal::NativeWidgetPrivate::GetTopLevelNativeWidget(
+ NativeWidget::GetTopLevelNativeWidget(
child_widget->GetWidget()->GetNativeView()));
}
diff --git a/views/widget/native_widget_views.cc b/views/widget/native_widget_views.cc
index 438b755..3f400c4 100644
--- a/views/widget/native_widget_views.cc
+++ b/views/widget/native_widget_views.cc
@@ -319,15 +319,12 @@ void NativeWidgetViews::SetCursor(gfx::NativeCursor cursor) {
////////////////////////////////////////////////////////////////////////////////
// NativeWidgetViews, private:
-internal::NativeWidgetPrivate* NativeWidgetViews::GetParentNativeWidget() {
- return static_cast<internal::NativeWidgetPrivate*>(
- view_->GetWidget()->native_widget());
+NativeWidget* NativeWidgetViews::GetParentNativeWidget() {
+ return view_->GetWidget()->native_widget();
}
-const internal::NativeWidgetPrivate*
- NativeWidgetViews::GetParentNativeWidget() const {
- return static_cast<const internal::NativeWidgetPrivate*>(
- view_->GetWidget()->native_widget());
+const NativeWidget* NativeWidgetViews::GetParentNativeWidget() const {
+ return view_->GetWidget()->native_widget();
}
} // namespace views
diff --git a/views/widget/native_widget_views.h b/views/widget/native_widget_views.h
index db6e097..1b0a47f 100644
--- a/views/widget/native_widget_views.h
+++ b/views/widget/native_widget_views.h
@@ -7,7 +7,7 @@
#pragma once
#include "base/message_loop.h"
-#include "views/widget/native_widget_private.h"
+#include "views/widget/native_widget.h"
namespace views {
namespace internal {
@@ -19,7 +19,7 @@ class NativeWidgetView;
//
// A NativeWidget implementation that uses another View as its native widget.
//
-class NativeWidgetViews : public internal::NativeWidgetPrivate {
+class NativeWidgetViews : public NativeWidget {
public:
NativeWidgetViews(View* host, internal::NativeWidgetDelegate* delegate);
virtual ~NativeWidgetViews();
@@ -33,7 +33,7 @@ class NativeWidgetViews : public internal::NativeWidgetPrivate {
internal::NativeWidgetDelegate* delegate() { return delegate_; }
protected:
- // Overridden from internal::NativeWidgetPrivate:
+ // Overridden from NativeWidget:
virtual void InitNativeWidget(const Widget::InitParams& params) OVERRIDE;
virtual NonClientFrameView* CreateNonClientFrameView() OVERRIDE;
virtual void UpdateFrameAfterFrameChange() OVERRIDE;
@@ -106,8 +106,8 @@ class NativeWidgetViews : public internal::NativeWidgetPrivate {
virtual void SetCursor(gfx::NativeCursor cursor) OVERRIDE;
private:
- internal::NativeWidgetPrivate* GetParentNativeWidget();
- const internal::NativeWidgetPrivate* GetParentNativeWidget() const;
+ NativeWidget* GetParentNativeWidget();
+ const NativeWidget* GetParentNativeWidget() const;
internal::NativeWidgetDelegate* delegate_;
diff --git a/views/widget/native_widget_win.cc b/views/widget/native_widget_win.cc
index cb1482d..dce389b 100644
--- a/views/widget/native_widget_win.cc
+++ b/views/widget/native_widget_win.cc
@@ -143,13 +143,15 @@ bool ProcessChildWindowMessage(UINT message,
return false;
}
-// Enumeration callback for NativeWidget::GetAllChildWidgets(). Called for each
+// Enumeration callback for NativeWidget::GetAllNativeWidgets(). Called for each
// child HWND beneath the original HWND.
BOOL CALLBACK EnumerateChildWindowsForNativeWidgets(HWND hwnd, LPARAM l_param) {
- Widget* widget = Widget::GetWidgetForNativeView(hwnd);
- if (widget) {
- Widget::Widgets* widgets = reinterpret_cast<Widget::Widgets*>(l_param);
- widgets->insert(widget);
+ NativeWidget* native_widget =
+ NativeWidget::GetNativeWidgetForNativeView(hwnd);
+ if (native_widget) {
+ NativeWidget::NativeWidgets* native_widgets =
+ reinterpret_cast<NativeWidget::NativeWidgets*>(l_param);
+ native_widgets->insert(native_widget);
}
return TRUE;
}
@@ -2374,9 +2376,13 @@ void Widget::NotifyLocaleChanged() {
namespace {
BOOL CALLBACK WindowCallbackProc(HWND hwnd, LPARAM lParam) {
- Widget* widget = Widget::GetWidgetForNativeView(hwnd);
- if (widget && widget->is_secondary_widget())
- widget->Close();
+ NativeWidget* native_widget =
+ NativeWidget::GetNativeWidgetForNativeView(hwnd);
+ if (native_widget) {
+ Widget* widget = native_widget->GetWidget();
+ if (widget->is_secondary_widget())
+ widget->Close();
+ }
return TRUE;
}
} // namespace
@@ -2408,32 +2414,30 @@ bool Widget::ConvertRect(const Widget* source,
return false;
}
-namespace internal {
-
////////////////////////////////////////////////////////////////////////////////
-// internal::NativeWidgetPrivate, public:
+// NativeWidget, public:
// static
-NativeWidgetPrivate* NativeWidgetPrivate::CreateNativeWidget(
+NativeWidget* NativeWidget::CreateNativeWidget(
internal::NativeWidgetDelegate* delegate) {
return new NativeWidgetWin(delegate);
}
// static
-NativeWidgetPrivate* NativeWidgetPrivate::GetNativeWidgetForNativeView(
+NativeWidget* NativeWidget::GetNativeWidgetForNativeView(
gfx::NativeView native_view) {
return reinterpret_cast<NativeWidgetWin*>(
ViewProp::GetValue(native_view, kNativeWidgetKey));
}
// static
-NativeWidgetPrivate* NativeWidgetPrivate::GetNativeWidgetForNativeWindow(
+NativeWidget* NativeWidget::GetNativeWidgetForNativeWindow(
gfx::NativeWindow native_window) {
return GetNativeWidgetForNativeView(native_window);
}
// static
-NativeWidgetPrivate* NativeWidgetPrivate::GetTopLevelNativeWidget(
+NativeWidget* NativeWidget::GetTopLevelNativeWidget(
gfx::NativeView native_view) {
if (!native_view)
return NULL;
@@ -2443,13 +2447,13 @@ NativeWidgetPrivate* NativeWidgetPrivate::GetTopLevelNativeWidget(
if (!root)
return NULL;
- NativeWidgetPrivate* widget = GetNativeWidgetForNativeView(root);
+ NativeWidget* widget = GetNativeWidgetForNativeView(root);
if (widget)
return widget;
// Second, try to locate the last Widget window in the parent hierarchy.
HWND parent_hwnd = native_view;
- NativeWidgetPrivate* parent_widget;
+ NativeWidget* parent_widget;
do {
parent_widget = GetNativeWidgetForNativeView(parent_hwnd);
if (parent_widget) {
@@ -2462,21 +2466,21 @@ NativeWidgetPrivate* NativeWidgetPrivate::GetTopLevelNativeWidget(
}
// static
-void NativeWidgetPrivate::GetAllChildWidgets(gfx::NativeView native_view,
- Widget::Widgets* children) {
+void NativeWidget::GetAllNativeWidgets(gfx::NativeView native_view,
+ NativeWidgets* children) {
if (!native_view)
return;
- Widget* widget = Widget::GetWidgetForNativeView(native_view);
- if (widget)
- children->insert(widget);
+ NativeWidget* native_widget = GetNativeWidgetForNativeView(native_view);
+ if (native_widget)
+ children->insert(native_widget);
EnumChildWindows(native_view, EnumerateChildWindowsForNativeWidgets,
- reinterpret_cast<LPARAM>(children));
+ reinterpret_cast<LPARAM>(children));
}
// static
-void NativeWidgetPrivate::ReparentNativeView(gfx::NativeView native_view,
- gfx::NativeView new_parent) {
+void NativeWidget::ReparentNativeView(gfx::NativeView native_view,
+ gfx::NativeView new_parent) {
if (!native_view)
return;
@@ -2484,26 +2488,27 @@ void NativeWidgetPrivate::ReparentNativeView(gfx::NativeView native_view,
if (previous_parent == new_parent)
return;
- Widget::Widgets widgets;
- GetAllChildWidgets(native_view, &widgets);
+ NativeWidgets widgets;
+ GetAllNativeWidgets(native_view, &widgets);
// First notify all the widgets that they are being disassociated
// from their previous parent.
- for (Widget::Widgets::iterator it = widgets.begin();
+ for (NativeWidgets::iterator it = widgets.begin();
it != widgets.end(); ++it) {
// TODO(beng): Rename this notification to NotifyNativeViewChanging()
// and eliminate the bool parameter.
- (*it)->NotifyNativeViewHierarchyChanged(false, previous_parent);
+ (*it)->GetWidget()->NotifyNativeViewHierarchyChanged(false,
+ previous_parent);
}
::SetParent(native_view, new_parent);
// And now, notify them that they have a brand new parent.
- for (Widget::Widgets::iterator it = widgets.begin();
+ for (NativeWidgets::iterator it = widgets.begin();
it != widgets.end(); ++it) {
- (*it)->NotifyNativeViewHierarchyChanged(true, new_parent);
+ (*it)->GetWidget()->NotifyNativeViewHierarchyChanged(true,
+ new_parent);
}
}
-} // namespace internal
} // namespace views
diff --git a/views/widget/native_widget_win.h b/views/widget/native_widget_win.h
index dadbc38..5162988 100644
--- a/views/widget/native_widget_win.h
+++ b/views/widget/native_widget_win.h
@@ -22,7 +22,7 @@
#include "views/focus/focus_manager.h"
#include "views/ime/input_method_delegate.h"
#include "views/layout/layout_manager.h"
-#include "views/widget/native_widget_private.h"
+#include "views/widget/native_widget.h"
namespace ui {
class ViewProp;
@@ -84,7 +84,7 @@ const int WM_NCUAHDRAWFRAME = 0xAF;
//
///////////////////////////////////////////////////////////////////////////////
class NativeWidgetWin : public ui::WindowImpl,
- public internal::NativeWidgetPrivate,
+ public NativeWidget,
public MessageLoopForUI::Observer,
public internal::InputMethodDelegate {
public:
@@ -187,7 +187,7 @@ class NativeWidgetWin : public ui::WindowImpl,
return ::GetClientRect(GetNativeView(), rect);
}
- // Overridden from internal::NativeWidgetPrivate:
+ // Overridden from NativeWidget:
virtual void InitNativeWidget(const Widget::InitParams& params) OVERRIDE;
virtual NonClientFrameView* CreateNonClientFrameView() OVERRIDE;
virtual void UpdateFrameAfterFrameChange() OVERRIDE;
diff --git a/views/widget/widget.cc b/views/widget/widget.cc
index 8b19ce2..5000156 100644
--- a/views/widget/widget.cc
+++ b/views/widget/widget.cc
@@ -15,7 +15,7 @@
#include "views/views_delegate.h"
#include "views/widget/default_theme_provider.h"
#include "views/widget/root_view.h"
-#include "views/widget/native_widget_private.h"
+#include "views/widget/native_widget.h"
#include "views/widget/widget_delegate.h"
#include "views/window/custom_frame_view.h"
@@ -192,40 +192,12 @@ bool Widget::IsPureViews() {
// static
Widget* Widget::GetWidgetForNativeView(gfx::NativeView native_view) {
- internal::NativeWidgetPrivate* native_widget =
- internal::NativeWidgetPrivate::GetNativeWidgetForNativeView(native_view);
+ NativeWidget* native_widget =
+ NativeWidget::GetNativeWidgetForNativeView(native_view);
return native_widget ? native_widget->GetWidget() : NULL;
}
// static
-Widget* Widget::GetWidgetForNativeWindow(gfx::NativeWindow native_window) {
- internal::NativeWidgetPrivate* native_widget =
- internal::NativeWidgetPrivate::GetNativeWidgetForNativeWindow(
- native_window);
- return native_widget ? native_widget->GetWidget() : NULL;
-}
-
-// static
-Widget* Widget::GetTopLevelWidgetForNativeView(gfx::NativeView native_view) {
- internal::NativeWidgetPrivate* native_widget =
- internal::NativeWidgetPrivate::GetTopLevelNativeWidget(native_view);
- return native_widget ? native_widget->GetWidget() : NULL;
-}
-
-
-// static
-void Widget::GetAllChildWidgets(gfx::NativeView native_view,
- Widgets* children) {
- internal::NativeWidgetPrivate::GetAllChildWidgets(native_view, children);
-}
-
-// static
-void Widget::ReparentNativeView(gfx::NativeView native_view,
- gfx::NativeView new_parent) {
- internal::NativeWidgetPrivate::ReparentNativeView(native_view, new_parent);
-}
-
-// static
int Widget::GetLocalizedContentsWidth(int col_resource_id) {
return ui::GetLocalizedContentsWidthForFont(col_resource_id,
ResourceBundle::GetSharedInstance().GetFont(ResourceBundle::BaseFont));
@@ -248,9 +220,9 @@ void Widget::Init(const InitParams& params) {
widget_delegate_ =
params.delegate ? params.delegate : new DefaultWidgetDelegate;
ownership_ = params.ownership;
- native_widget_ = params.native_widget ?
- params.native_widget->AsNativeWidgetPrivate() :
- internal::NativeWidgetPrivate::CreateNativeWidget(this);
+ native_widget_ =
+ params.native_widget ? params.native_widget
+ : NativeWidget::CreateNativeWidget(this);
GetRootView();
default_theme_provider_.reset(new DefaultThemeProvider);
if (params.type == InitParams::TYPE_MENU)
@@ -315,8 +287,8 @@ Widget* Widget::GetTopLevelWidget() {
}
const Widget* Widget::GetTopLevelWidget() const {
- internal::NativeWidgetPrivate* native_widget =
- internal::NativeWidgetPrivate::GetTopLevelNativeWidget(GetNativeView());
+ NativeWidget* native_widget =
+ NativeWidget::GetTopLevelNativeWidget(GetNativeView());
return native_widget ? native_widget->GetWidget() : NULL;
}
@@ -391,8 +363,8 @@ void Widget::EnableClose(bool enable) {
void Widget::Show() {
if (non_client_view_) {
native_widget_->ShowNativeWidget(
- saved_maximized_state_ ? internal::NativeWidgetPrivate::SHOW_MAXIMIZED
- : internal::NativeWidgetPrivate::SHOW_RESTORED);
+ saved_maximized_state_ ? NativeWidget::SHOW_MAXIMIZED
+ : NativeWidget::SHOW_RESTORED);
// |saved_maximized_state_| only applies the first time the window is shown.
// If we don't reset the value the window will be shown maximized every time
// it is subsequently shown after being hidden.
@@ -407,8 +379,7 @@ void Widget::Hide() {
}
void Widget::ShowInactive() {
- native_widget_->ShowNativeWidget(
- internal::NativeWidgetPrivate::SHOW_INACTIVE);
+ native_widget_->ShowNativeWidget(NativeWidget::SHOW_INACTIVE);
}
void Widget::Activate() {
@@ -511,7 +482,7 @@ FocusManager* Widget::GetFocusManager() {
InputMethod* Widget::GetInputMethod() {
Widget* toplevel_widget = GetTopLevelWidget();
return toplevel_widget ?
- toplevel_widget->native_widget_->GetInputMethodNative() : NULL;
+ toplevel_widget->native_widget()->GetInputMethodNative() : NULL;
}
bool Widget::ContainsNativeView(gfx::NativeView native_view) {
@@ -548,14 +519,6 @@ void Widget::ResetLastMouseMoveFlag() {
last_mouse_event_was_move_ = false;
}
-void Widget::SetNativeWindowProperty(const char* name, void* value) {
- native_widget_->SetNativeWindowProperty(name, value);
-}
-
-void* Widget::GetNativeWindowProperty(const char* name) const {
- return native_widget_->GetNativeWindowProperty(name);
-}
-
void Widget::UpdateWindowTitle() {
if (!non_client_view_)
return;
@@ -646,14 +609,6 @@ void Widget::NotifyAccessibilityEvent(
native_widget_->SendNativeAccessibilityEvent(view, event_type);
}
-const NativeWidget* Widget::native_widget() const {
- return native_widget_;
-}
-
-NativeWidget* Widget::native_widget() {
- return native_widget_;
-}
-
const Event* Widget::GetCurrentEvent() {
return event_stack_.empty() ? NULL : event_stack_.top()->event();
}
@@ -976,14 +931,5 @@ void Widget::SetInitialBounds(const gfx::Rect& bounds) {
}
}
-namespace internal {
-
-////////////////////////////////////////////////////////////////////////////////
-// internal::NativeWidgetPrivate, NativeWidget implementation:
-
-internal::NativeWidgetPrivate* NativeWidgetPrivate::AsNativeWidgetPrivate() {
- return this;
-}
-} // namespace internal
} // namespace views
diff --git a/views/widget/widget.h b/views/widget/widget.h
index 1e1b6f8..4220cc6 100644
--- a/views/widget/widget.h
+++ b/views/widget/widget.h
@@ -60,7 +60,6 @@ class TooltipManager;
class View;
class WidgetDelegate;
namespace internal {
-class NativeWidgetPrivate;
class RootView;
}
@@ -92,8 +91,6 @@ class RootView;
class Widget : public internal::NativeWidgetDelegate,
public FocusTraversable {
public:
- typedef std::set<Widget*> Widgets;
-
enum FrameType {
FRAME_TYPE_DEFAULT, // Use whatever the default would be.
FRAME_TYPE_FORCE_CUSTOM, // Force the custom frame.
@@ -183,25 +180,9 @@ class Widget : public internal::NativeWidgetDelegate,
static void SetPureViews(bool pure);
static bool IsPureViews();
- // Retrieves the Widget implementation associated with the given
- // NativeView or Window, or NULL if the supplied handle has no associated
- // Widget.
+ // Passes through to NativeWidget::GetWidgetForNativeView().
static Widget* GetWidgetForNativeView(gfx::NativeView native_view);
- static Widget* GetWidgetForNativeWindow(gfx::NativeWindow native_window);
-
- // Retrieves the highest Widget in a native view hierarchy starting at
- // |native_view|, which may or may not be a Widget itself.
- static Widget* GetTopLevelWidgetForNativeView(gfx::NativeView native_view);
-
- // Returns all Widgets in |native_view|'s hierarchy, including itself if
- // it is one.
- static void GetAllChildWidgets(gfx::NativeView native_view,
- Widgets* children);
- // Re-parent a NativeView and notify all Widgets in |native_view|'s hierarchy
- // of the change.
- static void ReparentNativeView(gfx::NativeView native_view,
- gfx::NativeView new_parent);
// Returns the preferred size of the contents view of this window based on
// its localized size data. The width in cols is held in a localized string
@@ -409,12 +390,6 @@ class Widget : public internal::NativeWidgetDelegate,
// to cause the close button to highlight.
void ResetLastMouseMoveFlag();
- // Sets/Gets a native window property on the underlying native window object.
- // Returns NULL if the property does not exist. Setting the property value to
- // NULL removes the property.
- void SetNativeWindowProperty(const char* name, void* value);
- void* GetNativeWindowProperty(const char* name) const;
-
// Tell the window to update its title from the delegate.
void UpdateWindowTitle();
@@ -487,15 +462,8 @@ class Widget : public internal::NativeWidgetDelegate,
ui::AccessibilityTypes::Event event_type,
bool send_native_event);
- const NativeWidget* native_widget() const;
- NativeWidget* native_widget();
-
- internal::NativeWidgetPrivate* native_widget_private() {
- return native_widget_;
- }
- const internal::NativeWidgetPrivate* native_widget_private() const {
- return native_widget_;
- }
+ const NativeWidget* native_widget() const { return native_widget_; }
+ NativeWidget* native_widget() { return native_widget_; }
// Returns the current event being processed. If there are multiple events
// being processed at the same time (e.g. one event triggers another event),
@@ -585,7 +553,7 @@ class Widget : public internal::NativeWidgetDelegate,
// Sizes and positions the window just after it is created.
void SetInitialBounds(const gfx::Rect& bounds);
- internal::NativeWidgetPrivate* native_widget_;
+ NativeWidget* native_widget_;
// Non-owned pointer to the Widget's delegate. May be NULL if no delegate is
// being used.