Index: ash/shell.cc |
diff --git a/ash/shell.cc b/ash/shell.cc |
index d7dc9b5623fa2c35b446e4d5f695c7889076cf8f..22fef97a4244004ec9f1f87ff405e3215c738635 100644 |
--- a/ash/shell.cc |
+++ b/ash/shell.cc |
@@ -33,6 +33,7 @@ |
#include "ash/magnifier/magnification_controller.h" |
#include "ash/magnifier/partial_magnification_controller.h" |
#include "ash/media_delegate.h" |
+#include "ash/metrics/screen_event_task_switch_metric_recorder.h" |
#include "ash/new_window_delegate.h" |
#include "ash/root_window_controller.h" |
#include "ash/session/session_state_delegate.h" |
@@ -112,6 +113,7 @@ |
#include "ui/wm/core/nested_accelerator_controller.h" |
#include "ui/wm/core/shadow_controller.h" |
#include "ui/wm/core/visibility_controller.h" |
+#include "ui/wm/core/window_activation_pre_target_handler.h" |
#include "ui/wm/core/window_modality_controller.h" |
#if defined(OS_CHROMEOS) |
@@ -762,6 +764,12 @@ Shell::~Shell() { |
// Chrome implementation of shelf delegate depends on FocusClient, |
// so must be deleted before |focus_client_|. |
shelf_delegate_.reset(); |
+ window_activation_pretarget_handler_->RemoveObserver( |
+ screen_event_task_switch_metric_recorder_.get()); |
+ screen_event_task_switch_metric_recorder_.reset(); |
+ // TODO(bruthig): Investigate why the |window_activation_pretarget_handler_| |
+ // is not removed from pre-target handler lists. |
+ window_activation_pretarget_handler_.reset(); |
focus_client_.reset(); |
// Destroy SystemTrayNotifier after destroying SystemTray as TrayItems |
@@ -894,6 +902,12 @@ void Shell::Init(const ShellInitParams& init_params) { |
new ::wm::FocusController(focus_rules); |
focus_client_.reset(focus_controller); |
activation_client_ = focus_controller; |
+ window_activation_pretarget_handler_.reset( |
+ new ::wm::WindowActivationPreTargetHandler(activation_client_)); |
+ screen_event_task_switch_metric_recorder_.reset( |
+ new ScreenEventTaskSwitchMetricRecorder(user_metrics_recorder_.get())); |
+ window_activation_pretarget_handler_->AddObserver( |
+ screen_event_task_switch_metric_recorder_.get()); |
activation_client_->AddObserver(this); |
focus_cycler_.reset(new FocusCycler()); |
@@ -1111,9 +1125,7 @@ void Shell::InitRootWindow(aura::Window* root_window) { |
aura::client::SetFocusClient(root_window, focus_client_.get()); |
input_method_filter_->SetInputMethodPropertyInRootWindow(root_window); |
aura::client::SetActivationClient(root_window, activation_client_); |
- ::wm::FocusController* focus_controller = |
- static_cast< ::wm::FocusController*>(activation_client_); |
- root_window->AddPreTargetHandler(focus_controller); |
+ root_window->AddPreTargetHandler(window_activation_pretarget_handler_.get()); |
aura::client::SetVisibilityClient(root_window, visibility_controller_.get()); |
aura::client::SetDragDropClient(root_window, drag_drop_controller_.get()); |
aura::client::SetScreenPositionClient(root_window, |