1 // Copyright 2013 The Chromium Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #ifndef CHROME_BROWSER_OMNIBOX_OMNIBOX_LOG_H_ 6 #define CHROME_BROWSER_OMNIBOX_OMNIBOX_LOG_H_ 7 8 #include <stddef.h> 9 10 #include "base/strings/string16.h" 11 #include "base/time/time.h" 12 #include "components/metrics/proto/omnibox_event.pb.h" 13 #include "components/metrics/proto/omnibox_input_type.pb.h" 14 #include "components/omnibox/autocomplete_provider.h" 15 #include "components/sessions/session_id.h" 16 17 class AutocompleteResult; 18 19 // The data to log (via the metrics service) when the user selects an item from 20 // the omnibox popup. 21 struct OmniboxLog { 22 OmniboxLog( 23 const base::string16& text, 24 bool just_deleted_text, 25 metrics::OmniboxInputType::Type input_type, 26 bool is_popup_open, 27 size_t selected_index, 28 bool is_paste_and_go, 29 SessionID::id_type tab_id, 30 metrics::OmniboxEventProto::PageClassification 31 current_page_classification, 32 base::TimeDelta elapsed_time_since_user_first_modified_omnibox, 33 size_t completed_length, 34 base::TimeDelta elapsed_time_since_last_change_to_default_match, 35 const AutocompleteResult& result); 36 ~OmniboxLog(); 37 38 // The user's input text in the omnibox. 39 base::string16 text; 40 41 // Whether the user deleted text immediately before selecting an omnibox 42 // suggestion. This is usually the result of pressing backspace or delete. 43 bool just_deleted_text; 44 45 // The detected type of the user's input. 46 metrics::OmniboxInputType::Type input_type; 47 48 // True if the popup is open. 49 bool is_popup_open; 50 51 // The index of the item selected in the dropdown list. Set to 0 if the 52 // dropdown is closed (and therefore there is only one implicit suggestion). 53 size_t selected_index; 54 55 // True if this is a paste-and-search or paste-and-go omnibox interaction. 56 // (The codebase refers to both these types as paste-and-go.) 57 bool is_paste_and_go; 58 59 // ID of the tab the selected autocomplete suggestion was opened in. 60 // Set to -1 if we haven't yet determined the destination tab. 61 SessionID::id_type tab_id; 62 63 // The type of page (e.g., new tab page, regular web page) that the 64 // user was viewing before going somewhere with the omnibox. 65 metrics::OmniboxEventProto::PageClassification current_page_classification; 66 67 // The amount of time since the user first began modifying the text 68 // in the omnibox. If at some point after modifying the text, the 69 // user reverts the modifications (thus seeing the current web 70 // page's URL again), then writes in the omnibox again, this time 71 // delta should be computed starting from the second series of 72 // modifications. If we somehow skipped the logic to record 73 // the time the user began typing (this should only happen in 74 // unit tests), this elapsed time is set to -1 milliseconds. 75 base::TimeDelta elapsed_time_since_user_first_modified_omnibox; 76 77 // The number of extra characters the user would have to manually type 78 // if she/he were not given the opportunity to select this match. Only 79 // set for matches that are allowed to be the default match (i.e., are 80 // inlineable). Set to base::string16::npos if the match is not allowed 81 // to be the default match. 82 size_t completed_length; 83 84 // The amount of time since the last time the default (i.e., inline) 85 // match changed. This will certainly be less than 86 // elapsed_time_since_user_first_modified_omnibox. Measuring this 87 // may be inappropriate in some cases (e.g., if editing is not in 88 // progress). In such cases, it's set to -1 milliseconds. 89 base::TimeDelta elapsed_time_since_last_change_to_default_match; 90 91 // Result set. 92 const AutocompleteResult& result; 93 94 // Diagnostic information from providers. See 95 // AutocompleteController::AddProvidersInfo() and 96 // AutocompleteProvider::AddProviderInfo() above. 97 ProvidersInfo providers_info; 98 }; 99 100 #endif // CHROME_BROWSER_OMNIBOX_OMNIBOX_LOG_H_ 101