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

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

Issue 342053002: Add UMA metrics for Android Chrome Google Search. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 6 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
(Empty)
1 // Copyright (c) 2014 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 #include "chrome/browser/google/google_search_counter_android.h"
6
7 #include "base/logging.h"
8 #include "chrome/browser/google/google_search_counter.h"
9 #include "chrome/browser/prerender/prerender_manager.h"
10 #include "chrome/browser/prerender/prerender_manager_factory.h"
11 #include "components/google/core/browser/google_search_metrics.h"
12 #include "content/public/browser/navigation_details.h"
13 #include "content/public/browser/navigation_entry.h"
14 #include "content/public/browser/notification_service.h"
15 #include "content/public/browser/notification_types.h"
16
17 GoogleSearchCounterAndroid::GoogleSearchCounterAndroid(Profile* profile)
18 : profile_(profile) {
19 // We always listen for all COMMITTED navigations from all sources, as any
20 // one of them could be a navigation of interest.
21 registrar_.Add(this, content::NOTIFICATION_NAV_ENTRY_COMMITTED,
22 content::NotificationService::AllSources());
23 }
24
25 GoogleSearchCounterAndroid::~GoogleSearchCounterAndroid() {
26 }
27
28 void GoogleSearchCounterAndroid::ProcessCommittedEntry(
29 const content::NotificationSource& source,
30 const content::NotificationDetails& details) {
31 GoogleSearchCounter* counter = GoogleSearchCounter::GetInstance();
32 DCHECK(counter);
33 if (!counter->ShouldRecordCommittedDetails(details))
34 return;
35
36 const content::NavigationEntry& entry =
37 *content::Details<content::LoadCommittedDetails>(details)->entry;
38 prerender::PrerenderManager* prerender_manager =
39 prerender::PrerenderManagerFactory::GetForProfile(profile_);
40 DCHECK(prerender_manager);
41 counter->search_metrics()->RecordAndroidGoogleSearch(
42 counter->GetGoogleSearchAccessPointForSearchNavEntry(entry),
43 prerender_manager->IsEnabled());
44 }
45
46 void GoogleSearchCounterAndroid::Observe(
47 int type,
48 const content::NotificationSource& source,
49 const content::NotificationDetails& details) {
50 DCHECK_EQ(content::NOTIFICATION_NAV_ENTRY_COMMITTED, type);
51 ProcessCommittedEntry(source, details);
52 }
OLDNEW
« no previous file with comments | « chrome/browser/google/google_search_counter_android.h ('k') | chrome/browser/google/google_search_counter_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698