diff options
author | pkotwicz <pkotwicz@chromium.org> | 2014-09-23 15:37:36 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2014-09-23 22:37:52 +0000 |
commit | 85b87978351f4449aba1aa68f459342600fafdfc (patch) | |
tree | 4cf72d6dd20b5f2f6652a0130d4bd2e1c748f5d9 | |
parent | 773fd62d4b1657ffc5a24f44c845ede94bc16e7d (diff) | |
download | chromium_src-85b87978351f4449aba1aa68f459342600fafdfc.zip chromium_src-85b87978351f4449aba1aa68f459342600fafdfc.tar.gz chromium_src-85b87978351f4449aba1aa68f459342600fafdfc.tar.bz2 |
Fix crash which occurs when combining tests which inherit from AthenaTestBase
and tests which inherit from AuraTestBase in the same target
BUG=None
TEST=None
Review URL: https://codereview.chromium.org/597543002
Cr-Commit-Position: refs/heads/master@{#296286}
-rw-r--r-- | athena/main/athena_launcher.cc | 4 | ||||
-rw-r--r-- | athena/main/athena_views_delegate.cc | 41 | ||||
-rw-r--r-- | athena/main/athena_views_delegate.h | 19 |
3 files changed, 38 insertions, 26 deletions
diff --git a/athena/main/athena_launcher.cc b/athena/main/athena_launcher.cc index d0cd9c1..ccf4de9c 100644 --- a/athena/main/athena_launcher.cc +++ b/athena/main/athena_launcher.cc @@ -100,7 +100,7 @@ void StartAthenaEnv(scoped_refptr<base::TaskRunner> blocking_task_runner) { ui::TouchFactory::SetTouchDeviceListFromCommandLine(); #endif - views::ViewsDelegate::views_delegate = new AthenaViewsDelegate(); + CreateAthenaViewsDelegate(); AthenaEnvState* env_state = new AthenaEnvState; @@ -165,7 +165,7 @@ void ShutdownAthena() { athena::ExtensionsDelegate::Shutdown(); athena::AthenaEnv::Shutdown(); - delete views::ViewsDelegate::views_delegate; + ShutdownAthenaViewsDelegate(); } } // namespace athena diff --git a/athena/main/athena_views_delegate.cc b/athena/main/athena_views_delegate.cc index 3f30cda..4db7ff9 100644 --- a/athena/main/athena_views_delegate.cc +++ b/athena/main/athena_views_delegate.cc @@ -6,18 +6,45 @@ #include "athena/main/athena_frame_view.h" #include "athena/screen/public/screen_manager.h" +#include "ui/views/views_delegate.h" namespace athena { -void AthenaViewsDelegate::OnBeforeWidgetInit( - views::Widget::InitParams* params, - views::internal::NativeWidgetDelegate* delegate) { - params->context = athena::ScreenManager::Get()->GetContext(); +namespace { + +class AthenaViewsDelegate: public views::ViewsDelegate { + public: + AthenaViewsDelegate() { + } + + virtual ~AthenaViewsDelegate() { + } + + virtual void OnBeforeWidgetInit( + views::Widget::InitParams* params, + views::internal::NativeWidgetDelegate* delegate) OVERRIDE { + params->context = athena::ScreenManager::Get()->GetContext(); + } + + virtual views::NonClientFrameView* CreateDefaultNonClientFrameView( + views::Widget* widget) OVERRIDE { + return new AthenaFrameView(widget); + } + + private: + DISALLOW_COPY_AND_ASSIGN(AthenaViewsDelegate); +}; + +} // namespace + +void CreateAthenaViewsDelegate() { + views::ViewsDelegate::views_delegate = new AthenaViewsDelegate; } -views::NonClientFrameView* AthenaViewsDelegate::CreateDefaultNonClientFrameView( - views::Widget* widget) { - return new AthenaFrameView(widget); +void ShutdownAthenaViewsDelegate() { + CHECK(views::ViewsDelegate::views_delegate); + delete views::ViewsDelegate::views_delegate; + views::ViewsDelegate::views_delegate = NULL; } } // namespace athena diff --git a/athena/main/athena_views_delegate.h b/athena/main/athena_views_delegate.h index b5d8586..9928bc1 100644 --- a/athena/main/athena_views_delegate.h +++ b/athena/main/athena_views_delegate.h @@ -4,25 +4,10 @@ #ifndef ATHENA_MAIN_ATHENA_VIEWS_DELEGATE_H_ #define ATHENA_MAIN_ATHENA_VIEWS_DELEGATE_H_ -#include "ui/views/views_delegate.h" - namespace athena { -class AthenaViewsDelegate : public views::ViewsDelegate { - public: - AthenaViewsDelegate() {} - virtual ~AthenaViewsDelegate() {} - - private: - // views::ViewsDelegate: - virtual void OnBeforeWidgetInit( - views::Widget::InitParams* params, - views::internal::NativeWidgetDelegate* delegate) OVERRIDE; - virtual views::NonClientFrameView* CreateDefaultNonClientFrameView( - views::Widget* widget) OVERRIDE; - - DISALLOW_COPY_AND_ASSIGN(AthenaViewsDelegate); -}; +void CreateAthenaViewsDelegate(); +void ShutdownAthenaViewsDelegate(); } // namespace athena |