OLD | NEW |
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/android/shortcut_info.h" |
10 #include "chrome/browser/banners/app_banner_settings_helper.h" | 11 #include "chrome/browser/banners/app_banner_settings_helper.h" |
11 #include "chrome/browser/browser_process.h" | 12 #include "chrome/browser/browser_process.h" |
12 #include "components/rappor/rappor_utils.h" | 13 #include "components/rappor/rappor_utils.h" |
13 #include "content/public/browser/web_contents.h" | 14 #include "content/public/browser/web_contents.h" |
14 #include "jni/LaunchMetrics_jni.h" | 15 #include "jni/LaunchMetrics_jni.h" |
15 #include "url/gurl.h" | 16 #include "url/gurl.h" |
16 | 17 |
17 namespace metrics { | 18 namespace metrics { |
18 | 19 |
19 enum HomeScreenLaunch { | 20 enum HomeScreenLaunch { |
20 HOME_SCREEN_LAUNCH_STANDALONE = 0, | 21 HOME_SCREEN_LAUNCH_STANDALONE = 0, |
21 HOME_SCREEN_LAUNCH_SHORTCUT = 1, | 22 HOME_SCREEN_LAUNCH_SHORTCUT = 1, |
22 HOME_SCREEN_LAUNCH_COUNT = 2 | 23 HOME_SCREEN_LAUNCH_COUNT = 2 |
23 }; | 24 }; |
24 | 25 |
25 bool RegisterLaunchMetrics(JNIEnv* env) { | 26 bool RegisterLaunchMetrics(JNIEnv* env) { |
26 return RegisterNativesImpl(env); | 27 return RegisterNativesImpl(env); |
27 } | 28 } |
28 | 29 |
29 static void RecordLaunch(JNIEnv* env, jclass caller, jboolean standalone, | 30 static void RecordLaunch(JNIEnv* env, jclass caller, jboolean standalone, |
30 jstring jurl, jobject jweb_contents) { | 31 jstring jurl, int source, jobject jweb_contents) { |
31 GURL url(base::android::ConvertJavaStringToUTF8(env, jurl)); | 32 GURL url(base::android::ConvertJavaStringToUTF8(env, jurl)); |
32 | 33 |
33 content::WebContents* web_contents = | 34 content::WebContents* web_contents = |
34 content::WebContents::FromJavaWebContents(jweb_contents); | 35 content::WebContents::FromJavaWebContents(jweb_contents); |
35 if (web_contents) { | 36 if (web_contents && source == ShortcutInfo::SOURCE_APP_BANNER) { |
36 // What a user has installed on the Home screen can become disconnected from | 37 // 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 // 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 // Use the launch as a signal that the shortcut still exists. |
39 AppBannerSettingsHelper::RecordBannerEvent( | 40 AppBannerSettingsHelper::RecordBannerEvent( |
40 web_contents, url, url.spec(), | 41 web_contents, url, url.spec(), |
41 AppBannerSettingsHelper::APP_BANNER_EVENT_DID_ADD_TO_HOMESCREEN, | 42 AppBannerSettingsHelper::APP_BANNER_EVENT_DID_ADD_TO_HOMESCREEN, |
42 base::Time::Now()); | 43 base::Time::Now()); |
43 } | 44 } |
44 | 45 |
45 int action = standalone ? HOME_SCREEN_LAUNCH_STANDALONE | 46 int action = standalone ? HOME_SCREEN_LAUNCH_STANDALONE |
46 : HOME_SCREEN_LAUNCH_SHORTCUT; | 47 : HOME_SCREEN_LAUNCH_SHORTCUT; |
47 std::string rappor_metric = standalone ? "Launch.HomeScreen.Standalone" | 48 std::string rappor_metric = standalone ? "Launch.HomeScreen.Standalone" |
48 : "Launch.HomeScreen.Shortcut"; | 49 : "Launch.HomeScreen.Shortcut"; |
49 | 50 |
50 UMA_HISTOGRAM_ENUMERATION("Launch.HomeScreen", action, | 51 UMA_HISTOGRAM_ENUMERATION("Launch.HomeScreen", action, |
51 HOME_SCREEN_LAUNCH_COUNT); | 52 HOME_SCREEN_LAUNCH_COUNT); |
52 | 53 |
| 54 UMA_HISTOGRAM_ENUMERATION("Launch.HomeScreenSource", source, |
| 55 ShortcutInfo::SOURCE_COUNT); |
| 56 |
53 rappor::SampleDomainAndRegistryFromGURL(g_browser_process->rappor_service(), | 57 rappor::SampleDomainAndRegistryFromGURL(g_browser_process->rappor_service(), |
54 rappor_metric, url); | 58 rappor_metric, url); |
55 } | 59 } |
56 | 60 |
57 }; // namespace metrics | 61 }; // namespace metrics |
OLD | NEW |