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

Side by Side Diff: ui/views/touchui/touch_selection_controller_impl.cc

Issue 895903003: Adding UMA logging to touch text selection (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Histograms.xml Created 5 years, 10 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 (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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/views/touchui/touch_selection_controller_impl.h" 5 #include "ui/views/touchui/touch_selection_controller_impl.h"
6 6
7 #include "base/metrics/histogram_macros.h"
7 #include "base/time/time.h" 8 #include "base/time/time.h"
8 #include "ui/aura/client/cursor_client.h" 9 #include "ui/aura/client/cursor_client.h"
9 #include "ui/aura/env.h" 10 #include "ui/aura/env.h"
10 #include "ui/aura/window.h" 11 #include "ui/aura/window.h"
11 #include "ui/base/resource/resource_bundle.h" 12 #include "ui/base/resource/resource_bundle.h"
12 #include "ui/gfx/canvas.h" 13 #include "ui/gfx/canvas.h"
13 #include "ui/gfx/geometry/rect.h" 14 #include "ui/gfx/geometry/rect.h"
14 #include "ui/gfx/geometry/size.h" 15 #include "ui/gfx/geometry/size.h"
15 #include "ui/gfx/image/image.h" 16 #include "ui/gfx/image/image.h"
16 #include "ui/gfx/path.h" 17 #include "ui/gfx/path.h"
(...skipping 391 matching lines...) Expand 10 before | Expand all | Expand 10 after
408 selection_handle_1_(new EditingHandleView(this, 409 selection_handle_1_(new EditingHandleView(this,
409 client_view->GetNativeView(), 410 client_view->GetNativeView(),
410 false)), 411 false)),
411 selection_handle_2_(new EditingHandleView(this, 412 selection_handle_2_(new EditingHandleView(this,
412 client_view->GetNativeView(), 413 client_view->GetNativeView(),
413 false)), 414 false)),
414 cursor_handle_(new EditingHandleView(this, 415 cursor_handle_(new EditingHandleView(this,
415 client_view->GetNativeView(), 416 client_view->GetNativeView(),
416 true)), 417 true)),
417 context_menu_(nullptr), 418 context_menu_(nullptr),
419 command_executed_(false),
418 dragging_handle_(nullptr) { 420 dragging_handle_(nullptr) {
421 selection_start_time_ = base::Time::Now();
419 aura::Window* client_window = client_view_->GetNativeView(); 422 aura::Window* client_window = client_view_->GetNativeView();
420 client_window->AddObserver(this); 423 client_window->AddObserver(this);
421 client_widget_ = Widget::GetTopLevelWidgetForNativeView(client_window); 424 client_widget_ = Widget::GetTopLevelWidgetForNativeView(client_window);
422 if (client_widget_) 425 if (client_widget_)
423 client_widget_->AddObserver(this); 426 client_widget_->AddObserver(this);
424 aura::Env::GetInstance()->AddPreTargetHandler(this); 427 aura::Env::GetInstance()->AddPreTargetHandler(this);
425 } 428 }
426 429
427 TouchSelectionControllerImpl::~TouchSelectionControllerImpl() { 430 TouchSelectionControllerImpl::~TouchSelectionControllerImpl() {
431 if (!command_executed_) {
432 UMA_HISTOGRAM_BOOLEAN("Event.TouchSelectionEndedWithAction", false);
433 LOG(ERROR) << "Event.TouchSelectionEndedWithAction = false";
434 }
428 HideContextMenu(); 435 HideContextMenu();
429 aura::Env::GetInstance()->RemovePreTargetHandler(this); 436 aura::Env::GetInstance()->RemovePreTargetHandler(this);
430 if (client_widget_) 437 if (client_widget_)
431 client_widget_->RemoveObserver(this); 438 client_widget_->RemoveObserver(this);
432 client_view_->GetNativeView()->RemoveObserver(this); 439 client_view_->GetNativeView()->RemoveObserver(this);
433 } 440 }
434 441
435 void TouchSelectionControllerImpl::SelectionChanged() { 442 void TouchSelectionControllerImpl::SelectionChanged() {
436 ui::SelectionBound anchor, focus; 443 ui::SelectionBound anchor, focus;
437 client_view_->GetSelectionEndPoints(&anchor, &focus); 444 client_view_->GetSelectionEndPoints(&anchor, &focus);
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
587 client_bounds.Inset(0, 0, 0, -kSelectionHandleBarBottomAllowance); 594 client_bounds.Inset(0, 0, 0, -kSelectionHandleBarBottomAllowance);
588 return client_bounds.Contains(BoundToRect(bound)); 595 return client_bounds.Contains(BoundToRect(bound));
589 } 596 }
590 597
591 bool TouchSelectionControllerImpl::IsCommandIdEnabled(int command_id) const { 598 bool TouchSelectionControllerImpl::IsCommandIdEnabled(int command_id) const {
592 return client_view_->IsCommandIdEnabled(command_id); 599 return client_view_->IsCommandIdEnabled(command_id);
593 } 600 }
594 601
595 void TouchSelectionControllerImpl::ExecuteCommand(int command_id, 602 void TouchSelectionControllerImpl::ExecuteCommand(int command_id,
596 int event_flags) { 603 int event_flags) {
604 command_executed_ = true;
605 UMA_HISTOGRAM_BOOLEAN("Event.TouchSelectionEndedWithAction", true);
606 base::TimeDelta duration = base::Time::Now() - selection_start_time_;
607 UMA_HISTOGRAM_CUSTOM_TIMES("Event.TouchSelectionDuration",
608 duration,
609 base::TimeDelta::FromMilliseconds(1),
610 base::TimeDelta::FromSeconds(60),
611 50);
612 LOG(ERROR) << "Event.TouchSelectionEndedWithAction = true";
613 LOG(ERROR) << "duration=" << duration.InMilliseconds() << "ms";
597 HideContextMenu(); 614 HideContextMenu();
598 client_view_->ExecuteCommand(command_id, event_flags); 615 client_view_->ExecuteCommand(command_id, event_flags);
599 } 616 }
600 617
601 void TouchSelectionControllerImpl::OpenContextMenu() { 618 void TouchSelectionControllerImpl::OpenContextMenu() {
602 // Context menu should appear centered on top of the selected region. 619 // Context menu should appear centered on top of the selected region.
603 const gfx::Rect rect = context_menu_->GetAnchorRect(); 620 const gfx::Rect rect = context_menu_->GetAnchorRect();
604 const gfx::Point anchor(rect.CenterPoint().x(), rect.y()); 621 const gfx::Point anchor(rect.CenterPoint().x(), rect.y());
605 HideContextMenu(); 622 HideContextMenu();
606 client_view_->OpenContextMenu(anchor); 623 client_view_->OpenContextMenu(anchor);
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
735 752
736 views::WidgetDelegateView* TouchSelectionControllerImpl::GetHandle1View() { 753 views::WidgetDelegateView* TouchSelectionControllerImpl::GetHandle1View() {
737 return selection_handle_1_.get(); 754 return selection_handle_1_.get();
738 } 755 }
739 756
740 views::WidgetDelegateView* TouchSelectionControllerImpl::GetHandle2View() { 757 views::WidgetDelegateView* TouchSelectionControllerImpl::GetHandle2View() {
741 return selection_handle_2_.get(); 758 return selection_handle_2_.get();
742 } 759 }
743 760
744 } // namespace views 761 } // namespace views
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698