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 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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::OutputDeveloperNotShownMessage( | 74 banners::OutputDeveloperNotShownMessage( |
75 web_contents(), banners::kIgnoredIdsDoNotMatch, is_debug_mode); | 75 web_contents(), |
| 76 banners::OutputDeveloperMessageCode::kIgnoredIdsDoNotMatch, |
| 77 is_debug_mode); |
76 return false; | 78 return false; |
77 } | 79 } |
78 | 80 |
79 std::string referrer = | 81 std::string referrer = |
80 ExtractQueryValueForName(url, kReferrerName); | 82 ExtractQueryValueForName(url, kReferrerName); |
81 | 83 |
82 // Attach the chrome_inline referrer value, prefixed with "&" if the referrer | 84 // Attach the chrome_inline referrer value, prefixed with "&" if the referrer |
83 // is non empty. | 85 // is non empty. |
84 if (referrer.empty()) | 86 if (referrer.empty()) |
85 referrer = kPlayInlineReferrer; | 87 referrer = kPlayInlineReferrer; |
(...skipping 11 matching lines...) Expand all Loading... |
97 jpackage.obj(), jreferrer.obj(), | 99 jpackage.obj(), jreferrer.obj(), |
98 ShortcutHelper::GetIdealHomescreenIconSizeInDp()); | 100 ShortcutHelper::GetIdealHomescreenIconSizeInDp()); |
99 return true; | 101 return true; |
100 } | 102 } |
101 | 103 |
102 bool AppBannerManagerAndroid::CheckPlatformAndId(const std::string& platform, | 104 bool AppBannerManagerAndroid::CheckPlatformAndId(const std::string& platform, |
103 const std::string& id, | 105 const std::string& id, |
104 bool is_debug_mode) { | 106 bool is_debug_mode) { |
105 if (platform != kPlayPlatform) { | 107 if (platform != kPlayPlatform) { |
106 banners::OutputDeveloperNotShownMessage( | 108 banners::OutputDeveloperNotShownMessage( |
107 web_contents(), banners::kIgnoredNotSupportedOnAndroid, platform, | 109 web_contents(), |
108 is_debug_mode); | 110 banners::OutputDeveloperMessageCode::kIgnoredNotSupportedOnAndroid, |
| 111 platform, is_debug_mode); |
109 return false; | 112 return false; |
110 } | 113 } |
111 if (id.empty()) { | 114 if (id.empty()) { |
112 banners::OutputDeveloperNotShownMessage( | 115 banners::OutputDeveloperNotShownMessage( |
113 web_contents(), banners::kIgnoredNoId, is_debug_mode); | 116 web_contents(), banners::OutputDeveloperMessageCode::kIgnoredNoId, |
| 117 is_debug_mode); |
114 return false; | 118 return false; |
115 } | 119 } |
116 return true; | 120 return true; |
117 } | 121 } |
118 | 122 |
119 bool AppBannerManagerAndroid::CheckFetcherMatchesContents(bool is_debug_mode) { | 123 bool AppBannerManagerAndroid::CheckFetcherMatchesContents(bool is_debug_mode) { |
120 if (!web_contents()) | 124 if (!web_contents()) |
121 return false; | 125 return false; |
122 | 126 |
123 if (!data_fetcher() || | 127 if (!data_fetcher() || |
124 data_fetcher()->validated_url() != web_contents()->GetURL()) { | 128 data_fetcher()->validated_url() != web_contents()->GetURL()) { |
125 banners::OutputDeveloperNotShownMessage( | 129 banners::OutputDeveloperNotShownMessage( |
126 web_contents(), banners::kUserNavigatedBeforeBannerShown, | 130 web_contents(), |
| 131 banners::OutputDeveloperMessageCode::kUserNavigatedBeforeBannerShown, |
127 is_debug_mode); | 132 is_debug_mode); |
128 return false; | 133 return false; |
129 } | 134 } |
130 return true; | 135 return true; |
131 } | 136 } |
132 | 137 |
133 std::string AppBannerManagerAndroid::ExtractQueryValueForName( | 138 std::string AppBannerManagerAndroid::ExtractQueryValueForName( |
134 const GURL& url, | 139 const GURL& url, |
135 const std::string& name) { | 140 const std::string& name) { |
136 url::Component query = url.parsed_for_possibly_invalid_spec().query; | 141 url::Component query = url.parsed_for_possibly_invalid_spec().query; |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
214 | 219 |
215 void SetEngagementWeights(JNIEnv* env, | 220 void SetEngagementWeights(JNIEnv* env, |
216 const JavaParamRef<jclass>& clazz, | 221 const JavaParamRef<jclass>& clazz, |
217 jdouble direct_engagement, | 222 jdouble direct_engagement, |
218 jdouble indirect_engagement) { | 223 jdouble indirect_engagement) { |
219 AppBannerManager::SetEngagementWeights(direct_engagement, | 224 AppBannerManager::SetEngagementWeights(direct_engagement, |
220 indirect_engagement); | 225 indirect_engagement); |
221 } | 226 } |
222 | 227 |
223 } // namespace banners | 228 } // namespace banners |
OLD | NEW |