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

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: Changed MobileSelectionChanged to SelectionChanged. 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
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("SelectionChanged"));
387 selection_handle_dragged_ = true; 391 selection_handle_dragged_ = true;
388 392
389 // When moving the handle we want to move only the extent point. Before doing 393 // 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. 394 // so we must make sure that the base point is set correctly.
391 client_->SelectBetweenCoordinates(base, extent); 395 client_->SelectBetweenCoordinates(base, extent);
392 client_->OnSelectionEvent(SELECTION_HANDLE_DRAG_STARTED); 396 client_->OnSelectionEvent(SELECTION_HANDLE_DRAG_STARTED);
393 } 397 }
394 398
395 void TouchSelectionController::OnDragUpdate( 399 void TouchSelectionController::OnDragUpdate(
396 const TouchSelectionDraggable& draggable, 400 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_; 694 base::TimeDelta duration = base::TimeTicks::Now() - selection_start_time_;
691 UMA_HISTOGRAM_CUSTOM_TIMES("Event.TouchSelection.WasDraggedDuration", 695 UMA_HISTOGRAM_CUSTOM_TIMES("Event.TouchSelection.WasDraggedDuration",
692 duration, 696 duration,
693 base::TimeDelta::FromMilliseconds(500), 697 base::TimeDelta::FromMilliseconds(500),
694 base::TimeDelta::FromSeconds(60), 698 base::TimeDelta::FromSeconds(60),
695 60); 699 60);
696 } 700 }
697 } 701 }
698 702
699 } // namespace ui 703 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698