Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(133)

Side by Side Diff: chrome/browser/google/google_search_counter.cc

Issue 16035020: Move instant support to SearchTabHelper. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed failing tests. Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/google/google_search_counter.h" 5 #include "chrome/browser/google/google_search_counter.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "chrome/browser/google/google_util.h" 8 #include "chrome/browser/google/google_util.h"
9 #include "content/public/browser/navigation_controller.h" 9 #include "content/public/browser/navigation_controller.h"
10 #include "content/public/browser/navigation_details.h" 10 #include "content/public/browser/navigation_details.h"
11 #include "content/public/browser/navigation_entry.h" 11 #include "content/public/browser/navigation_entry.h"
12 #include "content/public/browser/notification_service.h" 12 #include "content/public/browser/notification_service.h"
13 #include "content/public/browser/notification_types.h" 13 #include "content/public/browser/notification_types.h"
14 14
15 namespace { 15 namespace {
16 16
17 // Returns true iff |entry| represents a Google search from the Omnibox.
18 // This method assumes that we have already verified that |entry|'s URL is a
19 // Google search URL.
20 bool IsOmniboxGoogleSearchNavigation(const content::NavigationEntry& entry) {
21 const content::PageTransition stripped_transition =
22 PageTransitionStripQualifier(entry.GetTransitionType());
23 DCHECK(google_util::IsGoogleSearchUrl(entry.GetURL().spec()));
24 return stripped_transition == content::PAGE_TRANSITION_GENERATED;
25 }
26
27 // Returns true iff |entry| represents a Google search from the Google Search 17 // Returns true iff |entry| represents a Google search from the Google Search
28 // App. This method assumes that we have already verified that |entry|'s URL is 18 // App. This method assumes that we have already verified that |entry|'s URL is
29 // a Google search URL. 19 // a Google search URL.
30 bool IsSearchAppGoogleSearchNavigation(const content::NavigationEntry& entry) { 20 bool IsSearchAppGoogleSearchNavigation(const content::NavigationEntry& entry) {
31 DCHECK(google_util::IsGoogleSearchUrl(entry.GetURL().spec())); 21 DCHECK(google_util::IsGoogleSearchUrl(entry.GetURL().spec()));
32 return entry.GetURL().query().find("source=search_app") != 22 return entry.GetURL().query().find("source=search_app") !=
33 std::string::npos; 23 std::string::npos;
34 } 24 }
35 25
36 } // namespace 26 } // namespace
(...skipping 21 matching lines...) Expand all
58 const content::LoadCommittedDetails* commit = 48 const content::LoadCommittedDetails* commit =
59 content::Details<content::LoadCommittedDetails>(details).ptr(); 49 content::Details<content::LoadCommittedDetails>(details).ptr();
60 const content::NavigationEntry& entry = *commit->entry; 50 const content::NavigationEntry& entry = *commit->entry;
61 51
62 // First see if this is a Google search URL at all. 52 // First see if this is a Google search URL at all.
63 if (!google_util::IsGoogleSearchUrl(entry.GetURL().spec())) 53 if (!google_util::IsGoogleSearchUrl(entry.GetURL().spec()))
64 return; 54 return;
65 55
66 // If the commit is a GENERATED commit with a Google search URL, we know it's 56 // If the commit is a GENERATED commit with a Google search URL, we know it's
67 // an Omnibox search. 57 // an Omnibox search.
68 if (IsOmniboxGoogleSearchNavigation(entry)) { 58 if (google_util::IsOmniboxGoogleSearchNavigation(entry)) {
69 // Note that GoogleSearchMetrics logs metrics through UMA, which will only 59 // Note that GoogleSearchMetrics logs metrics through UMA, which will only
70 // transmit these counts to the server if the user has opted into sending 60 // transmit these counts to the server if the user has opted into sending
71 // usage stats. 61 // usage stats.
72 search_metrics_->RecordGoogleSearch(GoogleSearchMetrics::AP_OMNIBOX); 62 search_metrics_->RecordGoogleSearch(GoogleSearchMetrics::AP_OMNIBOX);
73 } else if (IsSearchAppGoogleSearchNavigation(entry)) { 63 } else if (IsSearchAppGoogleSearchNavigation(entry)) {
74 search_metrics_->RecordGoogleSearch(GoogleSearchMetrics::AP_SEARCH_APP); 64 search_metrics_->RecordGoogleSearch(GoogleSearchMetrics::AP_SEARCH_APP);
75 } else { 65 } else {
76 // For all other cases that we have not yet implemented or care to measure, 66 // For all other cases that we have not yet implemented or care to measure,
77 // we log a generic "catch-all" metric. 67 // we log a generic "catch-all" metric.
78 search_metrics_->RecordGoogleSearch(GoogleSearchMetrics::AP_OTHER); 68 search_metrics_->RecordGoogleSearch(GoogleSearchMetrics::AP_OTHER);
(...skipping 17 matching lines...) Expand all
96 const content::NotificationSource& source, 86 const content::NotificationSource& source,
97 const content::NotificationDetails& details) { 87 const content::NotificationDetails& details) {
98 switch (type) { 88 switch (type) {
99 case content::NOTIFICATION_NAV_ENTRY_COMMITTED: 89 case content::NOTIFICATION_NAV_ENTRY_COMMITTED:
100 ProcessCommittedEntry(source, details); 90 ProcessCommittedEntry(source, details);
101 break; 91 break;
102 default: 92 default:
103 NOTREACHED(); 93 NOTREACHED();
104 } 94 }
105 } 95 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/google/google_util.h » ('j') | chrome/browser/ui/search/search_tab_helper.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698