Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2175)

Unified Diff: ash/wm/ash_activation_controller.cc

Issue 11451002: Focus launcher if spoken feedback is enabled and no other windows visible. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Added end to end tests. Created 8 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: ash/wm/ash_activation_controller.cc
diff --git a/ash/wm/ash_activation_controller.cc b/ash/wm/ash_activation_controller.cc
index f9cc006b0fef9804fbdb0462a08ad4620ddbfa37..261bd628c3ed5242de71ee8d0a4bd870296892a7 100644
--- a/ash/wm/ash_activation_controller.cc
+++ b/ash/wm/ash_activation_controller.cc
@@ -4,13 +4,16 @@
#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 {
@@ -34,6 +37,10 @@ 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
@@ -77,5 +84,35 @@ 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

Powered by Google App Engine
This is Rietveld 408576698