Home | History | Annotate | Download | only in omnibox
      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 "chrome/browser/autocomplete/autocomplete_input.h"
     13 #include "chrome/browser/autocomplete/autocomplete_provider.h"
     14 #include "chrome/browser/sessions/session_id.h"
     15 
     16 class AutocompleteResult;
     17 
     18 // The data to log (via the metrics service) when the user selects an item from
     19 // the omnibox popup.
     20 struct OmniboxLog {
     21   OmniboxLog(
     22       const base::string16& text,
     23       bool just_deleted_text,
     24       AutocompleteInput::Type input_type,
     25       size_t selected_index,
     26       SessionID::id_type tab_id,
     27       AutocompleteInput::PageClassification current_page_classification,
     28       base::TimeDelta elapsed_time_since_user_first_modified_omnibox,
     29       size_t completed_length,
     30       base::TimeDelta elapsed_time_since_last_change_to_default_match,
     31       const AutocompleteResult& result);
     32   ~OmniboxLog();
     33 
     34   // The user's input text in the omnibox.
     35   base::string16 text;
     36 
     37   // Whether the user deleted text immediately before selecting an omnibox
     38   // suggestion.  This is usually the result of pressing backspace or delete.
     39   bool just_deleted_text;
     40 
     41   // The detected type of the user's input.
     42   AutocompleteInput::Type input_type;
     43 
     44   // Selected index (if selected) or -1 (OmniboxPopupModel::kNoMatch).
     45   size_t selected_index;
     46 
     47   // ID of the tab the selected autocomplete suggestion was opened in.
     48   // Set to -1 if we haven't yet determined the destination tab.
     49   SessionID::id_type tab_id;
     50 
     51   // The type of page (e.g., new tab page, regular web page) that the
     52   // user was viewing before going somewhere with the omnibox.
     53   AutocompleteInput::PageClassification current_page_classification;
     54 
     55   // The amount of time since the user first began modifying the text
     56   // in the omnibox.  If at some point after modifying the text, the
     57   // user reverts the modifications (thus seeing the current web
     58   // page's URL again), then writes in the omnibox again, this time
     59   // delta should be computed starting from the second series of
     60   // modifications.  If we somehow skipped the logic to record
     61   // the time the user began typing (this should only happen in
     62   // unit tests), this elapsed time is set to -1 milliseconds.
     63   base::TimeDelta elapsed_time_since_user_first_modified_omnibox;
     64 
     65   // The number of extra characters the user would have to manually type
     66   // if she/he were not given the opportunity to select this match.  Set to
     67   // base::string16::npos if not available.
     68   size_t completed_length;
     69 
     70   // The amount of time since the last time the default (i.e., inline)
     71   // match changed.  This will certainly be less than
     72   // elapsed_time_since_user_first_modified_omnibox.
     73   base::TimeDelta elapsed_time_since_last_change_to_default_match;
     74 
     75   // Result set.
     76   const AutocompleteResult& result;
     77 
     78   // Diagnostic information from providers.  See
     79   // AutocompleteController::AddProvidersInfo() and
     80   // AutocompleteProvider::AddProviderInfo() above.
     81   ProvidersInfo providers_info;
     82 };
     83 
     84 #endif  // CHROME_BROWSER_OMNIBOX_OMNIBOX_LOG_H_
     85