summaryrefslogtreecommitdiffstats
path: root/views/widget
diff options
context:
space:
mode:
authorsadrul@chromium.org <sadrul@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-07-26 17:11:58 +0000
committersadrul@chromium.org <sadrul@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-07-26 17:11:58 +0000
commit3f83296afd3738210d0b2010d504014677bd69d3 (patch)
tree69a15a6ca65d3fdbce87687649e22f227d754002 /views/widget
parent41f054c72c8261a45c743ad72b3d010575f3d08f (diff)
downloadchromium_src-3f83296afd3738210d0b2010d504014677bd69d3.zip
chromium_src-3f83296afd3738210d0b2010d504014677bd69d3.tar.gz
chromium_src-3f83296afd3738210d0b2010d504014677bd69d3.tar.bz2
NativeWidgetViews: Add support for window properties.
Also, check view_ for NULL in a few places because these functions can be called when the NWViews is in the process of closing and view_ may have already been unset. This fixes a crash when closing chrome in --views-desktop world. BUG=none TEST=start chrome with --views-dekstop and close, chrome shouldn't crash. Review URL: http://codereview.chromium.org/7480017 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@94112 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'views/widget')
-rw-r--r--views/widget/native_widget_views.cc26
-rw-r--r--views/widget/native_widget_views.h4
2 files changed, 22 insertions, 8 deletions
diff --git a/views/widget/native_widget_views.cc b/views/widget/native_widget_views.cc
index b1568e3..8c17c57 100644
--- a/views/widget/native_widget_views.cc
+++ b/views/widget/native_widget_views.cc
@@ -37,9 +37,11 @@ NativeWidgetViews::~NativeWidgetViews() {
delegate_->OnNativeWidgetDestroying();
// We must prevent the NativeWidgetView from attempting to delete us.
- view_->set_delete_native_widget(false);
- if (delete_native_view_)
- delete view_;
+ if (view_) {
+ view_->set_delete_native_widget(false);
+ if (delete_native_view_)
+ delete view_;
+ }
delegate_->OnNativeWidgetDestroyed();
if (ownership_ == Widget::InitParams::NATIVE_WIDGET_OWNS_WIDGET)
@@ -147,6 +149,10 @@ gfx::NativeWindow NativeWidgetViews::GetNativeWindow() const {
}
Widget* NativeWidgetViews::GetTopLevelWidget() {
+ // This can get called when this is in the process of being destroyed, and
+ // view_ has already been unset.
+ if (!view_)
+ return GetWidget();
if (view_->parent() == ViewsDelegate::views_delegate->GetDefaultParentView())
return GetWidget();
// During Widget destruction, this function may be called after |view_| is
@@ -181,12 +187,16 @@ void NativeWidgetViews::ViewRemoved(View* view) {
}
void NativeWidgetViews::SetNativeWindowProperty(const char* name, void* value) {
- NOTIMPLEMENTED();
+ if (value)
+ window_properties_[name] = value;
+ else
+ window_properties_.erase(name);
}
void* NativeWidgetViews::GetNativeWindowProperty(const char* name) const {
- NOTIMPLEMENTED();
- return NULL;
+ std::map<const char*, void*>::const_iterator iter =
+ window_properties_.find(name);
+ return iter != window_properties_.end() ? iter->second : NULL;
}
TooltipManager* NativeWidgetViews::GetTooltipManager() const {
@@ -494,7 +504,7 @@ void NativeWidgetViews::FocusNativeView(gfx::NativeView native_view) {
// NativeWidgetViews, private:
internal::NativeWidgetPrivate* NativeWidgetViews::GetParentNativeWidget() {
- Widget* containing_widget = view_->GetWidget();
+ Widget* containing_widget = view_ ? view_->GetWidget() : NULL;
return containing_widget ? static_cast<internal::NativeWidgetPrivate*>(
containing_widget->native_widget()) :
NULL;
@@ -502,7 +512,7 @@ internal::NativeWidgetPrivate* NativeWidgetViews::GetParentNativeWidget() {
const internal::NativeWidgetPrivate*
NativeWidgetViews::GetParentNativeWidget() const {
- const Widget* containing_widget = view_->GetWidget();
+ const Widget* containing_widget = view_ ? view_->GetWidget() : NULL;
return containing_widget ? static_cast<const internal::NativeWidgetPrivate*>(
containing_widget->native_widget()) :
NULL;
diff --git a/views/widget/native_widget_views.h b/views/widget/native_widget_views.h
index 3139557..4ab9ced 100644
--- a/views/widget/native_widget_views.h
+++ b/views/widget/native_widget_views.h
@@ -6,6 +6,8 @@
#define VIEWS_WIDGET_NATIVE_WIDGET_VIEWS_H_
#pragma once
+#include <map>
+
#include "base/message_loop.h"
#include "ui/gfx/transform.h"
#include "views/ime/input_method_delegate.h"
@@ -157,6 +159,8 @@ class NativeWidgetViews : public internal::NativeWidgetPrivate,
scoped_ptr<InputMethod> input_method_;
+ std::map<const char*, void*> window_properties_;
+
DISALLOW_COPY_AND_ASSIGN(NativeWidgetViews);
};