summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/browser/ui/search/instant_controller.cc39
-rw-r--r--chrome/browser/ui/search/instant_controller.h5
-rw-r--r--chrome/browser/ui/search/instant_extended_interactive_uitest.cc24
-rw-r--r--chrome/browser/ui/search/instant_page.cc1
-rw-r--r--chrome/browser/ui/search/instant_page.h4
-rw-r--r--chrome/browser/ui/search/instant_page_unittest.cc1
6 files changed, 65 insertions, 9 deletions
diff --git a/chrome/browser/ui/search/instant_controller.cc b/chrome/browser/ui/search/instant_controller.cc
index d133a68..54f27f6 100644
--- a/chrome/browser/ui/search/instant_controller.cc
+++ b/chrome/browser/ui/search/instant_controller.cc
@@ -495,8 +495,6 @@ bool InstantController::Update(const AutocompleteMatch& match,
if (UseTabForSuggestions()) {
instant_tab_->Update(user_text, selection_start, selection_end, verbatim);
} else {
- if (first_interaction_time_.is_null())
- first_interaction_time_ = base::Time::Now();
allow_overlay_to_show_search_suggestions_ = true;
overlay_->Update(extended_enabled_ ? user_text : full_text,
@@ -512,6 +510,10 @@ bool InstantController::Update(const AutocompleteMatch& match,
// suggestion or reset the existing "gray text".
browser_->SetInstantSuggestion(last_suggestion_);
+ // Record the time of the first keypress for logging histograms.
+ if (!first_interaction_time_recorded_ && first_interaction_time_.is_null())
+ first_interaction_time_ = base::Time::Now();
+
return true;
}
@@ -1339,6 +1341,31 @@ void InstantController::ShowInstantOverlay(const content::WebContents* contents,
ShowOverlay(height, units);
}
+void InstantController::LogDropdownShown() {
+ // If suggestions are being shown for the first time since the user started
+ // typing, record a histogram value.
+ if (!first_interaction_time_.is_null() && !first_interaction_time_recorded_) {
+ base::TimeDelta delta = base::Time::Now() - first_interaction_time_;
+ first_interaction_time_recorded_ = true;
+ if (search_mode_.is_origin_ntp()) {
+ UMA_HISTOGRAM_TIMES("Instant.TimeToFirstShowFromNTP", delta);
+ LOG_INSTANT_DEBUG_EVENT(this, base::StringPrintf(
+ "LogShowInstantOverlay: TimeToFirstShowFromNTP=%d",
+ static_cast<int>(delta.InMilliseconds())));
+ } else if (search_mode_.is_origin_search()) {
+ UMA_HISTOGRAM_TIMES("Instant.TimeToFirstShowFromSERP", delta);
+ LOG_INSTANT_DEBUG_EVENT(this, base::StringPrintf(
+ "LogShowInstantOverlay: TimeToFirstShowFromSERP=%d",
+ static_cast<int>(delta.InMilliseconds())));
+ } else {
+ UMA_HISTOGRAM_TIMES("Instant.TimeToFirstShowFromWeb", delta);
+ LOG_INSTANT_DEBUG_EVENT(this, base::StringPrintf(
+ "LogShowInstantOverlay: TimeToFirstShowFromWeb=%d",
+ static_cast<int>(delta.InMilliseconds())));
+ }
+ }
+}
+
void InstantController::FocusOmnibox(const content::WebContents* contents,
OmniboxFocusState state) {
if (!extended_enabled_)
@@ -1572,6 +1599,7 @@ void InstantController::HideInternal() {
// Clear the first interaction timestamp for later use.
first_interaction_time_ = base::Time();
+ first_interaction_time_recorded_ = false;
if (instant_tab_)
use_tab_for_suggestions_ = true;
@@ -1598,13 +1626,6 @@ void InstantController::ShowOverlay(int height, InstantSizeUnits units) {
return;
}
- // If the overlay is being shown for the first time since the user started
- // typing, record a histogram value.
- if (!first_interaction_time_.is_null() && model_.mode().is_default()) {
- base::TimeDelta delta = base::Time::Now() - first_interaction_time_;
- UMA_HISTOGRAM_TIMES("Instant.TimeToFirstShow", delta);
- }
-
// Show at 100% height except in the following cases:
// - The local overlay (omnibox popup) is being loaded.
// - Instant is disabled. The page needs to be able to show only a dropdown.
diff --git a/chrome/browser/ui/search/instant_controller.h b/chrome/browser/ui/search/instant_controller.h
index 0cf5aeb..ccf2bee 100644
--- a/chrome/browser/ui/search/instant_controller.h
+++ b/chrome/browser/ui/search/instant_controller.h
@@ -261,6 +261,7 @@ class InstantController : public InstantPage::Delegate,
FRIEND_TEST_ALL_PREFIXES(InstantExtendedTest, SearchProviderForLocalNTP);
FRIEND_TEST_ALL_PREFIXES(
InstantExtendedFirstTabTest, RedirectToLocalOnLoadFailure);
+ FRIEND_TEST_ALL_PREFIXES(InstantExtendedTest, LogDropdownShown);
Profile* profile() const;
InstantOverlay* overlay() const;
@@ -292,6 +293,7 @@ class InstantController : public InstantPage::Delegate,
const content::WebContents* contents,
int height,
InstantSizeUnits units) OVERRIDE;
+ virtual void LogDropdownShown() OVERRIDE;
virtual void FocusOmnibox(const content::WebContents* contents,
OmniboxFocusState state) OVERRIDE;
virtual void NavigateToURL(
@@ -505,6 +507,9 @@ class InstantController : public InstantPage::Delegate,
// overlay is showed and cleared when the overlay is hidden.
base::Time first_interaction_time_;
+ // Indicates that the first interaction time has already been logged.
+ bool first_interaction_time_recorded_;
+
// Whether to allow the overlay to show search suggestions. In general, the
// overlay is allowed to show search suggestions whenever |search_mode_| is
// MODE_SEARCH_SUGGESTIONS, except in those cases where this is false.
diff --git a/chrome/browser/ui/search/instant_extended_interactive_uitest.cc b/chrome/browser/ui/search/instant_extended_interactive_uitest.cc
index 4888629..fba9106 100644
--- a/chrome/browser/ui/search/instant_extended_interactive_uitest.cc
+++ b/chrome/browser/ui/search/instant_extended_interactive_uitest.cc
@@ -6,6 +6,9 @@
#include "base/command_line.h"
#include "base/metrics/field_trial.h"
+#include "base/metrics/histogram_base.h"
+#include "base/metrics/histogram_samples.h"
+#include "base/metrics/statistics_recorder.h"
#include "base/prefs/pref_service.h"
#include "base/string_util.h"
#include "base/stringprintf.h"
@@ -129,6 +132,17 @@ class InstantExtendedTest : public InProcessBrowserTest,
browser()->toolbar_model()->SetSupportsExtractionOfURLLikeSearchTerms(true);
}
+ int64 GetHistogramCount(const char* name) {
+ base::HistogramBase* histogram =
+ base::StatisticsRecorder::FindHistogram(name);
+ if (!histogram) {
+ // If no histogram is found, it's possible that no values have been
+ // recorded yet. Assume that the value is zero.
+ return 0;
+ }
+ return histogram->SnapshotSamples()->TotalCount();
+ }
+
std::string GetOmniboxText() {
return UTF16ToUTF8(omnibox()->GetText());
}
@@ -2365,3 +2379,13 @@ IN_PROC_BROWSER_TEST_F(InstantExtendedTest,
EXPECT_TRUE(GetIntFromJS(overlay, "onvisibilitycalls", &on_visibility_calls));
EXPECT_EQ(1, on_visibility_calls);
}
+
+// Test that if the LogDropdownShown() call records a histogram value.
+IN_PROC_BROWSER_TEST_F(InstantExtendedTest, LogDropdownShown) {
+ ASSERT_NO_FATAL_FAILURE(SetupInstant(browser()));
+ FocusOmniboxAndWaitForInstantOverlayAndNTPSupport();
+ int64 histogramValue = GetHistogramCount("Instant.TimeToFirstShowFromWeb");
+ ASSERT_TRUE(SetOmniboxTextAndWaitForOverlayToShow("a"));
+ EXPECT_EQ(histogramValue + 1,
+ GetHistogramCount("Instant.TimeToFirstShowFromWeb"));
+}
diff --git a/chrome/browser/ui/search/instant_page.cc b/chrome/browser/ui/search/instant_page.cc
index 140544a..8b53837 100644
--- a/chrome/browser/ui/search/instant_page.cc
+++ b/chrome/browser/ui/search/instant_page.cc
@@ -260,6 +260,7 @@ void InstantPage::OnShowInstantOverlay(int page_id,
InstantSizeUnits units) {
if (contents()->IsActiveEntry(page_id)) {
OnInstantSupportDetermined(page_id, true);
+ delegate_->LogDropdownShown();
if (ShouldProcessShowInstantOverlay())
delegate_->ShowInstantOverlay(contents(), height, units);
}
diff --git a/chrome/browser/ui/search/instant_page.h b/chrome/browser/ui/search/instant_page.h
index e85aec5..7dbdb59 100644
--- a/chrome/browser/ui/search/instant_page.h
+++ b/chrome/browser/ui/search/instant_page.h
@@ -68,6 +68,10 @@ class InstantPage : public content::WebContentsObserver {
int height,
InstantSizeUnits units) = 0;
+ // Called when the page shows suggestions for logging purposes, regardless
+ // of whether the page is processing the call.
+ virtual void LogDropdownShown() = 0;
+
// Called when the page wants the omnibox to be focused. |state| specifies
// the omnibox focus state.
virtual void FocusOmnibox(const content::WebContents* contents,
diff --git a/chrome/browser/ui/search/instant_page_unittest.cc b/chrome/browser/ui/search/instant_page_unittest.cc
index 6f831fe..797d9d2 100644
--- a/chrome/browser/ui/search/instant_page_unittest.cc
+++ b/chrome/browser/ui/search/instant_page_unittest.cc
@@ -39,6 +39,7 @@ class FakePageDelegate : public InstantPage::Delegate {
void(const content::WebContents* contents,
int height,
InstantSizeUnits units));
+ MOCK_METHOD0(LogDropdownShown, void());
MOCK_METHOD2(FocusOmnibox,
void(const content::WebContents* contents,
OmniboxFocusState state));