diff options
author | ben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-06-16 22:10:46 +0000 |
---|---|---|
committer | ben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-06-16 22:10:46 +0000 |
commit | 080440cebdc80def86dd88356e5922946cc11a79 (patch) | |
tree | 6da09cd9a2b69e79075f0d391179d0757ac04620 /views | |
parent | bc9b2f4215e0ee88e0faaa42a1f116231ce2a311 (diff) | |
download | chromium_src-080440cebdc80def86dd88356e5922946cc11a79.zip chromium_src-080440cebdc80def86dd88356e5922946cc11a79.tar.gz chromium_src-080440cebdc80def86dd88356e5922946cc11a79.tar.bz2 |
Fix even more crashes. To help identify remaining crashes now and in the future, I have made the GetWidget methods on WidgetDelegate pure virtual. This will cause classes that don't define them to fail compile instead of crashing at run time.
http://crbug.com/86119
TEST=none
Review URL: http://codereview.chromium.org/7189019
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@89409 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'views')
-rw-r--r-- | views/controls/tabbed_pane/tabbed_pane_unittest.cc | 12 | ||||
-rw-r--r-- | views/controls/table/table_view_unittest.cc | 20 | ||||
-rw-r--r-- | views/desktop/desktop_window.cc | 3 | ||||
-rw-r--r-- | views/desktop/desktop_window.h | 3 | ||||
-rw-r--r-- | views/focus/focus_manager_unittest.cc | 12 | ||||
-rw-r--r-- | views/view_unittest.cc | 3 | ||||
-rw-r--r-- | views/widget/widget.cc | 12 | ||||
-rw-r--r-- | views/widget/widget_delegate.cc | 8 | ||||
-rw-r--r-- | views/widget/widget_delegate.h | 4 |
9 files changed, 51 insertions, 26 deletions
diff --git a/views/controls/tabbed_pane/tabbed_pane_unittest.cc b/views/controls/tabbed_pane/tabbed_pane_unittest.cc index 12f82a5..958ac6b 100644 --- a/views/controls/tabbed_pane/tabbed_pane_unittest.cc +++ b/views/controls/tabbed_pane/tabbed_pane_unittest.cc @@ -38,20 +38,26 @@ class TabbedPaneTest : public testing::Test, } private: - virtual void SetUp() { + virtual void SetUp() OVERRIDE { tabbed_pane_ = new TabbedPane(); window_ = Widget::CreateWindowWithBounds(this, gfx::Rect(0, 0, 100, 100)); window_->Show(); } - virtual void TearDown() { + virtual void TearDown() OVERRIDE { window_->Close(); message_loop_.RunAllPending(); } - virtual views::View* GetContentsView() { + virtual views::View* GetContentsView() OVERRIDE { return tabbed_pane_; } + virtual views::Widget* GetWidget() OVERRIDE { + return tabbed_pane_->GetWidget(); + } + virtual const views::Widget* GetWidget() const OVERRIDE { + return tabbed_pane_->GetWidget(); + } MessageLoopForUI message_loop_; Widget* window_; diff --git a/views/controls/table/table_view_unittest.cc b/views/controls/table/table_view_unittest.cc index ee6734b..ce911f3 100644 --- a/views/controls/table/table_view_unittest.cc +++ b/views/controls/table/table_view_unittest.cc @@ -141,12 +141,18 @@ int TestTableModel::CompareValues(int row1, int row2, int column_id) { class TableViewTest : public testing::Test, views::WidgetDelegate { public: - virtual void SetUp(); - virtual void TearDown(); + virtual void SetUp() OVERRIDE; + virtual void TearDown() OVERRIDE; - virtual views::View* GetContentsView() { + virtual views::View* GetContentsView() OVERRIDE { return table_; } + virtual views::Widget* GetWidget() OVERRIDE { + return table_->GetWidget(); + } + virtual const views::Widget* GetWidget() const OVERRIDE { + return table_->GetWidget(); + } protected: // Creates the model. @@ -471,9 +477,15 @@ class TableView2Test : public testing::Test, views::WidgetDelegate { virtual void SetUp(); virtual void TearDown(); - virtual views::View* GetContentsView() { + virtual views::View* GetContentsView() OVERRIDE { return table_; } + virtual views::Widget* GetWidget() OVERRIDE { + return table_->GetWidget(); + } + virtual const views::Widget* GetWidget() const OVERRIDE { + return table_->GetWidget(); + } // Returns the contents of a cell in the table. std::wstring GetCellValue(int row, int column); diff --git a/views/desktop/desktop_window.cc b/views/desktop/desktop_window.cc index 7260826..773d34c 100644 --- a/views/desktop/desktop_window.cc +++ b/views/desktop/desktop_window.cc @@ -39,8 +39,7 @@ class DesktopWindowWindow : public Widget { DISALLOW_COPY_AND_ASSIGN(DesktopWindowWindow); }; -class TestWindowContentView : public View, - public WidgetDelegate { +class TestWindowContentView : public WidgetDelegateView { public: TestWindowContentView(const std::wstring& title, SkColor color) : title_(title), diff --git a/views/desktop/desktop_window.h b/views/desktop/desktop_window.h index 453030c..eb49f44 100644 --- a/views/desktop/desktop_window.h +++ b/views/desktop/desktop_window.h @@ -13,8 +13,7 @@ class NativeWidgetViews; namespace desktop { -class DesktopWindow : public View, - public WidgetDelegate { +class DesktopWindow : public WidgetDelegateView { public: DesktopWindow(); virtual ~DesktopWindow(); diff --git a/views/focus/focus_manager_unittest.cc b/views/focus/focus_manager_unittest.cc index 7ea323e..e5d7c0b 100644 --- a/views/focus/focus_manager_unittest.cc +++ b/views/focus/focus_manager_unittest.cc @@ -116,13 +116,13 @@ class FocusManagerTest : public testing::Test, public WidgetDelegate { #endif } - virtual void SetUp() { + virtual void SetUp() OVERRIDE { window_ = Widget::CreateWindowWithBounds(this, bounds()); InitContentView(); window_->Show(); } - virtual void TearDown() { + virtual void TearDown() OVERRIDE { if (focus_change_listener_) GetFocusManager()->RemoveFocusChangeListener(focus_change_listener_); window_->Close(); @@ -152,11 +152,17 @@ class FocusManagerTest : public testing::Test, public WidgetDelegate { } // WidgetDelegate Implementation. - virtual View* GetContentsView() { + virtual View* GetContentsView() OVERRIDE { if (!content_view_) content_view_ = new View(); return content_view_; } + virtual Widget* GetWidget() OVERRIDE { + return content_view_->GetWidget(); + } + virtual const Widget* GetWidget() const OVERRIDE { + return content_view_->GetWidget(); + } virtual void InitContentView() { } diff --git a/views/view_unittest.cc b/views/view_unittest.cc index a3a0671..857a6e4 100644 --- a/views/view_unittest.cc +++ b/views/view_unittest.cc @@ -1083,6 +1083,9 @@ class SimpleWidgetDelegate : public WidgetDelegate { virtual View* GetContentsView() { return contents_; } + virtual Widget* GetWidget() { return contents_->GetWidget(); } + virtual const Widget* GetWidget() const { return contents_->GetWidget(); } + private: View* contents_; }; diff --git a/views/widget/widget.cc b/views/widget/widget.cc index 292b081..85aabe4 100644 --- a/views/widget/widget.cc +++ b/views/widget/widget.cc @@ -60,15 +60,23 @@ class ScopedEvent { // WidgetDelegate is supplied. class DefaultWidgetDelegate : public WidgetDelegate { public: - DefaultWidgetDelegate() {} + explicit DefaultWidgetDelegate(Widget* widget) : widget_(widget) {} virtual ~DefaultWidgetDelegate() {} // Overridden from WidgetDelegate: virtual void DeleteDelegate() OVERRIDE { delete this; } + virtual Widget* GetWidget() { + return widget_; + } + virtual const Widget* GetWidget() const { + return widget_; + } private: + Widget* widget_; + DISALLOW_COPY_AND_ASSIGN(DefaultWidgetDelegate); }; @@ -246,7 +254,7 @@ gfx::Size Widget::GetLocalizedContentsSize(int col_resource_id, void Widget::Init(const InitParams& params) { widget_delegate_ = - params.delegate ? params.delegate : new DefaultWidgetDelegate; + params.delegate ? params.delegate : new DefaultWidgetDelegate(this); ownership_ = params.ownership; native_widget_ = params.native_widget ? params.native_widget->AsNativeWidgetPrivate() : diff --git a/views/widget/widget_delegate.cc b/views/widget/widget_delegate.cc index aecf12f..f2f16b7 100644 --- a/views/widget/widget_delegate.cc +++ b/views/widget/widget_delegate.cc @@ -132,14 +132,6 @@ bool WidgetDelegate::ShouldRestoreWindowSize() const { return true; } -Widget* WidgetDelegate::GetWidget() { - return NULL; -} - -const Widget* WidgetDelegate::GetWidget() const { - return NULL; -} - View* WidgetDelegate::GetContentsView() { if (!default_contents_view_) default_contents_view_ = new View; diff --git a/views/widget/widget_delegate.h b/views/widget/widget_delegate.h index 8c9e069..6a6b254 100644 --- a/views/widget/widget_delegate.h +++ b/views/widget/widget_delegate.h @@ -135,8 +135,8 @@ class WidgetDelegate { virtual void OnWindowEndUserBoundsChange() {} // Returns the Widget associated with this delegate. - virtual Widget* GetWidget(); - virtual const Widget* GetWidget() const; + virtual Widget* GetWidget() = 0; + virtual const Widget* GetWidget() const = 0; // Returns the View that is contained within this Widget. virtual View* GetContentsView(); |