summaryrefslogtreecommitdiffstats
path: root/ash
diff options
context:
space:
mode:
authorrsleevi@chromium.org <rsleevi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-12-17 05:37:42 +0000
committerrsleevi@chromium.org <rsleevi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-12-17 05:37:42 +0000
commitc3c9652c4fe55e933a6ce814ecf2d82f8cade13b (patch)
tree149ac297b8b55403839447ca79575c7cf3688c42 /ash
parent4b96530816299e1e42621d8c0ad0537e24ad5446 (diff)
downloadchromium_src-c3c9652c4fe55e933a6ce814ecf2d82f8cade13b.zip
chromium_src-c3c9652c4fe55e933a6ce814ecf2d82f8cade13b.tar.gz
chromium_src-c3c9652c4fe55e933a6ce814ecf2d82f8cade13b.tar.bz2
Revert 173417 - Broke on win_aura
Yet another approach. Not pretty, but simple and works. BUG=156772 Review URL: https://chromiumcodereview.appspot.com/11451002 TBR=mtomasz@chromium.org Review URL: https://codereview.chromium.org/11594004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@173421 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ash')
-rw-r--r--ash/ash.gyp1
-rw-r--r--ash/launcher/launcher.cc27
-rw-r--r--ash/launcher/launcher.h13
-rw-r--r--ash/launcher/launcher_unittest.cc15
-rw-r--r--ash/wm/ash_activation_controller.cc37
-rw-r--r--ash/wm/ash_activation_controller.h8
-rw-r--r--ash/wm/ash_activation_controller_unittest.cc126
7 files changed, 6 insertions, 221 deletions
diff --git a/ash/ash.gyp b/ash/ash.gyp
index cac4596..886a963 100644
--- a/ash/ash.gyp
+++ b/ash/ash.gyp
@@ -580,7 +580,6 @@
'test/ash_unittests.cc',
'tooltips/tooltip_controller_unittest.cc',
'wm/activation_controller_unittest.cc',
- 'wm/ash_activation_controller_unittest.cc',
'wm/base_layout_manager_unittest.cc',
'wm/cursor_manager_unittest.cc',
'wm/custom_frame_view_ash_unittest.cc',
diff --git a/ash/launcher/launcher.cc b/ash/launcher/launcher.cc
index a73f402..8668879 100644
--- a/ash/launcher/launcher.cc
+++ b/ash/launcher/launcher.cc
@@ -19,7 +19,6 @@
#include "ash/wm/shelf_layout_manager.h"
#include "ash/wm/window_properties.h"
#include "grit/ash_resources.h"
-#include "ui/aura/client/activation_client.h"
#include "ui/aura/root_window.h"
#include "ui/aura/window.h"
#include "ui/aura/window_observer.h"
@@ -69,14 +68,9 @@ class Launcher::DelegateView : public views::WidgetDelegate,
return View::GetWidget();
}
virtual bool CanActivate() const OVERRIDE {
- // Allow to activate as fallback.
- if (launcher_->activating_as_fallback_)
- return true;
- // Allow to activate from the focus cycler.
- if (focus_cycler_ && focus_cycler_->widget_activating() == GetWidget())
- return true;
- // Disallow activating in other cases, especially when using mouse.
- return false;
+ // We don't want mouse clicks to activate us, but we need to allow
+ // activation when the user is using the keyboard (FocusCycler).
+ return focus_cycler_ && focus_cycler_->widget_activating() == GetWidget();
}
// BackgroundAnimatorDelegate overrides:
@@ -215,8 +209,7 @@ Launcher::Launcher(LauncherModel* launcher_model,
launcher_view_(NULL),
alignment_(SHELF_ALIGNMENT_BOTTOM),
delegate_(launcher_delegate),
- background_animator_(delegate_view_, 0, kLauncherBackgroundAlpha),
- activating_as_fallback_(false) {
+ background_animator_(delegate_view_, 0, kLauncherBackgroundAlpha) {
widget_.reset(new views::Widget);
views::Widget::InitParams params(
views::Widget::InitParams::TYPE_WINDOW_FRAMELESS);
@@ -243,12 +236,9 @@ Launcher::Launcher(LauncherModel* launcher_model,
gfx::Size pref =
static_cast<views::View*>(launcher_view_)->GetPreferredSize();
widget_->SetBounds(gfx::Rect(pref));
-
- widget_->AddObserver(this);
}
Launcher::~Launcher() {
- widget_->RemoveObserver(this);
}
// static
@@ -416,15 +406,6 @@ void Launcher::SwitchToWindow(int window_index) {
}
}
-void Launcher::OnWidgetActivationChanged(views::Widget* widget, bool active) {
- activating_as_fallback_ = false;
- if (active) {
- delegate_view_->SetPaneFocusAndFocusDefault();
- } else {
- delegate_view_->GetFocusManager()->ClearFocus();
- }
-}
-
internal::LauncherView* Launcher::GetLauncherViewForTest() {
return launcher_view_;
}
diff --git a/ash/launcher/launcher.h b/ash/launcher/launcher.h
index a934a5b..03de4ec 100644
--- a/ash/launcher/launcher.h
+++ b/ash/launcher/launcher.h
@@ -12,7 +12,6 @@
#include "base/basictypes.h"
#include "base/memory/scoped_ptr.h"
#include "ui/gfx/size.h"
-#include "ui/views/widget/widget_observer.h"
namespace aura {
class Window;
@@ -39,7 +38,7 @@ class LauncherIconObserver;
class LauncherDelegate;
class LauncherModel;
-class ASH_EXPORT Launcher: public views::WidgetObserver {
+class ASH_EXPORT Launcher {
public:
Launcher(LauncherModel* launcher_model,
LauncherDelegate* launcher_delegate,
@@ -125,13 +124,6 @@ class ASH_EXPORT Launcher: public views::WidgetObserver {
aura::Window* window_container() { return window_container_; }
- // Called by the activation delegate, before the launcher is activated
- // when no other windows are visible.
- void WillActivateAsFallback() { activating_as_fallback_ = true; }
-
- // Overridden from views::WidgetObserver:
- void OnWidgetActivationChanged(views::Widget* widget, bool active) OVERRIDE;
-
private:
class DelegateView;
@@ -157,9 +149,6 @@ class ASH_EXPORT Launcher: public views::WidgetObserver {
// Used to animate the background.
internal::BackgroundAnimator background_animator_;
- // Used then activation is forced from the activation delegate.
- bool activating_as_fallback_;
-
DISALLOW_COPY_AND_ASSIGN(Launcher);
};
diff --git a/ash/launcher/launcher_unittest.cc b/ash/launcher/launcher_unittest.cc
index ea9135b..2c3f8a8 100644
--- a/ash/launcher/launcher_unittest.cc
+++ b/ash/launcher/launcher_unittest.cc
@@ -10,7 +10,6 @@
#include "ash/shell.h"
#include "ash/test/ash_test_base.h"
#include "ash/test/launcher_view_test_api.h"
-#include "ash/wm/window_util.h"
#include "ui/views/view.h"
#include "ui/views/widget/widget.h"
@@ -78,18 +77,4 @@ TEST_F(LauncherTest, OpenBrowser) {
ASSERT_EQ(--button_count, test.GetButtonCount());
}
-// Launcher can't be activated on mouse click, but it is activable from
-// the focus cycler or as fallback.
-TEST_F(LauncherTest, ActivateAsFallback) {
- Launcher* launcher = Launcher::ForPrimaryDisplay();
- views::Widget* launcher_widget = launcher->widget();
- EXPECT_FALSE(launcher_widget->CanActivate());
-
- launcher->WillActivateAsFallback();
- EXPECT_TRUE(launcher_widget->CanActivate());
-
- wm::ActivateWindow(launcher_widget->GetNativeWindow());
- EXPECT_FALSE(launcher_widget->CanActivate());
-}
-
} // namespace ash
diff --git a/ash/wm/ash_activation_controller.cc b/ash/wm/ash_activation_controller.cc
index 261bd62..f9cc006 100644
--- a/ash/wm/ash_activation_controller.cc
+++ b/ash/wm/ash_activation_controller.cc
@@ -4,16 +4,13 @@
#include "ash/wm/ash_activation_controller.h"
-#include "ash/launcher/launcher.h"
#include "ash/root_window_controller.h"
#include "ash/shell.h"
-#include "ash/shell_delegate.h"
#include "ash/wm/activation_controller.h"
#include "ash/wm/property_util.h"
#include "ash/wm/window_util.h"
#include "ash/wm/workspace_controller.h"
#include "ui/views/corewm/window_modality_controller.h"
-#include "ui/views/widget/widget.h"
namespace ash {
namespace internal {
@@ -37,10 +34,6 @@ aura::Window* AshActivationController::WillActivateWindow(
if (window_modal_transient)
return window_modal_transient;
- // Fallback to launcher
- if (!window)
- window = PrepareToActivateLauncher();
-
// Make sure the workspace manager switches to the workspace for window.
// Without this CanReceiveEvents() below returns false and activation never
// changes. CanReceiveEvents() returns false if |window| isn't in the active
@@ -84,35 +77,5 @@ aura::Window* AshActivationController::WillFocusWindow(
return window;
}
-aura::Window* AshActivationController::PrepareToActivateLauncher() {
- // If workspace controller is not available, then it means that the root
- // window is being destroyed. We can't activate any window then.
- if (!GetRootWindowController(
- Shell::GetActiveRootWindow())->workspace_controller()) {
- return NULL;
- }
- // Fallback to a launcher only when Spoken feedback is enabled.
- if (!Shell::GetInstance()->delegate()->IsSpokenFeedbackEnabled())
- return NULL;
- Launcher* launcher;
- if (Shell::IsLauncherPerDisplayEnabled()) {
- launcher = GetRootWindowController(
- Shell::GetActiveRootWindow())->launcher();
- } else {
- launcher = Launcher::ForPrimaryDisplay();
- }
- // Launcher is not always available, eg. not in the login screen.
- if (!launcher)
- return NULL;
- views::Widget* launcher_widget = launcher->widget();
- // Launcher's window may be already destroyed in shutting down process.
- if (!launcher_widget)
- return NULL;
- aura::Window* launcher_window = launcher_widget->GetNativeWindow();
- // Notify launcher to allow activation via CanActivate().
- launcher->WillActivateAsFallback();
- return launcher_window;
-}
-
} // namespace internal
} // namespace ash
diff --git a/ash/wm/ash_activation_controller.h b/ash/wm/ash_activation_controller.h
index c3961f9..0e9be46 100644
--- a/ash/wm/ash_activation_controller.h
+++ b/ash/wm/ash_activation_controller.h
@@ -5,7 +5,6 @@
#ifndef ASH_WM_ASH_ACTIVATION_CONTROLLER_H_
#define ASH_WM_ASH_ACTIVATION_CONTROLLER_H_
-#include "ash/ash_export.h"
#include "ash/wm/activation_controller_delegate.h"
#include "base/compiler_specific.h"
#include "base/basictypes.h"
@@ -13,7 +12,7 @@
namespace ash {
namespace internal {
-class ASH_EXPORT AshActivationController : public ActivationControllerDelegate {
+class AshActivationController : public ActivationControllerDelegate {
public:
AshActivationController();
virtual ~AshActivationController();
@@ -23,11 +22,6 @@ class ASH_EXPORT AshActivationController : public ActivationControllerDelegate {
virtual aura::Window* WillActivateWindow(aura::Window* window) OVERRIDE;
virtual aura::Window* WillFocusWindow(aura::Window* window) OVERRIDE;
- // Returns a handle to the launcher on the active root window which will
- // be activated as fallback. Also notifies the launcher, so it can return
- // true from Launcher::CanActivate().
- aura::Window* PrepareToActivateLauncher();
-
DISALLOW_COPY_AND_ASSIGN(AshActivationController);
};
diff --git a/ash/wm/ash_activation_controller_unittest.cc b/ash/wm/ash_activation_controller_unittest.cc
deleted file mode 100644
index 3fc31df..0000000
--- a/ash/wm/ash_activation_controller_unittest.cc
+++ /dev/null
@@ -1,126 +0,0 @@
-// Copyright (c) 2012 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 "ash/wm/ash_activation_controller.h"
-
-#include "ash/launcher/launcher.h"
-#include "ash/root_window_controller.h"
-#include "ash/shell_delegate.h"
-#include "ash/test/ash_test_base.h"
-#include "ash/wm/property_util.h"
-#include "ash/wm/window_util.h"
-#include "ui/aura/window.h"
-
-namespace ash {
-
-namespace wm {
-
-namespace {
-
-class AshActivationControllerTest : public test::AshTestBase {
- public:
- AshActivationControllerTest()
- : launcher_(NULL), launcher_widget_(NULL), launcher_window_(NULL) {}
- virtual ~AshActivationControllerTest() {}
-
- virtual void SetUp() OVERRIDE {
- test::AshTestBase::SetUp();
- ash_activation_controller_.reset(new internal::AshActivationController());
- launcher_ = Launcher::ForPrimaryDisplay();
- ASSERT_TRUE(launcher_);
- launcher_widget_ = launcher_->widget();
- ASSERT_TRUE(launcher_widget_);
- launcher_window_ = launcher_widget_->GetNativeWindow();
- ASSERT_TRUE(launcher_window_);
- }
-
- void SetSpokenFeedbackState(bool enabled) {
- if (Shell::GetInstance()->delegate()->IsSpokenFeedbackEnabled() !=
- enabled) {
- Shell::GetInstance()->delegate()->ToggleSpokenFeedback(
- A11Y_NOTIFICATION_NONE);
- }
- }
-
- protected:
- scoped_ptr<internal::ActivationControllerDelegate> ash_activation_controller_;
- ash::Launcher* launcher_;
- views::Widget* launcher_widget_;
- aura::Window* launcher_window_;
-
- DISALLOW_COPY_AND_ASSIGN(AshActivationControllerTest);
-};
-
-TEST_F(AshActivationControllerTest, LauncherFallback) {
- // When spoken feedback is disabled, then fallback should not occur.
- {
- SetSpokenFeedbackState(false);
- aura::Window* result = ash_activation_controller_->WillActivateWindow(NULL);
- EXPECT_EQ(NULL, result);
- }
-
- // When spoken feedback is enabled, then fallback should occur.
- {
- SetSpokenFeedbackState(true);
- aura::Window* result = ash_activation_controller_->WillActivateWindow(NULL);
- EXPECT_EQ(launcher_window_, result);
- }
-
- // No fallback when activating another window.
- {
- aura::Window* test_window = CreateTestWindowInShellWithId(0);
- aura::Window* result = ash_activation_controller_->
- WillActivateWindow(test_window);
- EXPECT_EQ(test_window, result);
- }
-}
-
-TEST_F(AshActivationControllerTest, LauncherFallbackOnShutdown) {
- SetSpokenFeedbackState(true);
- // While shutting down a root window controller, activation controller
- // is notified about destroyed windows and therefore will try to activate
- // a launcher as fallback, which would result in segmentation faults since
- // the launcher's window or the workspace's controller may be already
- // destroyed.
- GetRootWindowController(Shell::GetActiveRootWindow())->CloseChildWindows();
-
- aura::Window* result = ash_activation_controller_->WillActivateWindow(NULL);
- EXPECT_EQ(NULL, result);
-}
-
-TEST_F(AshActivationControllerTest, LauncherEndToEndFallbackOnDestroyTest) {
- // This test checks the whole fallback activation flow.
- SetSpokenFeedbackState(true);
-
- scoped_ptr<aura::Window> test_window(CreateTestWindowInShellWithId(0));
- ActivateWindow(test_window.get());
- ASSERT_EQ(test_window.get(), GetActiveWindow());
-
- // Close the window.
- test_window.reset();
-
- // Verify if the launcher got activated as fallback.
- ASSERT_EQ(launcher_window_, GetActiveWindow());
-}
-
-TEST_F(AshActivationControllerTest, LauncherEndToEndFallbackOnMinimizeTest) {
- // This test checks the whole fallback activation flow.
- SetSpokenFeedbackState(true);
-
- scoped_ptr<aura::Window> test_window(CreateTestWindowInShellWithId(0));
- ActivateWindow(test_window.get());
- ASSERT_EQ(test_window.get(), GetActiveWindow());
-
- // Minimize the window.
- MinimizeWindow(test_window.get());
-
- // Verify if the launcher got activated as fallback.
- ASSERT_EQ(launcher_window_, GetActiveWindow());
-}
-
-} // namespace
-
-} // namespace wm
-
-} // namespace ash