diff options
author | macourteau@chromium.org <macourteau@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-12-16 20:02:49 +0000 |
---|---|---|
committer | macourteau@chromium.org <macourteau@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-12-16 20:02:49 +0000 |
commit | 14ac349b7012f9f6485d4b4f22d9df4655e02002 (patch) | |
tree | 7689d45aeec7e3c47a9e63f98702399238fa0525 | |
parent | b2cefdba36878c6f557358771d01a0a4dcab5fb9 (diff) | |
download | chromium_src-14ac349b7012f9f6485d4b4f22d9df4655e02002.zip chromium_src-14ac349b7012f9f6485d4b4f22d9df4655e02002.tar.gz chromium_src-14ac349b7012f9f6485d4b4f22d9df4655e02002.tar.bz2 |
Adds UMA stats for the search button in omnibox experiment.
BUG=304859, 315944
TBR=pkasting@chromium.org
Review URL: https://codereview.chromium.org/115593002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@240989 0039d316-1c4b-4281-b951-d872f2087c98
12 files changed, 75 insertions, 20 deletions
diff --git a/chrome/browser/ui/cocoa/omnibox/omnibox_view_mac.h b/chrome/browser/ui/cocoa/omnibox/omnibox_view_mac.h index becf719..35b8484 100644 --- a/chrome/browser/ui/cocoa/omnibox/omnibox_view_mac.h +++ b/chrome/browser/ui/cocoa/omnibox/omnibox_view_mac.h @@ -63,7 +63,8 @@ class OmniboxViewMac : public OmniboxView, virtual gfx::NativeView GetRelativeWindowForPopup() const OVERRIDE; virtual void SetGrayTextAutocompletion(const base::string16& input) OVERRIDE; virtual base::string16 GetGrayTextAutocompletion() const OVERRIDE; - virtual int TextWidth() const OVERRIDE; + virtual int GetTextWidth() const OVERRIDE; + virtual int GetWidth() const OVERRIDE; virtual bool IsImeComposing() const OVERRIDE; // Implement the AutocompleteTextFieldObserver interface. diff --git a/chrome/browser/ui/cocoa/omnibox/omnibox_view_mac.mm b/chrome/browser/ui/cocoa/omnibox/omnibox_view_mac.mm index f232fe6..08a501e 100644 --- a/chrome/browser/ui/cocoa/omnibox/omnibox_view_mac.mm +++ b/chrome/browser/ui/cocoa/omnibox/omnibox_view_mac.mm @@ -614,12 +614,16 @@ base::string16 OmniboxViewMac::GetGrayTextAutocompletion() const { return suggest_text_; } -int OmniboxViewMac::TextWidth() const { +int OmniboxViewMac::GetTextWidth() const { // Not used on mac. NOTREACHED(); return 0; } +int OmniboxViewMac::GetWidth() const { + return ceil([field_ bounds].size.width); +} + bool OmniboxViewMac::IsImeComposing() const { return [(NSTextView*)[field_ currentEditor] hasMarkedText]; } diff --git a/chrome/browser/ui/gtk/location_bar_view_gtk.cc b/chrome/browser/ui/gtk/location_bar_view_gtk.cc index 4d9aa01..ddcd343 100644 --- a/chrome/browser/ui/gtk/location_bar_view_gtk.cc +++ b/chrome/browser/ui/gtk/location_bar_view_gtk.cc @@ -1450,7 +1450,7 @@ void LocationBarViewGtk::ShowZoomBubble() { } void LocationBarViewGtk::AdjustChildrenVisibility() { - int text_width = omnibox_view_->TextWidth(); + int text_width = omnibox_view_->GetTextWidth(); int available_width = entry_box_width_ - text_width - InnerPadding(); // Only one of |tab_to_search_alignment_| and |tab_to_search_hint_| can be diff --git a/chrome/browser/ui/gtk/omnibox/omnibox_view_gtk.cc b/chrome/browser/ui/gtk/omnibox/omnibox_view_gtk.cc index e7474d5..dbb69c0 100644 --- a/chrome/browser/ui/gtk/omnibox/omnibox_view_gtk.cc +++ b/chrome/browser/ui/gtk/omnibox/omnibox_view_gtk.cc @@ -720,7 +720,7 @@ base::string16 OmniboxViewGtk::GetGrayTextAutocompletion() const { return suggestion ? UTF8ToUTF16(suggestion) : base::string16(); } -int OmniboxViewGtk::TextWidth() const { +int OmniboxViewGtk::GetTextWidth() const { // TextWidth may be called after gtk widget tree is destroyed but // before OmniboxViewGtk gets deleted. This is a safe guard // to avoid accessing |text_view_| that has already been destroyed. @@ -765,6 +765,12 @@ int OmniboxViewGtk::TextWidth() const { return text_width + horizontal_border_size; } +int OmniboxViewGtk::GetWidth() const { + GtkAllocation allocation; + gtk_widget_get_allocation(text_view_, &allocation); + return allocation.width; +} + bool OmniboxViewGtk::IsImeComposing() const { return supports_pre_edit_ && !pre_edit_.empty(); } diff --git a/chrome/browser/ui/gtk/omnibox/omnibox_view_gtk.h b/chrome/browser/ui/gtk/omnibox/omnibox_view_gtk.h index 1643781..257f190 100644 --- a/chrome/browser/ui/gtk/omnibox/omnibox_view_gtk.h +++ b/chrome/browser/ui/gtk/omnibox/omnibox_view_gtk.h @@ -101,7 +101,8 @@ class OmniboxViewGtk : public OmniboxView, virtual void SetGrayTextAutocompletion( const base::string16& suggestion) OVERRIDE; virtual base::string16 GetGrayTextAutocompletion() const OVERRIDE; - virtual int TextWidth() const OVERRIDE; + virtual int GetTextWidth() const OVERRIDE; + virtual int GetWidth() const OVERRIDE; virtual bool IsImeComposing() const OVERRIDE; // Overridden from content::NotificationObserver: diff --git a/chrome/browser/ui/omnibox/omnibox_edit_model.cc b/chrome/browser/ui/omnibox/omnibox_edit_model.cc index cdc2769..5155d72 100644 --- a/chrome/browser/ui/omnibox/omnibox_edit_model.cc +++ b/chrome/browser/ui/omnibox/omnibox_edit_model.cc @@ -10,6 +10,7 @@ #include "base/format_macros.h" #include "base/metrics/histogram.h" #include "base/prefs/pref_service.h" +#include "base/strings/string_number_conversions.h" #include "base/strings/string_util.h" #include "base/strings/stringprintf.h" #include "base/strings/utf_string_conversions.h" @@ -106,10 +107,15 @@ const char kFocusToEditTimeHistogram[] = "Omnibox.FocusToEditTime"; // between focusing and opening an omnibox match. const char kFocusToOpenTimeHistogram[] = "Omnibox.FocusToOpenTime"; +// Split the percentage match histograms into buckets based on the width of the +// omnibox. +const int kPercentageMatchHistogramWidthBuckets[] = { 400, 700, 1200 }; + void RecordPercentageMatchHistogram(const base::string16& old_text, const base::string16& new_text, bool url_replacement_active, - content::PageTransition transition) { + content::PageTransition transition, + int omnibox_width) { size_t avg_length = (old_text.length() + new_text.length()) / 2; int percent = 0; @@ -122,23 +128,40 @@ void RecordPercentageMatchHistogram(const base::string16& old_text, percent = static_cast<float>(matching_characters) / avg_length * 100; } + std::string histogram_name; if (url_replacement_active) { if (transition == content::PAGE_TRANSITION_TYPED) { - UMA_HISTOGRAM_PERCENTAGE( - "InstantExtended.PercentageMatchV2_QuerytoURL", percent); + histogram_name = "InstantExtended.PercentageMatchV2_QuerytoURL"; + UMA_HISTOGRAM_PERCENTAGE(histogram_name, percent); } else { - UMA_HISTOGRAM_PERCENTAGE( - "InstantExtended.PercentageMatchV2_QuerytoQuery", percent); + histogram_name = "InstantExtended.PercentageMatchV2_QuerytoQuery"; + UMA_HISTOGRAM_PERCENTAGE(histogram_name, percent); } } else { if (transition == content::PAGE_TRANSITION_TYPED) { - UMA_HISTOGRAM_PERCENTAGE( - "InstantExtended.PercentageMatchV2_URLtoURL", percent); + histogram_name = "InstantExtended.PercentageMatchV2_URLtoURL"; + UMA_HISTOGRAM_PERCENTAGE(histogram_name, percent); } else { - UMA_HISTOGRAM_PERCENTAGE( - "InstantExtended.PercentageMatchV2_URLtoQuery", percent); + histogram_name = "InstantExtended.PercentageMatchV2_URLtoQuery"; + UMA_HISTOGRAM_PERCENTAGE(histogram_name, percent); + } + } + + std::string suffix = "large"; + for (size_t i = 0; i < arraysize(kPercentageMatchHistogramWidthBuckets); + ++i) { + if (omnibox_width < kPercentageMatchHistogramWidthBuckets[i]) { + suffix = base::IntToString(kPercentageMatchHistogramWidthBuckets[i]); + break; } } + + // Cannot rely on UMA histograms macro because the name of the histogram is + // generated dynamically. + base::HistogramBase* counter = base::LinearHistogram::FactoryGet( + histogram_name + "_" + suffix, 1, 101, 102, + base::Histogram::kUmaTargetedHistogramFlag); + counter->Add(percent); } } // namespace @@ -785,7 +808,7 @@ void OmniboxEditModel::OpenMatch(AutocompleteMatch match, RecordPercentageMatchHistogram( permanent_text_, current_text, controller_->GetToolbarModel()->WouldReplaceURL(), - match.transition); + match.transition, view_->GetWidth()); // Track whether the destination URL sends us to a search results page // using the default search provider. diff --git a/chrome/browser/ui/omnibox/omnibox_edit_unittest.cc b/chrome/browser/ui/omnibox/omnibox_edit_unittest.cc index 43c3b80..816361c 100644 --- a/chrome/browser/ui/omnibox/omnibox_edit_unittest.cc +++ b/chrome/browser/ui/omnibox/omnibox_edit_unittest.cc @@ -78,7 +78,8 @@ class TestingOmniboxView : public OmniboxView { virtual base::string16 GetGrayTextAutocompletion() const OVERRIDE { return base::string16(); } - virtual int TextWidth() const OVERRIDE { return 0; } + virtual int GetTextWidth() const OVERRIDE { return 0; } + virtual int GetWidth() const OVERRIDE { return 0; } virtual bool IsImeComposing() const OVERRIDE { return false; } #if defined(TOOLKIT_VIEWS) virtual int OnPerformDrop(const ui::DropTargetEvent& event) OVERRIDE { diff --git a/chrome/browser/ui/omnibox/omnibox_view.h b/chrome/browser/ui/omnibox/omnibox_view.h index c723491..b4702af 100644 --- a/chrome/browser/ui/omnibox/omnibox_view.h +++ b/chrome/browser/ui/omnibox/omnibox_view.h @@ -212,7 +212,10 @@ class OmniboxView { // Returns the width in pixels needed to display the current text. The // returned value includes margins. - virtual int TextWidth() const = 0; + virtual int GetTextWidth() const = 0; + + // Returns the omnibox's width in pixels. + virtual int GetWidth() const = 0; // Returns true if the user is composing something in an IME. virtual bool IsImeComposing() const = 0; diff --git a/chrome/browser/ui/views/location_bar/location_bar_view.cc b/chrome/browser/ui/views/location_bar/location_bar_view.cc index 4b80b09..da8c68b8 100644 --- a/chrome/browser/ui/views/location_bar/location_bar_view.cc +++ b/chrome/browser/ui/views/location_bar/location_bar_view.cc @@ -829,7 +829,7 @@ void LocationBarView::Layout() { leading_decorations.LayoutPass2(&entry_width); trailing_decorations.LayoutPass2(&entry_width); - int location_needed_width = omnibox_view_->TextWidth(); + int location_needed_width = omnibox_view_->GetTextWidth(); int available_width = entry_width - location_needed_width; // The bounds must be wide enough for all the decorations to fit. gfx::Rect location_bounds( diff --git a/chrome/browser/ui/views/omnibox/omnibox_view_views.cc b/chrome/browser/ui/views/omnibox/omnibox_view_views.cc index aed0598..76ca039 100644 --- a/chrome/browser/ui/views/omnibox/omnibox_view_views.cc +++ b/chrome/browser/ui/views/omnibox/omnibox_view_views.cc @@ -666,10 +666,14 @@ base::string16 OmniboxViewViews::GetGrayTextAutocompletion() const { #endif } -int OmniboxViewViews::TextWidth() const { +int OmniboxViewViews::GetTextWidth() const { return native_wrapper_->GetWidthNeededForText(); } +int OmniboxViewViews::GetWidth() const { + return location_bar_view_->width(); +} + bool OmniboxViewViews::IsImeComposing() const { return IsIMEComposing(); } diff --git a/chrome/browser/ui/views/omnibox/omnibox_view_views.h b/chrome/browser/ui/views/omnibox/omnibox_view_views.h index 7ae21a0..edae008 100644 --- a/chrome/browser/ui/views/omnibox/omnibox_view_views.h +++ b/chrome/browser/ui/views/omnibox/omnibox_view_views.h @@ -106,7 +106,8 @@ class OmniboxViewViews virtual gfx::NativeView GetRelativeWindowForPopup() const OVERRIDE; virtual void SetGrayTextAutocompletion(const base::string16& input) OVERRIDE; virtual base::string16 GetGrayTextAutocompletion() const OVERRIDE; - virtual int TextWidth() const OVERRIDE; + virtual int GetTextWidth() const OVERRIDE; + virtual int GetWidth() const OVERRIDE; virtual bool IsImeComposing() const OVERRIDE; virtual bool IsImeShowingPopup() const OVERRIDE; virtual int OnPerformDrop(const ui::DropTargetEvent& event) OVERRIDE; diff --git a/tools/metrics/histograms/histograms.xml b/tools/metrics/histograms/histograms.xml index 40d4375..5a5a8ab 100644 --- a/tools/metrics/histograms/histograms.xml +++ b/tools/metrics/histograms/histograms.xml @@ -31587,6 +31587,17 @@ other types of suffix sets. <affected-histogram name="Instant.SessionsStorageNamespace"/> </fieldtrial> +<fieldtrial name="InstantExtended_QuerytoQuery"> + <group name="400" label="Omnibox width < 400"/> + <group name="700" label="Omnibox width < 700"/> + <group name="1200" label="Omnibox width < 1200"/> + <group name="large" label="Omnibox width >= 1200"/> + <affected-histogram name="InstantExtended.PercentageMatchV2_QuerytoQuery"/> + <affected-histogram name="InstantExtended.PercentageMatchV2_QuerytoURL"/> + <affected-histogram name="InstantExtended.PercentageMatchV2_URLtoQuery"/> + <affected-histogram name="InstantExtended.PercentageMatchV2_URLtoURL"/> +</fieldtrial> + <fieldtrial name="Interval" separator="_"> <group name="Interval" label="Interval between two consecutive connects is"/> <affected-histogram name="Net.TCP_Connection_Latency"/> |