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

Side by Side Diff: ui/touch_selection/touch_selection_controller.cc

Issue 1965013004: Record user actions for long-press follow-on actions. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Renamed most actions: Prefixed the mobile action bar actions with "MobileActionMode.", the contextu… Created 4 years, 7 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
« no previous file with comments | « tools/metrics/actions/actions.xml ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ui/touch_selection/touch_selection_controller.h" 5 #include "ui/touch_selection/touch_selection_controller.h"
6 6
7 #include "base/auto_reset.h" 7 #include "base/auto_reset.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/metrics/histogram_macros.h" 9 #include "base/metrics/histogram_macros.h"
10 #include "base/metrics/user_metrics.h"
10 11
11 namespace ui { 12 namespace ui {
12 namespace { 13 namespace {
13 14
14 gfx::Vector2dF ComputeLineOffsetFromBottom(const SelectionBound& bound) { 15 gfx::Vector2dF ComputeLineOffsetFromBottom(const SelectionBound& bound) {
15 gfx::Vector2dF line_offset = 16 gfx::Vector2dF line_offset =
16 gfx::ScaleVector2d(bound.edge_top() - bound.edge_bottom(), 0.5f); 17 gfx::ScaleVector2d(bound.edge_top() - bound.edge_bottom(), 0.5f);
17 // An offset of 8 DIPs is sufficient for most line sizes. For small lines, 18 // An offset of 8 DIPs is sufficient for most line sizes. For small lines,
18 // using half the line height avoids synthesizing a point on a line above 19 // using half the line height avoids synthesizing a point on a line above
19 // (or below) the intended line. 20 // (or below) the intended line.
(...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after
377 anchor_drag_to_selection_start_ = 378 anchor_drag_to_selection_start_ =
378 (drag_position - GetStartPosition()).LengthSquared() < 379 (drag_position - GetStartPosition()).LengthSquared() <
379 (drag_position - GetEndPosition()).LengthSquared(); 380 (drag_position - GetEndPosition()).LengthSquared();
380 } 381 }
381 382
382 gfx::PointF base = GetStartPosition() + GetStartLineOffset(); 383 gfx::PointF base = GetStartPosition() + GetStartLineOffset();
383 gfx::PointF extent = GetEndPosition() + GetEndLineOffset(); 384 gfx::PointF extent = GetEndPosition() + GetEndLineOffset();
384 if (anchor_drag_to_selection_start_) 385 if (anchor_drag_to_selection_start_)
385 std::swap(base, extent); 386 std::swap(base, extent);
386 387
388 // If this is the first drag, log an action to allow user action sequencing.
389 if (!selection_handle_dragged_) {
390 base::RecordAction(base::UserMetricsAction("MobileSelectionChanged"));
mohsen 2016/05/12 17:27:44 nit: By "Mobile" do you mean Android? Can we use a
Donn Denman 2016/05/12 17:37:46 Good point -- changed to SelectionChanged.
391 }
387 selection_handle_dragged_ = true; 392 selection_handle_dragged_ = true;
388 393
389 // When moving the handle we want to move only the extent point. Before doing 394 // When moving the handle we want to move only the extent point. Before doing
390 // so we must make sure that the base point is set correctly. 395 // so we must make sure that the base point is set correctly.
391 client_->SelectBetweenCoordinates(base, extent); 396 client_->SelectBetweenCoordinates(base, extent);
392 client_->OnSelectionEvent(SELECTION_HANDLE_DRAG_STARTED); 397 client_->OnSelectionEvent(SELECTION_HANDLE_DRAG_STARTED);
393 } 398 }
394 399
395 void TouchSelectionController::OnDragUpdate( 400 void TouchSelectionController::OnDragUpdate(
396 const TouchSelectionDraggable& draggable, 401 const TouchSelectionDraggable& draggable,
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after
690 base::TimeDelta duration = base::TimeTicks::Now() - selection_start_time_; 695 base::TimeDelta duration = base::TimeTicks::Now() - selection_start_time_;
691 UMA_HISTOGRAM_CUSTOM_TIMES("Event.TouchSelection.WasDraggedDuration", 696 UMA_HISTOGRAM_CUSTOM_TIMES("Event.TouchSelection.WasDraggedDuration",
692 duration, 697 duration,
693 base::TimeDelta::FromMilliseconds(500), 698 base::TimeDelta::FromMilliseconds(500),
694 base::TimeDelta::FromSeconds(60), 699 base::TimeDelta::FromSeconds(60),
695 60); 700 60);
696 } 701 }
697 } 702 }
698 703
699 } // namespace ui 704 } // namespace ui
OLDNEW
« no previous file with comments | « tools/metrics/actions/actions.xml ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698