summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsamarth@chromium.org <samarth@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-08-07 03:22:32 +0000
committersamarth@chromium.org <samarth@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-08-07 03:22:32 +0000
commita93406d0d1cbb03d67a2e1fd572003e9da018b09 (patch)
tree668710e4d9b6cc5d4b30e72acd849d233723beec
parent8336c291fa6fbc50e2e49da78d8cfcc1ebb47ae8 (diff)
downloadchromium_src-a93406d0d1cbb03d67a2e1fd572003e9da018b09.zip
chromium_src-a93406d0d1cbb03d67a2e1fd572003e9da018b09.tar.gz
chromium_src-a93406d0d1cbb03d67a2e1fd572003e9da018b09.tar.bz2
InstantExtended: record initial focus state for omnibox interactions.
Keep track of whether omnibox was visibly or invisibly focused when user first started typing and record that state in OmniboxLog. BUG=264069 R=isherman@chromium.org, mpearson@chromium.org, pkasting@chromium.org Review URL: https://codereview.chromium.org/20587003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@216067 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/autocomplete/autocomplete_input.h9
-rw-r--r--chrome/browser/metrics/metrics_log.cc8
-rw-r--r--chrome/browser/ui/omnibox/omnibox_edit_model.cc35
-rw-r--r--chrome/browser/ui/omnibox/omnibox_edit_model.h17
-rw-r--r--chrome/common/metrics/proto/omnibox_event.proto9
5 files changed, 64 insertions, 14 deletions
diff --git a/chrome/browser/autocomplete/autocomplete_input.h b/chrome/browser/autocomplete/autocomplete_input.h
index 0070872..0ebc17d 100644
--- a/chrome/browser/autocomplete/autocomplete_input.h
+++ b/chrome/browser/autocomplete/autocomplete_input.h
@@ -58,11 +58,16 @@ class AutocompleteInput {
// Note that if the homepage is set to the new tab page or about blank,
// then we'll classify the web page into those categories, not HOMEPAGE.
OTHER = 4, // everything not included somewhere else on this list
- INSTANT_NEW_TAB_PAGE = 5, // new tab page rendered by Instant
// The user is on a search result page that's doing search term
// replacement, meaning the search terms should've appeared in the omnibox
// before the user started editing it, not the URL of the page.
- SEARCH_RESULT_PAGE_DOING_SEARCH_TERM_REPLACEMENT = 6
+ SEARCH_RESULT_PAGE_DOING_SEARCH_TERM_REPLACEMENT = 6,
+ // The new tab page in which this omnibox interaction first started
+ // with the user having focus in the omnibox.
+ INSTANT_NEW_TAB_PAGE_WITH_OMNIBOX_AS_STARTING_FOCUS = 7,
+ // The new tab page in which this omnibox interaction first started
+ // with the user having focus in the fakebox.
+ INSTANT_NEW_TAB_PAGE_WITH_FAKEBOX_AS_STARTING_FOCUS = 8,
};
AutocompleteInput();
diff --git a/chrome/browser/metrics/metrics_log.cc b/chrome/browser/metrics/metrics_log.cc
index 89ff359..bb9d550 100644
--- a/chrome/browser/metrics/metrics_log.cc
+++ b/chrome/browser/metrics/metrics_log.cc
@@ -154,11 +154,15 @@ OmniboxEventProto::PageClassification AsOmniboxEventPageClassification(
return OmniboxEventProto::HOMEPAGE;
case AutocompleteInput::OTHER:
return OmniboxEventProto::OTHER;
- case AutocompleteInput::INSTANT_NEW_TAB_PAGE:
- return OmniboxEventProto::INSTANT_NEW_TAB_PAGE;
case AutocompleteInput::SEARCH_RESULT_PAGE_DOING_SEARCH_TERM_REPLACEMENT:
return OmniboxEventProto::
SEARCH_RESULT_PAGE_DOING_SEARCH_TERM_REPLACEMENT;
+ case AutocompleteInput::INSTANT_NEW_TAB_PAGE_WITH_OMNIBOX_AS_STARTING_FOCUS:
+ return OmniboxEventProto::
+ INSTANT_NEW_TAB_PAGE_WITH_OMNIBOX_AS_STARTING_FOCUS;
+ case AutocompleteInput::INSTANT_NEW_TAB_PAGE_WITH_FAKEBOX_AS_STARTING_FOCUS:
+ return OmniboxEventProto::
+ INSTANT_NEW_TAB_PAGE_WITH_FAKEBOX_AS_STARTING_FOCUS;
}
return OmniboxEventProto::INVALID_SPEC;
}
diff --git a/chrome/browser/ui/omnibox/omnibox_edit_model.cc b/chrome/browser/ui/omnibox/omnibox_edit_model.cc
index ed4e44c..b4c9087 100644
--- a/chrome/browser/ui/omnibox/omnibox_edit_model.cc
+++ b/chrome/browser/ui/omnibox/omnibox_edit_model.cc
@@ -146,13 +146,15 @@ OmniboxEditModel::State::State(bool user_input_in_progress,
const string16& gray_text,
const string16& keyword,
bool is_keyword_hint,
- OmniboxFocusState focus_state)
+ OmniboxFocusState focus_state,
+ FocusSource focus_source)
: user_input_in_progress(user_input_in_progress),
user_text(user_text),
gray_text(gray_text),
keyword(keyword),
is_keyword_hint(is_keyword_hint),
- focus_state(focus_state) {
+ focus_state(focus_state),
+ focus_source(focus_source) {
}
OmniboxEditModel::State::~State() {
@@ -167,6 +169,7 @@ OmniboxEditModel::OmniboxEditModel(OmniboxView* view,
: view_(view),
controller_(controller),
focus_state_(OMNIBOX_FOCUS_NONE),
+ focus_source_(INVALID),
user_input_in_progress_(false),
user_input_since_focus_(true),
just_deleted_text_(false),
@@ -207,11 +210,13 @@ const OmniboxEditModel::State OmniboxEditModel::GetStateForTabSwitch() {
view_->GetGrayTextAutocompletion(),
keyword_,
is_keyword_hint_,
- focus_state_);
+ focus_state_,
+ focus_source_);
}
void OmniboxEditModel::RestoreState(const State& state) {
SetFocusState(state.focus_state, OMNIBOX_FOCUS_CHANGE_TAB_SWITCH);
+ focus_source_ = state.focus_source;
// Restore any user editing.
if (state.user_input_in_progress) {
// NOTE: Be sure and set keyword-related state BEFORE invoking
@@ -849,6 +854,7 @@ void OmniboxEditModel::OnKillFocus() {
// OmniboxFocusChanged() from OnWillKillFocus() to here, which would let us
// just call SetFocusState() to handle the state change.
focus_state_ = OMNIBOX_FOCUS_NONE;
+ focus_source_ = INVALID;
control_key_state_ = UP;
paste_state_ = NONE;
}
@@ -1022,10 +1028,18 @@ bool OmniboxEditModel::OnAfterPossibleChange(const string16& old_text,
else if (text_differs)
paste_state_ = NONE;
- // Restore caret visibility whenever the user changes text or selection in the
- // omnibox.
- if (text_differs || selection_differs)
+ if (text_differs || selection_differs) {
+ // Record current focus state for this input if we haven't already.
+ DCHECK_NE(OMNIBOX_FOCUS_NONE, focus_state_);
+ if (focus_source_ == INVALID) {
+ focus_source_ = (focus_state_ == OMNIBOX_FOCUS_VISIBLE) ?
+ OMNIBOX : FAKEBOX;
+ }
+
+ // Restore caret visibility whenever the user changes text or selection in
+ // the omnibox.
SetFocusState(OMNIBOX_FOCUS_VISIBLE, OMNIBOX_FOCUS_CHANGE_TYPING);
+ }
// Modifying the selection counts as accepting the autocompleted text.
const bool user_text_changed =
@@ -1260,8 +1274,13 @@ bool OmniboxEditModel::IsSpaceCharForAcceptingKeyword(wchar_t c) {
AutocompleteInput::PageClassification OmniboxEditModel::ClassifyPage() const {
if (!delegate_->CurrentPageExists())
return AutocompleteInput::OTHER;
- if (delegate_->IsInstantNTP())
- return AutocompleteInput::INSTANT_NEW_TAB_PAGE;
+ if (delegate_->IsInstantNTP()) {
+ // Note that we treat OMNIBOX as the source if focus_source_ is INVALID,
+ // i.e., if input isn't actually in progress.
+ return (focus_source_ == FAKEBOX) ?
+ AutocompleteInput::INSTANT_NEW_TAB_PAGE_WITH_FAKEBOX_AS_STARTING_FOCUS :
+ AutocompleteInput::INSTANT_NEW_TAB_PAGE_WITH_OMNIBOX_AS_STARTING_FOCUS;
+ }
const GURL& gurl = delegate_->GetURL();
if (!gurl.is_valid())
return AutocompleteInput::INVALID_SPEC;
diff --git a/chrome/browser/ui/omnibox/omnibox_edit_model.h b/chrome/browser/ui/omnibox/omnibox_edit_model.h
index c2f780d..afc9be7 100644
--- a/chrome/browser/ui/omnibox/omnibox_edit_model.h
+++ b/chrome/browser/ui/omnibox/omnibox_edit_model.h
@@ -43,13 +43,22 @@ enum EnteredKeywordModeMethod {
class OmniboxEditModel {
public:
+ // Did the Omnibox focus originate via the user clicking on the Omnibox or on
+ // the Fakebox?
+ enum FocusSource {
+ INVALID = 0,
+ OMNIBOX = 1,
+ FAKEBOX = 2
+ };
+
struct State {
State(bool user_input_in_progress,
const string16& user_text,
const string16& gray_text,
const string16& keyword,
bool is_keyword_hint,
- OmniboxFocusState focus_state);
+ OmniboxFocusState focus_state,
+ FocusSource focus_source);
~State();
bool user_input_in_progress;
@@ -58,6 +67,7 @@ class OmniboxEditModel {
const string16 keyword;
const bool is_keyword_hint;
OmniboxFocusState focus_state;
+ FocusSource focus_source;
};
OmniboxEditModel(OmniboxView* view,
@@ -410,6 +420,11 @@ class OmniboxEditModel {
OmniboxFocusState focus_state_;
+ // Used to keep track whether the input currently in progress originated by
+ // focusing in the Omnibox or in the Fakebox. This will be INVALID if no input
+ // is in progress or the Omnibox is not focused.
+ FocusSource focus_source_;
+
// The URL of the currently displayed page.
string16 permanent_text_;
diff --git a/chrome/common/metrics/proto/omnibox_event.proto b/chrome/common/metrics/proto/omnibox_event.proto
index cd1ee8ef8..4bd5dd1 100644
--- a/chrome/common/metrics/proto/omnibox_event.proto
+++ b/chrome/common/metrics/proto/omnibox_event.proto
@@ -73,11 +73,18 @@ message OmniboxEventProto {
// Note that if the homepage is set to the new tab page or about blank,
// then we'll classify the web page into those categories, not HOMEPAGE.
OTHER = 4; // everything not included somewhere else on this list
- INSTANT_NEW_TAB_PAGE = 5; // new tab page rendered by Instant
+ // The instant new tab page enum value was deprecated on August 2, 2013.
+ OBSOLETE_INSTANT_NEW_TAB_PAGE = 5;
// The user is on a search result page that's doing search term
// replacement, meaning the search terms should've appeared in the omnibox
// before the user started editing it, not the URL of the page.
SEARCH_RESULT_PAGE_DOING_SEARCH_TERM_REPLACEMENT = 6;
+ // The new tab page in which this omnibox interaction first started
+ // with the user having focus in the omnibox.
+ INSTANT_NEW_TAB_PAGE_WITH_OMNIBOX_AS_STARTING_FOCUS = 7;
+ // The new tab page in which this omnibox interaction first started
+ // with the user having focus in the fakebox.
+ INSTANT_NEW_TAB_PAGE_WITH_FAKEBOX_AS_STARTING_FOCUS = 8;
}
optional PageClassification current_page_classification = 10;