Skip to content

Commit

Permalink
Exit overview mode when a new activity is opened in athena.
Browse files Browse the repository at this point in the history
This has the side effect of fixing the crash in 396368

BUG=396368
TEST=Manual, see bug

Committed: https://src.chromium.org/viewvc/chrome?view=rev&revision=285393

Review URL: https://codereview.chromium.org/411813002

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@285763 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
pkotwicz@chromium.org committed Jul 26, 2014
1 parent 65cc234 commit dd6f8fa
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 16 deletions.
8 changes: 0 additions & 8 deletions athena/home/home_card_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,6 @@ TEST_F(HomeCardTest, AppSelection) {
athena::ActivityFactory::Get()->CreateWebActivity(
NULL, GURL("http://www.google.com/")));
EXPECT_EQ(HomeCard::VISIBLE_MINIMIZED, HomeCard::Get()->GetState());

// Overview mode has to finish before ending test, otherwise it crashes.
// TODO(mukai): fix this.
WindowManager::GetInstance()->ToggleOverview();
}

TEST_F(HomeCardTest, Accelerators) {
Expand All @@ -84,10 +80,6 @@ TEST_F(HomeCardTest, Accelerators) {
EXPECT_EQ(HomeCard::VISIBLE_CENTERED, HomeCard::Get()->GetState());
generator.PressKey(ui::VKEY_L, ui::EF_CONTROL_DOWN);
EXPECT_EQ(HomeCard::VISIBLE_CENTERED, HomeCard::Get()->GetState());

// Overview mode has to finish before ending test, otherwise it crashes.
// TODO(mukai): fix this.
WindowManager::GetInstance()->ToggleOverview();
}

} // namespace athena
27 changes: 19 additions & 8 deletions athena/wm/window_manager_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ class WindowManagerImpl : public WindowManager,
COMMAND_TOGGLE_OVERVIEW,
};

// Sets whether overview mode is active.
void SetInOverview(bool active);

void InstallAccelerators();

// WindowManager:
Expand Down Expand Up @@ -101,6 +104,7 @@ WindowManagerImpl::WindowManagerImpl() {
}

WindowManagerImpl::~WindowManagerImpl() {
overview_.reset();
if (container_) {
container_->RemoveObserver(this);
container_->RemovePreTargetHandler(bezel_controller_.get());
Expand All @@ -112,6 +116,7 @@ WindowManagerImpl::~WindowManagerImpl() {
void WindowManagerImpl::Layout() {
if (!container_)
return;
SetInOverview(false);
gfx::Rect bounds = gfx::Rect(container_->bounds().size());
const aura::Window::Windows& children = container_->children();
for (aura::Window::Windows::const_iterator iter = children.begin();
Expand All @@ -124,14 +129,22 @@ void WindowManagerImpl::Layout() {
}

void WindowManagerImpl::ToggleOverview() {
if (overview_) {
overview_.reset();
FOR_EACH_OBSERVER(WindowManagerObserver, observers_,
OnOverviewModeExit());
} else {
SetInOverview(overview_.get() == NULL);
}

void WindowManagerImpl::SetInOverview(bool active) {
bool in_overview = !!overview_;
if (active == in_overview)
return;

if (active) {
overview_ = WindowOverviewMode::Create(container_.get(), this);
FOR_EACH_OBSERVER(WindowManagerObserver, observers_,
OnOverviewModeEnter());
} else {
overview_.reset();
FOR_EACH_OBSERVER(WindowManagerObserver, observers_,
OnOverviewModeExit());
}
}

Expand All @@ -156,9 +169,7 @@ void WindowManagerImpl::OnSelectWindow(aura::Window* window) {
CHECK_EQ(container_.get(), window->parent());
container_->StackChildAtTop(window);
wm::ActivateWindow(window);
overview_.reset();
FOR_EACH_OBSERVER(WindowManagerObserver, observers_,
OnOverviewModeExit());
SetInOverview(false);
}

void WindowManagerImpl::OnWindowDestroying(aura::Window* window) {
Expand Down

0 comments on commit dd6f8fa

Please sign in to comment.