diff options
-rw-r--r-- | athena/athena.gyp | 1 | ||||
-rw-r--r-- | athena/env/athena_env_impl.cc | 61 | ||||
-rw-r--r-- | athena/env/athena_env_unittest.cc | 38 | ||||
-rw-r--r-- | athena/screen/screen_manager_impl.cc | 7 | ||||
-rw-r--r-- | athena/wm/window_manager_unittest.cc | 3 | ||||
-rw-r--r-- | chrome/browser/chromeos/chrome_browser_main_chromeos.cc | 6 | ||||
-rw-r--r-- | chrome/browser/ui/views/athena/chrome_browser_main_extra_parts_athena.cc | 13 |
7 files changed, 120 insertions, 9 deletions
diff --git a/athena/athena.gyp b/athena/athena.gyp index 8d9e4da..9a69a66 100644 --- a/athena/athena.gyp +++ b/athena/athena.gyp @@ -244,6 +244,7 @@ 'activity/activity_manager_unittest.cc', 'util/fill_layout_manager_unittest.cc', 'content/app_activity_unittest.cc', + 'env/athena_env_unittest.cc', 'home/athena_start_page_view_unittest.cc', 'home/home_card_gesture_manager_unittest.cc', 'home/home_card_unittest.cc', diff --git a/athena/env/athena_env_impl.cc b/athena/env/athena_env_impl.cc index ce55b1d..130f8af 100644 --- a/athena/env/athena_env_impl.cc +++ b/athena/env/athena_env_impl.cc @@ -34,6 +34,63 @@ namespace { AthenaEnv* instance = NULL; +// Screen object used during shutdown. +gfx::Screen* screen_for_shutdown = NULL; + +// TODO(flackr:oshima): Remove this once athena switches to share +// ash::DisplayManager. +class ScreenForShutdown : public gfx::Screen { + public: + // Creates and sets the screen for shutdown. Deletes existing one if any. + static void Create(const gfx::Screen* screen) { + delete screen_for_shutdown; + screen_for_shutdown = new ScreenForShutdown(screen->GetPrimaryDisplay()); + gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_NATIVE, + screen_for_shutdown); + } + + private: + explicit ScreenForShutdown(const gfx::Display& primary_display) + : primary_display_(primary_display) {} + + // gfx::Screen overrides: + virtual bool IsDIPEnabled() OVERRIDE { return true; } + virtual gfx::Point GetCursorScreenPoint() OVERRIDE { return gfx::Point(); } + virtual gfx::NativeWindow GetWindowUnderCursor() OVERRIDE { return NULL; } + virtual gfx::NativeWindow GetWindowAtScreenPoint( + const gfx::Point& point) OVERRIDE { + return NULL; + } + virtual int GetNumDisplays() const OVERRIDE { return 1; } + virtual std::vector<gfx::Display> GetAllDisplays() const OVERRIDE { + std::vector<gfx::Display> displays(1, primary_display_); + return displays; + } + virtual gfx::Display GetDisplayNearestWindow( + gfx::NativeView view) const OVERRIDE { + return primary_display_; + } + virtual gfx::Display GetDisplayNearestPoint( + const gfx::Point& point) const OVERRIDE { + return primary_display_; + } + virtual gfx::Display GetDisplayMatching( + const gfx::Rect& match_rect) const OVERRIDE { + return primary_display_; + } + virtual gfx::Display GetPrimaryDisplay() const OVERRIDE { + return primary_display_; + } + virtual void AddObserver(gfx::DisplayObserver* observer) OVERRIDE { + NOTREACHED() << "Observer should not be added during shutdown"; + } + virtual void RemoveObserver(gfx::DisplayObserver* observer) OVERRIDE {} + + const gfx::Display primary_display_; + + DISALLOW_COPY_AND_ASSIGN(ScreenForShutdown); +}; + // A class that bridges the gap between CursorManager and Aura. It borrows // heavily from AshNativeCursorManager. class AthenaNativeCursorManager : public wm::NativeCursorManager { @@ -182,9 +239,9 @@ class AthenaEnvImpl : public AthenaEnv, input_method_filter_.reset(); host_.reset(); - screen_.reset(); - gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_NATIVE, NULL); + ScreenForShutdown::Create(screen_.get()); + screen_.reset(); aura::Env::DeleteInstance(); display_configurator_->RemoveObserver(this); diff --git a/athena/env/athena_env_unittest.cc b/athena/env/athena_env_unittest.cc new file mode 100644 index 0000000..1c092a2 --- /dev/null +++ b/athena/env/athena_env_unittest.cc @@ -0,0 +1,38 @@ +// Copyright 2014 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. + +#include "athena/env/public/athena_env.h" + +#include "athena/test/athena_test_base.h" +#include "base/bind.h" +#include "ui/gfx/display.h" +#include "ui/gfx/screen.h" + +namespace athena { + +namespace { + +class AthenaShutdownTest : public test::AthenaTestBase { + public: + AthenaShutdownTest() {} + virtual ~AthenaShutdownTest() {} + + virtual void TearDown() { + test::AthenaTestBase::TearDown(); + ASSERT_NE( + gfx::Display::kInvalidDisplayID, + gfx::Screen::GetNativeScreen()->GetPrimaryDisplay().id()); + } + + private: + DISALLOW_COPY_AND_ASSIGN(AthenaShutdownTest); +}; + +} // namespace + +// gfx::Screen should be accessible after shutdown. +TEST_F(AthenaShutdownTest, Shutdown) { +} + +} // namespace athena diff --git a/athena/screen/screen_manager_impl.cc b/athena/screen/screen_manager_impl.cc index c8395a7..0b9f67e 100644 --- a/athena/screen/screen_manager_impl.cc +++ b/athena/screen/screen_manager_impl.cc @@ -240,6 +240,13 @@ ScreenManagerImpl::~ScreenManagerImpl() { root_window_->RemovePreTargetHandler(focus_controller); aura::client::SetActivationClient(root_window_, NULL); aura::client::SetFocusClient(root_window_, NULL); + aura::Window::Windows children = root_window_->children(); + // Close All children: + for (aura::Window::Windows::iterator iter = children.begin(); + iter != children.end(); + ++iter) { + delete *iter; + } instance = NULL; } diff --git a/athena/wm/window_manager_unittest.cc b/athena/wm/window_manager_unittest.cc index 0f03ae1..4e3324f 100644 --- a/athena/wm/window_manager_unittest.cc +++ b/athena/wm/window_manager_unittest.cc @@ -35,9 +35,6 @@ namespace athena { typedef test::AthenaTestBase WindowManagerTest; -TEST_F(WindowManagerTest, Empty) { -} - TEST_F(WindowManagerTest, OverviewModeBasics) { aura::test::TestWindowDelegate delegate; scoped_ptr<aura::Window> first(CreateWindow(&delegate)); diff --git a/chrome/browser/chromeos/chrome_browser_main_chromeos.cc b/chrome/browser/chromeos/chrome_browser_main_chromeos.cc index 77b6730..3ac8c03 100644 --- a/chrome/browser/chromeos/chrome_browser_main_chromeos.cc +++ b/chrome/browser/chromeos/chrome_browser_main_chromeos.cc @@ -627,11 +627,11 @@ void ChromeBrowserMainPartsChromeos::PostBrowserStart() { #endif data_promo_notification_.reset(new DataPromoNotification()); +#if !defined(USE_ATHENA) + // TODO(oshima): Support accessibility on athena. crbug.com/408733. keyboard_event_rewriters_.reset(new EventRewriterController()); keyboard_event_rewriters_->AddEventRewriter( scoped_ptr<ui::EventRewriter>(new KeyboardDrivenEventRewriter())); -#if !defined(USE_ATHENA) - // TODO(oshima): Support accessibility on athena. crbug.com/408733. keyboard_event_rewriters_->AddEventRewriter(scoped_ptr<ui::EventRewriter>( new EventRewriter(ash::Shell::GetInstance()->sticky_keys_controller()))); keyboard_event_rewriters_->Init(); @@ -705,7 +705,9 @@ void ChromeBrowserMainPartsChromeos::PostMainMessageLoopRun() { power_button_observer_.reset(); idle_action_warning_observer_.reset(); +#if !defined(USE_ATHENA) MagnificationManager::Shutdown(); +#endif AccessibilityManager::Shutdown(); media::SoundsManager::Shutdown(); diff --git a/chrome/browser/ui/views/athena/chrome_browser_main_extra_parts_athena.cc b/chrome/browser/ui/views/athena/chrome_browser_main_extra_parts_athena.cc index 6624053..bbc00c3 100644 --- a/chrome/browser/ui/views/athena/chrome_browser_main_extra_parts_athena.cc +++ b/chrome/browser/ui/views/athena/chrome_browser_main_extra_parts_athena.cc @@ -6,26 +6,36 @@ #include "athena/extensions/public/extensions_delegate.h" #include "athena/main/public/athena_launcher.h" +#include "base/command_line.h" #include "base/macros.h" #include "chrome/browser/browser_process.h" #include "chrome/browser/chrome_browser_main_extra_parts.h" +#include "chrome/browser/lifetime/application_lifetime.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/profiles/profile_manager.h" +#include "chrome/common/chrome_switches.h" #include "content/public/browser/browser_thread.h" namespace { class ChromeBrowserMainExtraPartsAthena : public ChromeBrowserMainExtraParts { public: - ChromeBrowserMainExtraPartsAthena() {} + ChromeBrowserMainExtraPartsAthena() { + } + virtual ~ChromeBrowserMainExtraPartsAthena() {} + private: // Overridden from ChromeBrowserMainExtraParts: virtual void PreProfileInit() OVERRIDE { athena::StartAthenaEnv(content::BrowserThread::GetMessageLoopProxyForThread( content::BrowserThread::FILE)); } virtual void PostProfileInit() OVERRIDE { + if (!CommandLine::ForCurrentProcess()->HasSwitch( + switches::kDisableZeroBrowsersOpenForTests)) { + chrome::IncrementKeepAliveCount(); + } Profile* profile = g_browser_process->profile_manager()->GetActiveUserProfile(); // TODO(oshima|polukhin): Start OOBE/Login process. @@ -34,7 +44,6 @@ class ChromeBrowserMainExtraPartsAthena : public ChromeBrowserMainExtraParts { } virtual void PostMainMessageLoopRun() OVERRIDE { athena::ShutdownAthena(); } - private: DISALLOW_COPY_AND_ASSIGN(ChromeBrowserMainExtraPartsAthena); }; |