Index: chrome/browser/google/google_util.cc |
diff --git a/chrome/browser/google/google_util.cc b/chrome/browser/google/google_util.cc |
index f4d06810d7ef4a5eabb3f469bf102ff2a6bd9439..e355f49a580828100b519310d56b615394bc4d15 100644 |
--- a/chrome/browser/google/google_util.cc |
+++ b/chrome/browser/google/google_util.cc |
@@ -16,6 +16,7 @@ |
#include "components/google/core/browser/google_switches.h" |
#include "components/google/core/browser/google_url_tracker.h" |
#include "components/url_fixer/url_fixer.h" |
+#include "content/public/browser/navigation_entry.h" |
#include "net/base/registry_controlled_domains/registry_controlled_domain.h" |
#include "net/base/url_util.h" |
#include "url/gurl.h" |
@@ -71,6 +72,25 @@ bool IsValidURL(const GURL& url, google_util::PortPermission port_permission) { |
(port_permission == google_util::ALLOW_NON_STANDARD_PORTS)); |
} |
+// Returns true iff |entry| represents a Google search from the Omnibox. |
+// This method assumes that we have already verified that |entry|'s URL is a |
+// Google search URL. |
+bool IsOmniboxGoogleSearchNavigation(const content::NavigationEntry& entry) { |
Peter Kasting
2014/06/19 21:20:32
Given that these two functions are extremely short
kmadhusu
2014/06/19 22:52:49
Done.
|
+ const content::PageTransition stripped_transition = |
+ PageTransitionStripQualifier(entry.GetTransitionType()); |
+ DCHECK(google_util::IsGoogleSearchUrl(entry.GetURL())); |
+ return stripped_transition == content::PAGE_TRANSITION_GENERATED; |
Peter Kasting
2014/06/19 21:20:32
Don't you also need to check for PAGE_TRANSITION_F
kmadhusu
2014/06/19 22:52:49
I moved this code from GoogleSearchCounter to here
Peter Kasting
2014/06/19 22:58:05
I would grep the codebase for PAGE_TRANSITION_GENE
kmadhusu
2014/06/19 23:21:45
Okay.
kmadhusu
2014/06/20 01:15:07
Updated the check.
|
+} |
+ |
+// Returns true iff |entry| represents a Google search from the Google Search |
+// App. This method assumes that we have already verified that |entry|'s URL is |
+// a Google search URL. |
+bool IsSearchAppGoogleSearchNavigation(const content::NavigationEntry& entry) { |
+ DCHECK(google_util::IsGoogleSearchUrl(entry.GetURL())); |
+ return entry.GetURL().query().find("source=search_app") != |
+ std::string::npos; |
Peter Kasting
2014/06/19 21:20:32
Nit: Indent 4, not even
kmadhusu
2014/06/19 22:52:49
Fixed.
|
+} |
+ |
} // namespace |
@@ -214,4 +234,19 @@ bool IsYoutubeDomainUrl(const GURL& url, |
IsValidHostName(url.host(), "youtube", subdomain_permission); |
} |
+GoogleSearchMetrics::AccessPoint GetGoogleSearchAccessPointForNavEntry( |
+ const content::NavigationEntry& entry) { |
+ DCHECK(google_util::IsGoogleSearchUrl(entry.GetURL())); |
+ |
+ // If the commit is a GENERATED commit with a Google search URL, we know it's |
+ // an Omnibox search. |
Peter Kasting
2014/06/19 21:20:32
This comment goes into detail that isn't visible h
kmadhusu
2014/06/19 22:52:49
Inlined IsOmniboxGoogleSearchNavigation() definiti
|
+ if (IsOmniboxGoogleSearchNavigation(entry)) |
+ return GoogleSearchMetrics::AP_OMNIBOX; |
+ |
+ // For all other cases that we have not yet implemented or care to measure, |
+ // we log a generic "catch-all" metric. |
+ return IsSearchAppGoogleSearchNavigation(entry) ? |
+ GoogleSearchMetrics::AP_SEARCH_APP : GoogleSearchMetrics::AP_OTHER; |
+} |
+ |
} // namespace google_util |