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

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

Issue 21452002: Add metric Omnibox.FocusToOpenTime for time from omnibox focus to omnibox usage. (Closed) Base URL: https://src.chromium.org/svn/trunk/src/
Patch Set: Created 7 years, 4 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 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 96 // Histogram name which counts the number of milliseconds a user takes
97 // between focusing and editing the omnibox. 97 // between focusing and editing the omnibox.
98 const char kFocusToEditTimeHistogram[] = "Omnibox.FocusToEditTime"; 98 const char kFocusToEditTimeHistogram[] = "Omnibox.FocusToEditTime";
99 99
100 // Histogram name which counts the number of milliseconds a user takes
101 // between focusing and opening an omnibox match.
102 const char kFocusToOpenTimeHistogram[] = "Omnibox.FocusToOpenTime";
103
100 void RecordPercentageMatchHistogram(const string16& old_text, 104 void RecordPercentageMatchHistogram(const string16& old_text,
101 const string16& new_text, 105 const string16& new_text,
102 bool search_term_replacement_active, 106 bool search_term_replacement_active,
103 content::PageTransition transition) { 107 content::PageTransition transition) {
104 size_t avg_length = (old_text.length() + new_text.length()) / 2; 108 size_t avg_length = (old_text.length() + new_text.length()) / 2;
105 109
106 int percent = 0; 110 int percent = 0;
107 if (!old_text.empty() && !new_text.empty()) { 111 if (!old_text.empty() && !new_text.empty()) {
108 size_t shorter_length = std::min(old_text.length(), new_text.length()); 112 size_t shorter_length = std::min(old_text.length(), new_text.length());
109 string16::const_iterator end(old_text.begin() + shorter_length); 113 string16::const_iterator end(old_text.begin() + shorter_length);
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 /////////////////////////////////////////////////////////////////////////////// 161 ///////////////////////////////////////////////////////////////////////////////
158 // OmniboxEditModel 162 // OmniboxEditModel
159 163
160 OmniboxEditModel::OmniboxEditModel(OmniboxView* view, 164 OmniboxEditModel::OmniboxEditModel(OmniboxView* view,
161 OmniboxEditController* controller, 165 OmniboxEditController* controller,
162 Profile* profile) 166 Profile* profile)
163 : view_(view), 167 : view_(view),
164 controller_(controller), 168 controller_(controller),
165 focus_state_(OMNIBOX_FOCUS_NONE), 169 focus_state_(OMNIBOX_FOCUS_NONE),
166 user_input_in_progress_(false), 170 user_input_in_progress_(false),
171 user_input_since_focus_(true),
Mark P 2013/08/01 23:35:16 shouldn't this be false according to the descripti
H Fung 2013/08/02 19:04:55 Revised the description. Changing to false might
167 just_deleted_text_(false), 172 just_deleted_text_(false),
168 has_temporary_text_(false), 173 has_temporary_text_(false),
169 paste_state_(NONE), 174 paste_state_(NONE),
170 control_key_state_(UP), 175 control_key_state_(UP),
171 is_keyword_hint_(false), 176 is_keyword_hint_(false),
172 profile_(profile), 177 profile_(profile),
173 in_revert_(false), 178 in_revert_(false),
174 allow_exact_keyword_match_(false) { 179 allow_exact_keyword_match_(false) {
175 omnibox_controller_.reset(new OmniboxController(this, profile)); 180 omnibox_controller_.reset(new OmniboxController(this, profile));
176 delegate_.reset(new OmniboxCurrentPageDelegateImpl(controller, profile)); 181 delegate_.reset(new OmniboxCurrentPageDelegateImpl(controller, profile));
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after
407 url->SchemeIs(chrome::kHttpScheme) && perm_url.host() == url->host()) { 412 url->SchemeIs(chrome::kHttpScheme) && perm_url.host() == url->host()) {
408 *write_url = true; 413 *write_url = true;
409 string16 http = ASCIIToUTF16(chrome::kHttpScheme) + 414 string16 http = ASCIIToUTF16(chrome::kHttpScheme) +
410 ASCIIToUTF16(content::kStandardSchemeSeparator); 415 ASCIIToUTF16(content::kStandardSchemeSeparator);
411 if (text->compare(0, http.length(), http) != 0) 416 if (text->compare(0, http.length(), http) != 0)
412 *text = http + *text; 417 *text = http + *text;
413 } 418 }
414 } 419 }
415 420
416 void OmniboxEditModel::SetInputInProgress(bool in_progress) { 421 void OmniboxEditModel::SetInputInProgress(bool in_progress) {
417 if (in_progress && !last_omnibox_focus_without_user_input_.is_null()) { 422 if (in_progress && !user_input_since_focus_) {
418 base::TimeTicks now = base::TimeTicks::Now(); 423 base::TimeTicks now = base::TimeTicks::Now();
419 DCHECK(last_omnibox_focus_without_user_input_ <= now); 424 DCHECK(last_omnibox_focus_ <= now);
420 UMA_HISTOGRAM_TIMES(kFocusToEditTimeHistogram, 425 UMA_HISTOGRAM_TIMES(kFocusToEditTimeHistogram, now - last_omnibox_focus_);
421 now - last_omnibox_focus_without_user_input_); 426 user_input_since_focus_ = true;
422 // We only want to count the time from focus to the first user input, so
423 // reset |last_omnibox_focus_without_user_input_| to null.
424 last_omnibox_focus_without_user_input_ = base::TimeTicks();
425 } 427 }
426 428
427 if (user_input_in_progress_ == in_progress) 429 if (user_input_in_progress_ == in_progress)
428 return; 430 return;
429 431
430 user_input_in_progress_ = in_progress; 432 user_input_in_progress_ = in_progress;
431 if (user_input_in_progress_) { 433 if (user_input_in_progress_) {
432 time_user_first_modified_omnibox_ = base::TimeTicks::Now(); 434 time_user_first_modified_omnibox_ = base::TimeTicks::Now();
433 content::RecordAction(content::UserMetricsAction("OmniboxInputInProgress")); 435 content::RecordAction(content::UserMetricsAction("OmniboxInputInProgress"));
434 autocomplete_controller()->ResetSession(); 436 autocomplete_controller()->ResetSession();
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
636 << "We didn't get here through the expected series of calls. " 638 << "We didn't get here through the expected series of calls. "
637 << "time_user_first_modified_omnibox_ is not set correctly and other " 639 << "time_user_first_modified_omnibox_ is not set correctly and other "
638 << "things may be wrong. Match provider: " 640 << "things may be wrong. Match provider: "
639 << (match.provider ? match.provider->GetName() : "NULL"); 641 << (match.provider ? match.provider->GetName() : "NULL");
640 DCHECK(log.elapsed_time_since_user_first_modified_omnibox >= 642 DCHECK(log.elapsed_time_since_user_first_modified_omnibox >=
641 log.elapsed_time_since_last_change_to_default_match) 643 log.elapsed_time_since_last_change_to_default_match)
642 << "We should've got the notification that the user modified the " 644 << "We should've got the notification that the user modified the "
643 << "omnibox text at same time or before the most recent time the " 645 << "omnibox text at same time or before the most recent time the "
644 << "default match changed."; 646 << "default match changed.";
645 647
648 UMA_HISTOGRAM_TIMES(kFocusToOpenTimeHistogram, now - last_omnibox_focus_);
Mark P 2013/08/01 23:35:16 I think this is more appropriate to put next to th
H Fung 2013/08/02 19:04:55 Done.
649
646 if (index != OmniboxPopupModel::kNoMatch) 650 if (index != OmniboxPopupModel::kNoMatch)
647 log.selected_index = index; 651 log.selected_index = index;
648 652
649 if ((disposition == CURRENT_TAB) && delegate_->CurrentPageExists()) { 653 if ((disposition == CURRENT_TAB) && delegate_->CurrentPageExists()) {
650 // If we know the destination is being opened in the current tab, 654 // If we know the destination is being opened in the current tab,
651 // we can easily get the tab ID. (If it's being opened in a new 655 // we can easily get the tab ID. (If it's being opened in a new
652 // tab, we don't know the tab ID yet.) 656 // tab, we don't know the tab ID yet.)
653 log.tab_id = delegate_->GetSessionID().id(); 657 log.tab_id = delegate_->GetSessionID().id();
654 } 658 }
655 autocomplete_controller()->AddProvidersInfo(&log.providers_info); 659 autocomplete_controller()->AddProvidersInfo(&log.providers_info);
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
787 // since the edit contents have actually grown 791 // since the edit contents have actually grown
788 // longer. 792 // longer.
789 } else { 793 } else {
790 is_keyword_hint_ = true; 794 is_keyword_hint_ = true;
791 view_->SetWindowTextAndCaretPos(window_text.c_str(), keyword_.length(), 795 view_->SetWindowTextAndCaretPos(window_text.c_str(), keyword_.length(),
792 false, true); 796 false, true);
793 } 797 }
794 } 798 }
795 799
796 void OmniboxEditModel::OnSetFocus(bool control_down) { 800 void OmniboxEditModel::OnSetFocus(bool control_down) {
797 last_omnibox_focus_without_user_input_ = base::TimeTicks::Now(); 801 last_omnibox_focus_ = base::TimeTicks::Now();
802 user_input_since_focus_ = false;
798 803
799 // If the omnibox lost focus while the caret was hidden and then regained 804 // If the omnibox lost focus while the caret was hidden and then regained
800 // focus, OnSetFocus() is called and should restore visibility. Note that 805 // focus, OnSetFocus() is called and should restore visibility. Note that
801 // focus can be regained without an accompanying call to 806 // focus can be regained without an accompanying call to
802 // OmniboxView::SetFocus(), e.g. by tabbing in. 807 // OmniboxView::SetFocus(), e.g. by tabbing in.
803 SetFocusState(OMNIBOX_FOCUS_VISIBLE, OMNIBOX_FOCUS_CHANGE_EXPLICIT); 808 SetFocusState(OMNIBOX_FOCUS_VISIBLE, OMNIBOX_FOCUS_CHANGE_EXPLICIT);
804 control_key_state_ = control_down ? DOWN_WITHOUT_CHANGE : UP; 809 control_key_state_ = control_down ? DOWN_WITHOUT_CHANGE : UP;
805 810
806 if (delegate_->CurrentPageExists()) { 811 if (delegate_->CurrentPageExists()) {
807 // TODO(jered): We may want to merge this into Start() and just call that 812 // TODO(jered): We may want to merge this into Start() and just call that
(...skipping 483 matching lines...) Expand 10 before | Expand all | Expand 10 after
1291 instant->OmniboxFocusChanged(state, reason, NULL); 1296 instant->OmniboxFocusChanged(state, reason, NULL);
1292 1297
1293 // Update state and notify view if the omnibox has focus and the caret 1298 // Update state and notify view if the omnibox has focus and the caret
1294 // visibility changed. 1299 // visibility changed.
1295 const bool was_caret_visible = is_caret_visible(); 1300 const bool was_caret_visible = is_caret_visible();
1296 focus_state_ = state; 1301 focus_state_ = state;
1297 if (focus_state_ != OMNIBOX_FOCUS_NONE && 1302 if (focus_state_ != OMNIBOX_FOCUS_NONE &&
1298 is_caret_visible() != was_caret_visible) 1303 is_caret_visible() != was_caret_visible)
1299 view_->ApplyCaretVisibility(); 1304 view_->ApplyCaretVisibility();
1300 } 1305 }
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