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

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') | tools/metrics/histograms/histograms.xml » ('j') | 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 kFocusToEditTimeHistogram[] = "Omnibox.FocusToEditTime";
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 294 matching lines...) Expand 10 before | Expand all | Expand 10 after
400 url->SchemeIs(chrome::kHttpScheme) && perm_url.host() == url->host()) { 404 url->SchemeIs(chrome::kHttpScheme) && perm_url.host() == url->host()) {
401 *write_url = true; 405 *write_url = true;
402 string16 http = ASCIIToUTF16(chrome::kHttpScheme) + 406 string16 http = ASCIIToUTF16(chrome::kHttpScheme) +
403 ASCIIToUTF16(content::kStandardSchemeSeparator); 407 ASCIIToUTF16(content::kStandardSchemeSeparator);
404 if (text->compare(0, http.length(), http) != 0) 408 if (text->compare(0, http.length(), http) != 0)
405 *text = http + *text; 409 *text = http + *text;
406 } 410 }
407 } 411 }
408 412
409 void OmniboxEditModel::SetInputInProgress(bool in_progress) { 413 void OmniboxEditModel::SetInputInProgress(bool in_progress) {
414 if (in_progress && !last_omnibox_focus_without_user_input_.is_null()) {
415 base::TimeTicks now = base::TimeTicks::Now();
416 DCHECK(last_omnibox_focus_without_user_input_ <= now);
417 UMA_HISTOGRAM_TIMES(kFocusToEditTimeHistogram,
418 now - last_omnibox_focus_without_user_input_);
419 // We only want to count the time from focus to the first user input, so
420 // reset |last_omnibox_focus_without_user_input_| to null.
421 last_omnibox_focus_without_user_input_ = base::TimeTicks();
422 }
423
410 if (user_input_in_progress_ == in_progress) 424 if (user_input_in_progress_ == in_progress)
411 return; 425 return;
412 426
413 user_input_in_progress_ = in_progress; 427 user_input_in_progress_ = in_progress;
414 if (user_input_in_progress_) { 428 if (user_input_in_progress_) {
415 time_user_first_modified_omnibox_ = base::TimeTicks::Now(); 429 time_user_first_modified_omnibox_ = base::TimeTicks::Now();
416 content::RecordAction(content::UserMetricsAction("OmniboxInputInProgress")); 430 content::RecordAction(content::UserMetricsAction("OmniboxInputInProgress"));
417 autocomplete_controller()->ResetSession(); 431 autocomplete_controller()->ResetSession();
418 } 432 }
419 controller_->OnInputInProgress(in_progress); 433 controller_->OnInputInProgress(in_progress);
(...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after
795 // since the edit contents have actually grown 809 // since the edit contents have actually grown
796 // longer. 810 // longer.
797 } else { 811 } else {
798 is_keyword_hint_ = true; 812 is_keyword_hint_ = true;
799 view_->SetWindowTextAndCaretPos(window_text.c_str(), keyword_.length(), 813 view_->SetWindowTextAndCaretPos(window_text.c_str(), keyword_.length(),
800 false, true); 814 false, true);
801 } 815 }
802 } 816 }
803 817
804 void OmniboxEditModel::OnSetFocus(bool control_down) { 818 void OmniboxEditModel::OnSetFocus(bool control_down) {
819 last_omnibox_focus_without_user_input_ = base::TimeTicks::Now();
820
805 // If the omnibox lost focus while the caret was hidden and then regained 821 // If the omnibox lost focus while the caret was hidden and then regained
806 // focus, OnSetFocus() is called and should restore visibility. Note that 822 // focus, OnSetFocus() is called and should restore visibility. Note that
807 // focus can be regained without an accompanying call to 823 // focus can be regained without an accompanying call to
808 // OmniboxView::SetFocus(), e.g. by tabbing in. 824 // OmniboxView::SetFocus(), e.g. by tabbing in.
809 SetFocusState(OMNIBOX_FOCUS_VISIBLE, OMNIBOX_FOCUS_CHANGE_EXPLICIT); 825 SetFocusState(OMNIBOX_FOCUS_VISIBLE, OMNIBOX_FOCUS_CHANGE_EXPLICIT);
810 control_key_state_ = control_down ? DOWN_WITHOUT_CHANGE : UP; 826 control_key_state_ = control_down ? DOWN_WITHOUT_CHANGE : UP;
811 827
812 if (delegate_->CurrentPageExists()) { 828 if (delegate_->CurrentPageExists()) {
813 // TODO(jered): We may want to merge this into Start() and just call that 829 // 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 830 // 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); 1426 instant->OmniboxFocusChanged(state, reason, NULL);
1411 1427
1412 // Update state and notify view if the omnibox has focus and the caret 1428 // Update state and notify view if the omnibox has focus and the caret
1413 // visibility changed. 1429 // visibility changed.
1414 const bool was_caret_visible = is_caret_visible(); 1430 const bool was_caret_visible = is_caret_visible();
1415 focus_state_ = state; 1431 focus_state_ = state;
1416 if (focus_state_ != OMNIBOX_FOCUS_NONE && 1432 if (focus_state_ != OMNIBOX_FOCUS_NONE &&
1417 is_caret_visible() != was_caret_visible) 1433 is_caret_visible() != was_caret_visible)
1418 view_->ApplyCaretVisibility(); 1434 view_->ApplyCaretVisibility();
1419 } 1435 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/omnibox/omnibox_edit_model.h ('k') | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698