summaryrefslogtreecommitdiffstats
path: root/ash
diff options
context:
space:
mode:
authorsky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-02-21 01:17:36 +0000
committersky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-02-21 01:17:36 +0000
commitaf5e2527f117e4187012285b731b7c19690b09c0 (patch)
tree6a81621eb664eeec75b8565e206a592c33625003 /ash
parent5436bd2533a236ca3c6ff6cc7ce7b9a89e9ab10d (diff)
downloadchromium_src-af5e2527f117e4187012285b731b7c19690b09c0.zip
chromium_src-af5e2527f117e4187012285b731b7c19690b09c0.tar.gz
chromium_src-af5e2527f117e4187012285b731b7c19690b09c0.tar.bz2
Plumbs through ET_CANCEL_MODE, which is intended to be used when modal
type operations should cancel, such as menus. This is a precursor to moving TooltipController to views. BUG=175441 R=sadrul@chromium.org Review URL: https://chromiumcodereview.appspot.com/12294051 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@183693 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ash')
-rw-r--r--ash/ash.gyp2
-rw-r--r--ash/cancel_mode.cc22
-rw-r--r--ash/cancel_mode.h15
-rw-r--r--ash/launcher/launcher_tooltip_manager.cc17
-rw-r--r--ash/launcher/launcher_tooltip_manager.h9
-rw-r--r--ash/tooltips/tooltip_controller.cc16
-rw-r--r--ash/tooltips/tooltip_controller.h9
-rw-r--r--ash/wm/session_state_controller_impl.cc5
-rw-r--r--ash/wm/session_state_controller_impl2.cc3
9 files changed, 58 insertions, 40 deletions
diff --git a/ash/ash.gyp b/ash/ash.gyp
index 7330065..dd22c5b 100644
--- a/ash/ash.gyp
+++ b/ash/ash.gyp
@@ -62,6 +62,8 @@
'ash_constants.h',
'ash_switches.cc',
'ash_switches.h',
+ 'cancel_mode.cc',
+ 'cancel_mode.h',
'caps_lock_delegate.h',
'caps_lock_delegate_stub.cc',
'caps_lock_delegate_stub.h',
diff --git a/ash/cancel_mode.cc b/ash/cancel_mode.cc
new file mode 100644
index 0000000..92f0543
--- /dev/null
+++ b/ash/cancel_mode.cc
@@ -0,0 +1,22 @@
+// Copyright (c) 2013 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/cancel_mode.h"
+
+#include "ash/root_window_controller.h"
+#include "ash/shell.h"
+#include "ui/aura/root_window.h"
+
+namespace ash {
+
+void DispatchCancelMode() {
+ Shell::RootWindowControllerList controllers(
+ Shell::GetAllRootWindowControllers());
+ for (Shell::RootWindowControllerList::const_iterator i = controllers.begin();
+ i != controllers.end(); ++i) {
+ (*i)->root_window()->AsRootWindowHostDelegate()->OnHostCancelMode();
+ }
+}
+
+} // namespace ash
diff --git a/ash/cancel_mode.h b/ash/cancel_mode.h
new file mode 100644
index 0000000..915fe43
--- /dev/null
+++ b/ash/cancel_mode.h
@@ -0,0 +1,15 @@
+// Copyright (c) 2013 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.
+
+#ifndef ASH_CANCEL_MODE_H_
+#define ASH_CANCEL_MODE_H_
+
+namespace ash {
+
+// Sends OnHostCancelMode() to all RootWindows.
+void DispatchCancelMode();
+
+} // namespace ash
+
+#endif // ASH_CANCEL_MODE_H_
diff --git a/ash/launcher/launcher_tooltip_manager.cc b/ash/launcher/launcher_tooltip_manager.cc
index ba5bf48..5d5e230 100644
--- a/ash/launcher/launcher_tooltip_manager.cc
+++ b/ash/launcher/launcher_tooltip_manager.cc
@@ -7,8 +7,6 @@
#include "ash/launcher/launcher_view.h"
#include "ash/shell.h"
#include "ash/shell_window_ids.h"
-#include "ash/wm/session_state_controller.h"
-#include "ash/wm/session_state_observer.h"
#include "ash/wm/shelf_layout_manager.h"
#include "ash/wm/window_animations.h"
#include "base/bind.h"
@@ -137,10 +135,8 @@ LauncherTooltipManager::LauncherTooltipManager(
launcher_view_(launcher_view) {
if (shelf_layout_manager)
shelf_layout_manager->AddObserver(this);
- if (Shell::HasInstance()) {
+ if (Shell::HasInstance())
Shell::GetInstance()->AddPreTargetHandler(this);
- Shell::GetInstance()->session_state_controller()->AddObserver(this);
- }
}
LauncherTooltipManager::~LauncherTooltipManager() {
@@ -148,10 +144,8 @@ LauncherTooltipManager::~LauncherTooltipManager() {
Close();
if (shelf_layout_manager_)
shelf_layout_manager_->RemoveObserver(this);
- if (Shell::HasInstance()) {
+ if (Shell::HasInstance())
Shell::GetInstance()->RemovePreTargetHandler(this);
- Shell::GetInstance()->session_state_controller()->RemoveObserver(this);
- }
}
void LauncherTooltipManager::ShowDelayed(views::View* anchor,
@@ -290,11 +284,8 @@ void LauncherTooltipManager::OnGestureEvent(ui::GestureEvent* event) {
}
}
-void LauncherTooltipManager::OnSessionStateEvent(
- SessionStateObserver::EventType event) {
- if (event == SessionStateObserver::EVENT_PRELOCK_ANIMATION_STARTED ||
- event == SessionStateObserver::EVENT_LOCK_ANIMATION_STARTED)
- Close();
+void LauncherTooltipManager::OnCancelMode(ui::CancelModeEvent* event) {
+ Close();
}
void LauncherTooltipManager::WillDeleteShelf() {
diff --git a/ash/launcher/launcher_tooltip_manager.h b/ash/launcher/launcher_tooltip_manager.h
index efe27f9..edd48bb 100644
--- a/ash/launcher/launcher_tooltip_manager.h
+++ b/ash/launcher/launcher_tooltip_manager.h
@@ -7,7 +7,6 @@
#include "ash/ash_export.h"
#include "ash/shelf_types.h"
-#include "ash/wm/session_state_observer.h"
#include "ash/wm/shelf_layout_manager.h"
#include "base/basictypes.h"
#include "base/string16.h"
@@ -37,8 +36,7 @@ class LauncherView;
// LauncherTooltipManager manages the tooltip balloon poping up on launcher
// items.
class ASH_EXPORT LauncherTooltipManager : public ui::EventHandler,
- public ShelfLayoutManager::Observer,
- public SessionStateObserver {
+ public ShelfLayoutManager::Observer {
public:
LauncherTooltipManager(ShelfLayoutManager* shelf_layout_manager,
LauncherView* launcher_view);
@@ -79,10 +77,7 @@ protected:
virtual void OnMouseEvent(ui::MouseEvent* event) OVERRIDE;
virtual void OnTouchEvent(ui::TouchEvent* event) OVERRIDE;
virtual void OnGestureEvent(ui::GestureEvent* event) OVERRIDE;
-
- // SessionStateObserver override:
- virtual void OnSessionStateEvent(SessionStateObserver::EventType event)
- OVERRIDE;
+ virtual void OnCancelMode(ui::CancelModeEvent* event) OVERRIDE;
// ShelfLayoutManager::Observer overrides:
virtual void WillDeleteShelf() OVERRIDE;
diff --git a/ash/tooltips/tooltip_controller.cc b/ash/tooltips/tooltip_controller.cc
index 8c187b6..c8bde19 100644
--- a/ash/tooltips/tooltip_controller.cc
+++ b/ash/tooltips/tooltip_controller.cc
@@ -10,8 +10,6 @@
#include "ash/shell.h"
#include "ash/wm/coordinate_conversion.h"
#include "ash/wm/cursor_manager.h"
-#include "ash/wm/session_state_controller.h"
-#include "ash/wm/session_state_observer.h"
#include "base/command_line.h"
#include "base/location.h"
#include "base/string_split.h"
@@ -214,15 +212,11 @@ TooltipController::TooltipController(
base::TimeDelta::FromMilliseconds(kTooltipTimeoutMs),
this, &TooltipController::TooltipTimerFired);
DCHECK(drag_drop_client_);
- if (Shell::GetInstance())
- Shell::GetInstance()->session_state_controller()->AddObserver(this);
}
TooltipController::~TooltipController() {
if (tooltip_window_)
tooltip_window_->RemoveObserver(this);
- if (Shell::GetInstance())
- Shell::GetInstance()->session_state_controller()->RemoveObserver(this);
}
void TooltipController::UpdateTooltip(aura::Window* target) {
@@ -311,13 +305,9 @@ void TooltipController::OnTouchEvent(ui::TouchEvent* event) {
tooltip_window_ = NULL;
}
-void TooltipController::OnSessionStateEvent(
- SessionStateObserver::EventType event) {
- if (event == SessionStateObserver::EVENT_PRELOCK_ANIMATION_STARTED ||
- event == SessionStateObserver::EVENT_LOCK_ANIMATION_STARTED) {
- if (tooltip_.get() && tooltip_->IsVisible())
- tooltip_->Hide();
- }
+void TooltipController::OnCancelMode(ui::CancelModeEvent* event) {
+ if (tooltip_.get() && tooltip_->IsVisible())
+ tooltip_->Hide();
}
void TooltipController::OnWindowDestroyed(aura::Window* window) {
diff --git a/ash/tooltips/tooltip_controller.h b/ash/tooltips/tooltip_controller.h
index 5f2215a..3022aee 100644
--- a/ash/tooltips/tooltip_controller.h
+++ b/ash/tooltips/tooltip_controller.h
@@ -6,7 +6,6 @@
#define ASH_TOOLTIPS_TOOLTIP_CONTROLLER_H_
#include "ash/ash_export.h"
-#include "ash/wm/session_state_observer.h"
#include "base/memory/scoped_ptr.h"
#include "base/string16.h"
#include "base/timer.h"
@@ -33,8 +32,7 @@ namespace internal {
// TooltipController provides tooltip functionality for aura shell.
class ASH_EXPORT TooltipController : public aura::client::TooltipClient,
public ui::EventHandler,
- public aura::WindowObserver,
- public SessionStateObserver {
+ public aura::WindowObserver {
public:
explicit TooltipController(aura::client::DragDropClient* drag_drop_client);
virtual ~TooltipController();
@@ -47,10 +45,7 @@ class ASH_EXPORT TooltipController : public aura::client::TooltipClient,
virtual void OnKeyEvent(ui::KeyEvent* event) OVERRIDE;
virtual void OnMouseEvent(ui::MouseEvent* event) OVERRIDE;
virtual void OnTouchEvent(ui::TouchEvent* event) OVERRIDE;
-
- // Overridden from SessionStateController.
- virtual void OnSessionStateEvent(SessionStateObserver::EventType event)
- OVERRIDE;
+ virtual void OnCancelMode(ui::CancelModeEvent* event) OVERRIDE;
// Overridden from aura::WindowObserver.
virtual void OnWindowDestroyed(aura::Window* window) OVERRIDE;
diff --git a/ash/wm/session_state_controller_impl.cc b/ash/wm/session_state_controller_impl.cc
index 7a54f35..0469b6b 100644
--- a/ash/wm/session_state_controller_impl.cc
+++ b/ash/wm/session_state_controller_impl.cc
@@ -5,6 +5,7 @@
#include "ash/wm/session_state_controller_impl.h"
#include "ash/ash_switches.h"
+#include "ash/cancel_mode.h"
#include "ash/shell.h"
#include "ash/shell_delegate.h"
#include "ash/shell_window_ids.h"
@@ -71,6 +72,7 @@ void SessionStateControllerImpl::OnLockStateChanged(bool locked) {
internal::SessionStateAnimator::LOCK_SCREEN_CONTAINERS,
internal::SessionStateAnimator::ANIMATION_FADE_IN,
internal::SessionStateAnimator::ANIMATION_SPEED_SHOW_LOCK_SCREEN);
+ DispatchCancelMode();
FOR_EACH_OBSERVER(SessionStateObserver, observers_,
OnSessionStateEvent(
SessionStateObserver::EVENT_LOCK_ANIMATION_STARTED));
@@ -105,6 +107,7 @@ void SessionStateControllerImpl::OnStartingLock() {
internal::SessionStateAnimator::ANIMATION_FULL_CLOSE,
internal::SessionStateAnimator::ANIMATION_SPEED_FAST);
+ DispatchCancelMode();
FOR_EACH_OBSERVER(SessionStateObserver, observers_,
OnSessionStateEvent(SessionStateObserver::EVENT_LOCK_ANIMATION_STARTED));
@@ -120,6 +123,7 @@ void SessionStateControllerImpl::StartLockAnimationAndLockImmediately() {
internal::SessionStateAnimator::NON_LOCK_SCREEN_CONTAINERS,
internal::SessionStateAnimator::ANIMATION_PARTIAL_CLOSE,
internal::SessionStateAnimator::ANIMATION_SPEED_UNDOABLE);
+ DispatchCancelMode();
FOR_EACH_OBSERVER(SessionStateObserver, observers_,
OnSessionStateEvent(SessionStateObserver::EVENT_LOCK_ANIMATION_STARTED));
OnLockTimeout();
@@ -132,6 +136,7 @@ void SessionStateControllerImpl::StartLockAnimation(bool shutdown_after_lock) {
internal::SessionStateAnimator::NON_LOCK_SCREEN_CONTAINERS,
internal::SessionStateAnimator::ANIMATION_PARTIAL_CLOSE,
internal::SessionStateAnimator::ANIMATION_SPEED_UNDOABLE);
+ DispatchCancelMode();
FOR_EACH_OBSERVER(SessionStateObserver, observers_,
OnSessionStateEvent(
SessionStateObserver::EVENT_PRELOCK_ANIMATION_STARTED));
diff --git a/ash/wm/session_state_controller_impl2.cc b/ash/wm/session_state_controller_impl2.cc
index 2a386a3..2084e00 100644
--- a/ash/wm/session_state_controller_impl2.cc
+++ b/ash/wm/session_state_controller_impl2.cc
@@ -5,6 +5,7 @@
#include "ash/wm/session_state_controller_impl2.h"
#include "ash/ash_switches.h"
+#include "ash/cancel_mode.h"
#include "ash/shell.h"
#include "ash/shell_delegate.h"
#include "ash/shell_window_ids.h"
@@ -450,6 +451,7 @@ void SessionStateControllerImpl2::StartImmediatePreLockAnimation(
observer->Unpause();
+ DispatchCancelMode();
FOR_EACH_OBSERVER(SessionStateObserver, observers_,
OnSessionStateEvent(SessionStateObserver::EVENT_LOCK_ANIMATION_STARTED));
}
@@ -485,6 +487,7 @@ void SessionStateControllerImpl2::StartCancellablePreLockAnimation() {
internal::SessionStateAnimator::ANIMATION_SPEED_UNDOABLE,
observer);
+ DispatchCancelMode();
FOR_EACH_OBSERVER(SessionStateObserver, observers_,
OnSessionStateEvent(
SessionStateObserver::EVENT_PRELOCK_ANIMATION_STARTED));