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

Side by Side Diff: chrome/browser/android/metrics/launch_metrics.cc

Issue 1129293009: Record whenever an app is launched from the Home screen. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 7 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
« no previous file with comments | « chrome/android/java/src/org/chromium/chrome/browser/metrics/LaunchMetrics.java ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2015 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2015 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/android/metrics/launch_metrics.h" 5 #include "chrome/browser/android/metrics/launch_metrics.h"
6 6
7 #include "base/android/jni_string.h" 7 #include "base/android/jni_string.h"
8 #include "base/metrics/histogram_macros.h" 8 #include "base/metrics/histogram_macros.h"
9 #include "base/metrics/user_metrics.h" 9 #include "base/metrics/user_metrics.h"
10 #include "chrome/browser/banners/app_banner_settings_helper.h"
10 #include "chrome/browser/browser_process.h" 11 #include "chrome/browser/browser_process.h"
11 #include "components/rappor/rappor_utils.h" 12 #include "components/rappor/rappor_utils.h"
13 #include "content/public/browser/web_contents.h"
12 #include "jni/LaunchMetrics_jni.h" 14 #include "jni/LaunchMetrics_jni.h"
13 #include "url/gurl.h" 15 #include "url/gurl.h"
14 16
15 namespace metrics { 17 namespace metrics {
16 18
17 enum HomeScreenLaunch { 19 enum HomeScreenLaunch {
18 HOME_SCREEN_LAUNCH_STANDALONE = 0, 20 HOME_SCREEN_LAUNCH_STANDALONE = 0,
19 HOME_SCREEN_LAUNCH_SHORTCUT = 1, 21 HOME_SCREEN_LAUNCH_SHORTCUT = 1,
20 HOME_SCREEN_LAUNCH_COUNT = 2 22 HOME_SCREEN_LAUNCH_COUNT = 2
21 }; 23 };
22 24
23 bool RegisterLaunchMetrics(JNIEnv* env) { 25 bool RegisterLaunchMetrics(JNIEnv* env) {
24 return RegisterNativesImpl(env); 26 return RegisterNativesImpl(env);
25 } 27 }
26 28
27 static void RecordLaunch(JNIEnv* env, jclass caller, jboolean standalone, 29 static void RecordLaunch(JNIEnv* env, jclass caller, jboolean standalone,
28 jstring jurl) { 30 jstring jurl, jobject jweb_contents) {
31 GURL url(base::android::ConvertJavaStringToUTF8(env, jurl));
32
33 content::WebContents* web_contents =
34 content::WebContents::FromJavaWebContents(jweb_contents);
35 if (web_contents) {
36 // What a user has installed on the Home screen can become disconnected from
37 // what Chrome believes is on the Home screen if the user clears their data.
38 // Use the launch as a signal that the shortcut still exists.
39 AppBannerSettingsHelper::RecordBannerEvent(
40 web_contents, url, url.spec(),
41 AppBannerSettingsHelper::APP_BANNER_EVENT_DID_ADD_TO_HOMESCREEN,
42 base::Time::Now());
43 }
44
29 int action = standalone ? HOME_SCREEN_LAUNCH_STANDALONE 45 int action = standalone ? HOME_SCREEN_LAUNCH_STANDALONE
30 : HOME_SCREEN_LAUNCH_SHORTCUT; 46 : HOME_SCREEN_LAUNCH_SHORTCUT;
31 std::string rappor_metric = standalone ? "Launch.HomeScreen.Standalone" 47 std::string rappor_metric = standalone ? "Launch.HomeScreen.Standalone"
32 : "Launch.HomeScreen.Shortcut"; 48 : "Launch.HomeScreen.Shortcut";
33 49
34 UMA_HISTOGRAM_ENUMERATION("Launch.HomeScreen", action, 50 UMA_HISTOGRAM_ENUMERATION("Launch.HomeScreen", action,
35 HOME_SCREEN_LAUNCH_COUNT); 51 HOME_SCREEN_LAUNCH_COUNT);
36 52
37 std::string url = base::android::ConvertJavaStringToUTF8(env, jurl);
38 rappor::SampleDomainAndRegistryFromGURL(g_browser_process->rappor_service(), 53 rappor::SampleDomainAndRegistryFromGURL(g_browser_process->rappor_service(),
39 rappor_metric, GURL(url)); 54 rappor_metric, url);
40 } 55 }
41 56
42 }; // namespace metrics 57 }; // namespace metrics
OLDNEW
« no previous file with comments | « chrome/android/java/src/org/chromium/chrome/browser/metrics/LaunchMetrics.java ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698