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

Side by Side Diff: ui/wm/core/window_activation_pre_target_handler.cc

Issue 1153633006: Added UMA statistics for changing the active window via click or touch events. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 6 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
OLDNEW
(Empty)
1 // Copyright 2015 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 "ui/wm/core/window_activation_pre_target_handler.h"
6
7 #include "ui/aura/window.h"
8 #include "ui/events/event.h"
9 #include "ui/events/event_constants.h"
10 #include "ui/wm/core/window_activation_pre_target_handler_observer.h"
11 #include "ui/wm/public/activation_client.h"
12
13 namespace wm {
14
15 WindowActivationPreTargetHandler::WindowActivationPreTargetHandler(
16 aura::client::ActivationClient* activation_client)
17 : activation_client_(activation_client) {
18 }
19
20 WindowActivationPreTargetHandler::~WindowActivationPreTargetHandler() {
21 }
22
23 void WindowActivationPreTargetHandler::AddObserver(
24 WindowActivationPreTargetHandlerObserver* observer) {
25 observers_.AddObserver(observer);
26 }
27
28 void WindowActivationPreTargetHandler::RemoveObserver(
29 WindowActivationPreTargetHandlerObserver* observer) {
30 observers_.RemoveObserver(observer);
31 }
32
33 void WindowActivationPreTargetHandler::OnMouseEvent(ui::MouseEvent* event) {
34 if (event->type() == ui::ET_MOUSE_PRESSED && !event->handled())
35 ActivateWindowFromEvent(event);
36 }
37
38 void WindowActivationPreTargetHandler::OnGestureEvent(ui::GestureEvent* event) {
39 if (event->type() == ui::ET_GESTURE_BEGIN &&
40 event->details().touch_points() == 1 && !event->handled()) {
41 ActivateWindowFromEvent(event);
42 }
43 }
44
45 void WindowActivationPreTargetHandler::ActivateWindowFromEvent(
46 ui::Event* event) {
47 aura::Window* window = static_cast<aura::Window*>(event->target());
48 if (activation_client_->CanActivateWindow(window)) {
49 aura::Window* lost_active_window = activation_client_->GetActiveWindow();
50 FOR_EACH_OBSERVER(WindowActivationPreTargetHandlerObserver, observers_,
51 BeforeWindowActivatedByPreTargetHandler());
52 activation_client_->ActivateWindow(window);
53 FOR_EACH_OBSERVER(
54 WindowActivationPreTargetHandlerObserver, observers_,
55 OnWindowActivatedByPreTargetHandler(
56 activation_client_->GetActiveWindow(), lost_active_window));
57 }
58 }
59
60 } // namespace wm
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698