Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(265)

Unified Diff: views/widget/native_widget_views.cc

Issue 7273084: Change the meaning of "Widget::GetTopLevelWidget()" to mean the logical top level Window in the v... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « views/widget/native_widget_views.h ('k') | views/widget/native_widget_win.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: views/widget/native_widget_views.cc
===================================================================
--- views/widget/native_widget_views.cc (revision 91561)
+++ views/widget/native_widget_views.cc (working copy)
@@ -5,6 +5,7 @@
#include "views/widget/native_widget_views.h"
#include "ui/gfx/compositor/compositor.h"
+#include "views/desktop/desktop_window_view.h"
#include "views/view.h"
#include "views/views_delegate.h"
#include "views/widget/native_widget_view.h"
@@ -21,10 +22,22 @@
active_(false),
minimized_(false),
ALLOW_THIS_IN_INITIALIZER_LIST(close_widget_factory_(this)),
- hosting_widget_(NULL) {
+ hosting_widget_(NULL),
+ ownership_(Widget::InitParams::NATIVE_WIDGET_OWNS_WIDGET),
+ delete_native_view_(true) {
}
NativeWidgetViews::~NativeWidgetViews() {
+ delegate_->OnNativeWidgetDestroying();
+ if (delete_native_view_) {
+ view_->parent()->RemoveChildView(view_);
+ // We must prevent the NativeWidgetView from attempting to delete us.
+ view_->set_delete_native_widget(false);
+ delete view_;
+ }
+ delegate_->OnNativeWidgetDestroyed();
+ if (ownership_ == Widget::InitParams::NATIVE_WIDGET_OWNS_WIDGET)
+ delete delegate_;
}
View* NativeWidgetViews::GetView() {
@@ -44,11 +57,16 @@
// NativeWidgetViews, NativeWidget implementation:
void NativeWidgetViews::InitNativeWidget(const Widget::InitParams& params) {
+ ownership_ = params.ownership;
View* desktop_view = ViewsDelegate::views_delegate->GetDefaultParentView();
hosting_widget_ = desktop_view->GetWidget();
view_ = new internal::NativeWidgetView(this);
view_->SetBoundsRect(params.bounds);
view_->SetPaintToLayer(true);
+ // TODO(beng): This is insufficient. While this handles the case where
+ // params.parent_widget is NULL, we need to somehow handle a case
+ // where we are passed a specified, valid parent. We may have to
+ // add View* Widget::GetContainerView().
desktop_view->AddChildView(view_);
// TODO(beng): handle parenting.
@@ -86,6 +104,12 @@
return GetParentNativeWidget()->GetNativeWindow();
}
+Widget* NativeWidgetViews::GetTopLevelWidget() {
+ if (view_->parent() == ViewsDelegate::views_delegate->GetDefaultParentView())
+ return GetWidget();
+ return view_->GetWidget()->GetTopLevelWidget();
+}
+
const ui::Compositor* NativeWidgetViews::GetCompositor() const {
return hosting_widget_->GetCompositor();
}
@@ -234,8 +258,9 @@
}
void NativeWidgetViews::CloseNow() {
- view_->parent()->RemoveChildView(view_);
- delete view_;
+ // TODO(beng): what about the other case??
+ if (ownership_ == Widget::InitParams::NATIVE_WIDGET_OWNS_WIDGET)
+ delete view_;
}
void NativeWidgetViews::EnableClose(bool enable) {
« no previous file with comments | « views/widget/native_widget_views.h ('k') | views/widget/native_widget_win.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698