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

Side by Side Diff: chrome/browser/ui/omnibox/omnibox_edit_model.cc

Issue 18866003: Add histogram Omnibox.FocusToEditTime for time in milliseconds between a user focus and edit. (Closed) Base URL: https://src.chromium.org/svn/trunk/src/
Patch Set: Created 7 years, 5 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 | « chrome/browser/ui/omnibox/omnibox_edit_model.h ('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 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 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 "chrome/browser/ui/omnibox/omnibox_edit_model.h" 5 #include "chrome/browser/ui/omnibox/omnibox_edit_model.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/auto_reset.h" 9 #include "base/auto_reset.h"
10 #include "base/format_macros.h" 10 #include "base/format_macros.h"
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 OMNIBOX_USER_TEXT_CLEARED_BY_EDITING = 0, 86 OMNIBOX_USER_TEXT_CLEARED_BY_EDITING = 0,
87 OMNIBOX_USER_TEXT_CLEARED_WITH_ESCAPE = 1, 87 OMNIBOX_USER_TEXT_CLEARED_WITH_ESCAPE = 1,
88 OMNIBOX_USER_TEXT_CLEARED_NUM_OF_ITEMS, 88 OMNIBOX_USER_TEXT_CLEARED_NUM_OF_ITEMS,
89 }; 89 };
90 90
91 // Histogram name which counts the number of times the user enters 91 // Histogram name which counts the number of times the user enters
92 // keyword hint mode and via what method. The possible values are listed 92 // keyword hint mode and via what method. The possible values are listed
93 // in the EnteredKeywordModeMethod enum which is defined in the .h file. 93 // in the EnteredKeywordModeMethod enum which is defined in the .h file.
94 const char kEnteredKeywordModeHistogram[] = "Omnibox.EnteredKeywordMode"; 94 const char kEnteredKeywordModeHistogram[] = "Omnibox.EnteredKeywordMode";
95 95
96 // Histogram name which counts the number of milliseconds a user takes
97 // between focusing and editing the omnibox.
98 const char kFocusToEditHistogram[] = "Omnibox.FocusToEdit";
99
96 } // namespace 100 } // namespace
97 101
98 /////////////////////////////////////////////////////////////////////////////// 102 ///////////////////////////////////////////////////////////////////////////////
99 // OmniboxEditModel::State 103 // OmniboxEditModel::State
100 104
101 OmniboxEditModel::State::State(bool user_input_in_progress, 105 OmniboxEditModel::State::State(bool user_input_in_progress,
102 const string16& user_text, 106 const string16& user_text,
103 const string16& instant_suggestion, 107 const string16& instant_suggestion,
104 const string16& keyword, 108 const string16& keyword,
105 bool is_keyword_hint, 109 bool is_keyword_hint,
(...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after
407 } 411 }
408 412
409 void OmniboxEditModel::SetInputInProgress(bool in_progress) { 413 void OmniboxEditModel::SetInputInProgress(bool in_progress) {
410 if (user_input_in_progress_ == in_progress) 414 if (user_input_in_progress_ == in_progress)
411 return; 415 return;
412 416
413 user_input_in_progress_ = in_progress; 417 user_input_in_progress_ = in_progress;
414 if (user_input_in_progress_) { 418 if (user_input_in_progress_) {
415 time_user_first_modified_omnibox_ = base::TimeTicks::Now(); 419 time_user_first_modified_omnibox_ = base::TimeTicks::Now();
416 content::RecordAction(content::UserMetricsAction("OmniboxInputInProgress")); 420 content::RecordAction(content::UserMetricsAction("OmniboxInputInProgress"));
421 UMA_HISTOGRAM_COUNTS(kFocusToEditHistogram,
Mark P 2013/07/08 21:58:30 COUNTS is not the right type of histogram for time
H Fung 2013/07/09 01:09:55 I switched to UMA_HISTOGRAM_TIMES but I guess the
422 (time_user_first_modified_omnibox_ -
423 time_user_last_focused_on_omnibox_).InMilliseconds());
Mark P 2013/07/08 21:58:30 You might want to DCHECK that time_user_last_focus
H Fung 2013/07/09 01:09:55 I do a manual check that the time has been set now
417 autocomplete_controller()->ResetSession(); 424 autocomplete_controller()->ResetSession();
418 } 425 }
419 controller_->OnInputInProgress(in_progress); 426 controller_->OnInputInProgress(in_progress);
420 427
421 delegate_->NotifySearchTabHelper(user_input_in_progress_, !in_revert_, 428 delegate_->NotifySearchTabHelper(user_input_in_progress_, !in_revert_,
422 popup_model()->IsOpen(), user_text_.empty()); 429 popup_model()->IsOpen(), user_text_.empty());
423 } 430 }
424 431
425 void OmniboxEditModel::Revert() { 432 void OmniboxEditModel::Revert() {
426 SetInputInProgress(false); 433 SetInputInProgress(false);
(...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after
795 // since the edit contents have actually grown 802 // since the edit contents have actually grown
796 // longer. 803 // longer.
797 } else { 804 } else {
798 is_keyword_hint_ = true; 805 is_keyword_hint_ = true;
799 view_->SetWindowTextAndCaretPos(window_text.c_str(), keyword_.length(), 806 view_->SetWindowTextAndCaretPos(window_text.c_str(), keyword_.length(),
800 false, true); 807 false, true);
801 } 808 }
802 } 809 }
803 810
804 void OmniboxEditModel::OnSetFocus(bool control_down) { 811 void OmniboxEditModel::OnSetFocus(bool control_down) {
812 time_user_last_focused_on_omnibox_ = base::TimeTicks::Now();
813
805 // If the omnibox lost focus while the caret was hidden and then regained 814 // If the omnibox lost focus while the caret was hidden and then regained
806 // focus, OnSetFocus() is called and should restore visibility. Note that 815 // focus, OnSetFocus() is called and should restore visibility. Note that
807 // focus can be regained without an accompanying call to 816 // focus can be regained without an accompanying call to
808 // OmniboxView::SetFocus(), e.g. by tabbing in. 817 // OmniboxView::SetFocus(), e.g. by tabbing in.
809 SetFocusState(OMNIBOX_FOCUS_VISIBLE, OMNIBOX_FOCUS_CHANGE_EXPLICIT); 818 SetFocusState(OMNIBOX_FOCUS_VISIBLE, OMNIBOX_FOCUS_CHANGE_EXPLICIT);
810 control_key_state_ = control_down ? DOWN_WITHOUT_CHANGE : UP; 819 control_key_state_ = control_down ? DOWN_WITHOUT_CHANGE : UP;
811 820
812 if (delegate_->CurrentPageExists()) { 821 if (delegate_->CurrentPageExists()) {
813 // TODO(jered): We may want to merge this into Start() and just call that 822 // TODO(jered): We may want to merge this into Start() and just call that
814 // here rather than having a special entry point for zero-suggest. Note 823 // here rather than having a special entry point for zero-suggest. Note
(...skipping 595 matching lines...) Expand 10 before | Expand all | Expand 10 after
1410 instant->OmniboxFocusChanged(state, reason, NULL); 1419 instant->OmniboxFocusChanged(state, reason, NULL);
1411 1420
1412 // Update state and notify view if the omnibox has focus and the caret 1421 // Update state and notify view if the omnibox has focus and the caret
1413 // visibility changed. 1422 // visibility changed.
1414 const bool was_caret_visible = is_caret_visible(); 1423 const bool was_caret_visible = is_caret_visible();
1415 focus_state_ = state; 1424 focus_state_ = state;
1416 if (focus_state_ != OMNIBOX_FOCUS_NONE && 1425 if (focus_state_ != OMNIBOX_FOCUS_NONE &&
1417 is_caret_visible() != was_caret_visible) 1426 is_caret_visible() != was_caret_visible)
1418 view_->ApplyCaretVisibility(); 1427 view_->ApplyCaretVisibility();
1419 } 1428 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/omnibox/omnibox_edit_model.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698