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

Side by Side Diff: ash/wm/ash_activation_controller.cc

Issue 23874013: Remove old activation code and disable-focus-controller flags (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 3 months 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "ash/wm/ash_activation_controller.h"
6
7 #include "ash/launcher/launcher.h"
8 #include "ash/root_window_controller.h"
9 #include "ash/shelf/shelf_widget.h"
10 #include "ash/shell.h"
11 #include "ash/shell_delegate.h"
12 #include "ash/wm/activation_controller.h"
13 #include "ash/wm/property_util.h"
14 #include "ash/wm/window_util.h"
15 #include "ash/wm/workspace_controller.h"
16 #include "ui/views/corewm/window_modality_controller.h"
17 #include "ui/views/widget/widget.h"
18
19 namespace ash {
20 namespace internal {
21
22 ////////////////////////////////////////////////////////////////////////////////
23 // AshActivationController, public:
24
25 AshActivationController::AshActivationController() {
26 }
27
28 AshActivationController::~AshActivationController() {
29 }
30
31 ////////////////////////////////////////////////////////////////////////////////
32 // AshActivationController, ActivationControllerDelegate implementation:
33
34 aura::Window* AshActivationController::WillActivateWindow(
35 aura::Window* window) {
36 aura::Window* window_modal_transient =
37 views::corewm::GetModalTransient(window);
38 if (window_modal_transient)
39 return window_modal_transient;
40
41 // Fallback to launcher
42 if (!window)
43 window = PrepareToActivateLauncher();
44
45 // Restore minimized window. This needs to be done before CanReceiveEvents()
46 // is called as that function checks window visibility.
47 if (window && wm::IsWindowMinimized(window))
48 window->Show();
49
50 // If the screen is locked, just bring the window to top so that
51 // it will be activated when the lock window is destroyed.
52 // TODO(beng): Call EventClient directly here, rather than conflating with
53 // window visibility.
54 if (window && !window->CanReceiveEvents())
55 return NULL;
56
57 // TODO(beng): could probably move to being a ActivationChangeObserver on
58 // Shell.
59 if (window) {
60 DCHECK(window->GetRootWindow());
61 Shell::GetInstance()->set_active_root_window(window->GetRootWindow());
62 }
63 return window;
64 }
65
66 aura::Window* AshActivationController::WillFocusWindow(
67 aura::Window* window) {
68 aura::Window* window_modal_transient =
69 views::corewm::GetModalTransient(window);
70 if (window_modal_transient)
71 return window_modal_transient;
72 return window;
73 }
74
75 aura::Window* AshActivationController::PrepareToActivateLauncher() {
76 // If workspace controller is not available, then it means that the root
77 // window is being destroyed. We can't activate any window then.
78 if (!GetRootWindowController(
79 Shell::GetActiveRootWindow())->workspace_controller()) {
80 return NULL;
81 }
82 // Fallback to a launcher only when Spoken feedback is enabled.
83 if (!Shell::GetInstance()->delegate()->IsSpokenFeedbackEnabled())
84 return NULL;
85 ShelfWidget* shelf = GetRootWindowController(
86 Shell::GetActiveRootWindow())->shelf();
87 // Launcher's window may be already destroyed in shutting down process.
88 if (!shelf)
89 return NULL;
90 // Notify launcher to allow activation via CanActivate().
91 shelf->WillActivateAsFallback();
92 return shelf->GetNativeWindow();
93 }
94
95 } // namespace internal
96 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698