OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 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/banners/app_banner_manager_android.h" | 5 #include "chrome/browser/android/banners/app_banner_manager_android.h" |
6 | 6 |
7 #include "base/android/jni_android.h" | 7 #include "base/android/jni_android.h" |
8 #include "base/android/jni_string.h" | 8 #include "base/android/jni_string.h" |
9 #include "chrome/browser/android/banners/app_banner_data_fetcher_android.h" | 9 #include "chrome/browser/android/banners/app_banner_data_fetcher_android.h" |
10 #include "chrome/browser/android/shortcut_helper.h" | 10 #include "chrome/browser/android/shortcut_helper.h" |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 banners::TrackDisplayEvent(DISPLAY_EVENT_NATIVE_APP_BANNER_REQUESTED); | 64 banners::TrackDisplayEvent(DISPLAY_EVENT_NATIVE_APP_BANNER_REQUESTED); |
65 | 65 |
66 // Send the info to the Java side to get info about the app. | 66 // Send the info to the Java side to get info about the app. |
67 JNIEnv* env = base::android::AttachCurrentThread(); | 67 JNIEnv* env = base::android::AttachCurrentThread(); |
68 ScopedJavaLocalRef<jobject> jobj = weak_java_banner_view_manager_.get(env); | 68 ScopedJavaLocalRef<jobject> jobj = weak_java_banner_view_manager_.get(env); |
69 if (jobj.is_null()) | 69 if (jobj.is_null()) |
70 return false; | 70 return false; |
71 | 71 |
72 std::string id_from_app_url = ExtractQueryValueForName(url, kIdName); | 72 std::string id_from_app_url = ExtractQueryValueForName(url, kIdName); |
73 if (id_from_app_url.size() && id != id_from_app_url) { | 73 if (id_from_app_url.size() && id != id_from_app_url) { |
74 banners::OutputDeveloperDebugMessage( | 74 banners::OutputDeveloperNotShownMessage( |
75 web_contents(), banners::kIgnoredIdsDoNotMatch, is_debug_mode); | 75 web_contents(), banners::kIgnoredIdsDoNotMatch, is_debug_mode); |
76 return false; | 76 return false; |
77 } | 77 } |
78 | 78 |
79 std::string referrer = | 79 std::string referrer = |
80 ExtractQueryValueForName(url, kReferrerName); | 80 ExtractQueryValueForName(url, kReferrerName); |
81 | 81 |
82 // Attach the chrome_inline referrer value, prefixed with "&" if the referrer | 82 // Attach the chrome_inline referrer value, prefixed with "&" if the referrer |
83 // is non empty. | 83 // is non empty. |
84 if (referrer.empty()) | 84 if (referrer.empty()) |
(...skipping 11 matching lines...) Expand all Loading... |
96 env, jobj.obj(), jurl.obj(), | 96 env, jobj.obj(), jurl.obj(), |
97 jpackage.obj(), jreferrer.obj(), | 97 jpackage.obj(), jreferrer.obj(), |
98 ShortcutHelper::GetIdealHomescreenIconSizeInDp()); | 98 ShortcutHelper::GetIdealHomescreenIconSizeInDp()); |
99 return true; | 99 return true; |
100 } | 100 } |
101 | 101 |
102 bool AppBannerManagerAndroid::CheckPlatformAndId(const std::string& platform, | 102 bool AppBannerManagerAndroid::CheckPlatformAndId(const std::string& platform, |
103 const std::string& id, | 103 const std::string& id, |
104 bool is_debug_mode) { | 104 bool is_debug_mode) { |
105 if (platform != kPlayPlatform) { | 105 if (platform != kPlayPlatform) { |
106 banners::OutputDeveloperDebugMessage( | 106 banners::OutputDeveloperNotShownMessage( |
107 web_contents(), platform + banners::kIgnoredNotSupportedOnAndroid, | 107 web_contents(), banners::kIgnoredNotSupportedOnAndroid, platform, |
108 is_debug_mode); | 108 is_debug_mode); |
109 return false; | 109 return false; |
110 } | 110 } |
111 if (id.empty()) { | 111 if (id.empty()) { |
112 banners::OutputDeveloperDebugMessage(web_contents(), banners::kIgnoredNoId, | 112 banners::OutputDeveloperNotShownMessage( |
113 is_debug_mode); | 113 web_contents(), banners::kIgnoredNoId, is_debug_mode); |
114 return false; | 114 return false; |
115 } | 115 } |
116 return true; | 116 return true; |
117 } | 117 } |
118 | 118 |
119 bool AppBannerManagerAndroid::CheckFetcherMatchesContents(bool is_debug_mode) { | 119 bool AppBannerManagerAndroid::CheckFetcherMatchesContents(bool is_debug_mode) { |
120 if (!web_contents()) | 120 if (!web_contents()) |
121 return false; | 121 return false; |
122 | 122 |
123 if (!data_fetcher() || | 123 if (!data_fetcher() || |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
214 | 214 |
215 void SetEngagementWeights(JNIEnv* env, | 215 void SetEngagementWeights(JNIEnv* env, |
216 const JavaParamRef<jclass>& clazz, | 216 const JavaParamRef<jclass>& clazz, |
217 jdouble direct_engagement, | 217 jdouble direct_engagement, |
218 jdouble indirect_engagement) { | 218 jdouble indirect_engagement) { |
219 AppBannerManager::SetEngagementWeights(direct_engagement, | 219 AppBannerManager::SetEngagementWeights(direct_engagement, |
220 indirect_engagement); | 220 indirect_engagement); |
221 } | 221 } |
222 | 222 |
223 } // namespace banners | 223 } // namespace banners |
OLD | NEW |