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_infobar_delegate_android.h" | 5 #include "chrome/browser/android/banners/app_banner_infobar_delegate_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 "base/guid.h" | 9 #include "base/guid.h" |
10 #include "base/location.h" | 10 #include "base/location.h" |
11 #include "base/memory/ptr_util.h" | 11 #include "base/memory/ptr_util.h" |
12 #include "base/strings/string16.h" | 12 #include "base/strings/string16.h" |
13 #include "base/strings/utf_string_conversions.h" | 13 #include "base/strings/utf_string_conversions.h" |
14 #include "chrome/browser/android/shortcut_helper.h" | 14 #include "chrome/browser/android/shortcut_helper.h" |
15 #include "chrome/browser/android/shortcut_info.h" | 15 #include "chrome/browser/android/shortcut_info.h" |
16 #include "chrome/browser/android/tab_android.h" | 16 #include "chrome/browser/android/tab_android.h" |
17 #include "chrome/browser/android/webapk/webapk_installer.h" | 17 #include "chrome/browser/android/webapk/webapk_installer.h" |
18 #include "chrome/browser/android/webapk/webapk_metrics.h" | |
18 #include "chrome/browser/banners/app_banner_manager.h" | 19 #include "chrome/browser/banners/app_banner_manager.h" |
19 #include "chrome/browser/banners/app_banner_metrics.h" | 20 #include "chrome/browser/banners/app_banner_metrics.h" |
20 #include "chrome/browser/banners/app_banner_settings_helper.h" | 21 #include "chrome/browser/banners/app_banner_settings_helper.h" |
21 #include "chrome/browser/browser_process.h" | 22 #include "chrome/browser/browser_process.h" |
22 #include "chrome/browser/infobars/infobar_service.h" | 23 #include "chrome/browser/infobars/infobar_service.h" |
23 #include "chrome/browser/ui/android/infobars/app_banner_infobar_android.h" | 24 #include "chrome/browser/ui/android/infobars/app_banner_infobar_android.h" |
24 #include "chrome/common/render_messages.h" | 25 #include "chrome/common/render_messages.h" |
25 #include "components/rappor/rappor_utils.h" | 26 #include "components/rappor/rappor_utils.h" |
26 #include "content/public/browser/render_frame_host.h" | 27 #include "content/public/browser/render_frame_host.h" |
27 #include "content/public/browser/web_contents.h" | 28 #include "content/public/browser/web_contents.h" |
28 #include "content/public/common/manifest.h" | 29 #include "content/public/common/manifest.h" |
29 #include "jni/AppBannerInfoBarDelegateAndroid_jni.h" | 30 #include "jni/AppBannerInfoBarDelegateAndroid_jni.h" |
30 #include "ui/gfx/android/java_bitmap.h" | 31 #include "ui/gfx/android/java_bitmap.h" |
31 #include "url/gurl.h" | 32 #include "url/gurl.h" |
32 | 33 |
33 using base::android::ConvertJavaStringToUTF8; | 34 using base::android::ConvertJavaStringToUTF8; |
34 using base::android::ConvertJavaStringToUTF16; | 35 using base::android::ConvertJavaStringToUTF16; |
35 using base::android::ConvertUTF8ToJavaString; | 36 using base::android::ConvertUTF8ToJavaString; |
36 using base::android::ConvertUTF16ToJavaString; | 37 using base::android::ConvertUTF16ToJavaString; |
37 using base::android::JavaParamRef; | 38 using base::android::JavaParamRef; |
38 using base::android::ScopedJavaLocalRef; | 39 using base::android::ScopedJavaLocalRef; |
39 | 40 |
40 namespace { | 41 namespace { |
41 | 42 |
42 bool IsInfoEmpty(const std::unique_ptr<ShortcutInfo>& info) { | 43 bool IsInfoEmpty(const std::unique_ptr<ShortcutInfo>& info) { |
43 return !info || info->url.is_empty(); | 44 return !info || info->url.is_empty(); |
44 } | 45 } |
45 | 46 |
46 } | 47 } // namespace |
47 | 48 |
48 namespace banners { | 49 namespace banners { |
49 | 50 |
50 // static | 51 // static |
51 bool AppBannerInfoBarDelegateAndroid::Create( | 52 bool AppBannerInfoBarDelegateAndroid::Create( |
52 content::WebContents* web_contents, | 53 content::WebContents* web_contents, |
53 base::WeakPtr<AppBannerManager> weak_manager, | 54 base::WeakPtr<AppBannerManager> weak_manager, |
54 const base::string16& app_title, | 55 const base::string16& app_title, |
55 std::unique_ptr<ShortcutInfo> shortcut_info, | 56 std::unique_ptr<ShortcutInfo> shortcut_info, |
56 std::unique_ptr<SkBitmap> icon, | 57 std::unique_ptr<SkBitmap> icon, |
57 int event_request_id, | 58 int event_request_id, |
58 bool is_webapk, | 59 bool is_webapk, |
59 bool start_install_webapk) { | 60 bool start_install_webapk) { |
60 const GURL& url = shortcut_info->url; | 61 const GURL& url = shortcut_info->url; |
61 auto infobar_delegate = | 62 auto infobar_delegate = |
62 base::WrapUnique(new banners::AppBannerInfoBarDelegateAndroid( | 63 base::WrapUnique(new banners::AppBannerInfoBarDelegateAndroid( |
63 weak_manager, app_title, std::move(shortcut_info), std::move(icon), | 64 weak_manager, app_title, std::move(shortcut_info), std::move(icon), |
64 event_request_id, is_webapk)); | 65 event_request_id, is_webapk)); |
65 auto raw_delegate = infobar_delegate.get(); | 66 auto raw_delegate = infobar_delegate.get(); |
66 auto infobar = base::MakeUnique<AppBannerInfoBarAndroid>( | 67 auto infobar = base::MakeUnique<AppBannerInfoBarAndroid>( |
67 std::move(infobar_delegate), url, is_webapk); | 68 std::move(infobar_delegate), url, is_webapk); |
68 if (!InfoBarService::FromWebContents(web_contents) | 69 if (!InfoBarService::FromWebContents(web_contents) |
69 ->AddInfoBar(std::move(infobar))) | 70 ->AddInfoBar(std::move(infobar))) |
70 return false; | 71 return false; |
71 | 72 |
72 if (is_webapk && start_install_webapk) | 73 if (is_webapk) { |
73 raw_delegate->AcceptWebApk(web_contents); | 74 if (start_install_webapk) { |
75 raw_delegate->AcceptWebApk(web_contents); | |
76 webapk::TrackInstallTriggeredType( | |
77 webapk::TRIGGERED_FROM_ADD_TO_HOME_SCREEN_MENU); | |
78 webapk::TrackInstallStartType( | |
79 webapk::STARTED_FROM_ADD_TO_HOME_SCREEN_MENU); | |
80 } else { | |
81 webapk::TrackInstallTriggeredType(webapk::TRIGGERED_FROM_BANNER); | |
82 } | |
83 } | |
74 | 84 |
75 return true; | 85 return true; |
76 } | 86 } |
77 | 87 |
78 // static | 88 // static |
79 bool AppBannerInfoBarDelegateAndroid::Create( | 89 bool AppBannerInfoBarDelegateAndroid::Create( |
80 content::WebContents* web_contents, | 90 content::WebContents* web_contents, |
81 const base::string16& app_title, | 91 const base::string16& app_title, |
82 const base::android::ScopedJavaGlobalRef<jobject>& native_app_data, | 92 const base::android::ScopedJavaGlobalRef<jobject>& native_app_data, |
83 std::unique_ptr<SkBitmap> icon, | 93 std::unique_ptr<SkBitmap> icon, |
84 const std::string& native_app_package, | 94 const std::string& native_app_package, |
85 const std::string& referrer, | 95 const std::string& referrer, |
86 int event_request_id) { | 96 int event_request_id) { |
87 auto infobar_delegate = base::WrapUnique(new AppBannerInfoBarDelegateAndroid( | 97 auto infobar_delegate = base::WrapUnique(new AppBannerInfoBarDelegateAndroid( |
88 app_title, native_app_data, std::move(icon), native_app_package, referrer, | 98 app_title, native_app_data, std::move(icon), native_app_package, referrer, |
89 event_request_id)); | 99 event_request_id)); |
90 return InfoBarService::FromWebContents(web_contents) | 100 return InfoBarService::FromWebContents(web_contents) |
91 ->AddInfoBar(base::MakeUnique<AppBannerInfoBarAndroid>( | 101 ->AddInfoBar(base::MakeUnique<AppBannerInfoBarAndroid>( |
92 std::move(infobar_delegate), native_app_data)); | 102 std::move(infobar_delegate), native_app_data)); |
93 } | 103 } |
94 | 104 |
95 AppBannerInfoBarDelegateAndroid::~AppBannerInfoBarDelegateAndroid() { | 105 AppBannerInfoBarDelegateAndroid::~AppBannerInfoBarDelegateAndroid() { |
96 weak_ptr_factory_.InvalidateWeakPtrs(); | 106 weak_ptr_factory_.InvalidateWeakPtrs(); |
97 | 107 |
98 if (!has_user_interaction_) { | 108 if (!has_user_interaction_) { |
99 if (!native_app_data_.is_null()) | 109 if (!native_app_data_.is_null()) { |
100 TrackUserResponse(USER_RESPONSE_NATIVE_APP_IGNORED); | 110 TrackUserResponse(USER_RESPONSE_NATIVE_APP_IGNORED); |
101 else if (!IsInfoEmpty(shortcut_info_)) | 111 } else { |
102 TrackUserResponse(USER_RESPONSE_WEB_APP_IGNORED); | 112 TrackUserResponse(USER_RESPONSE_WEB_APP_IGNORED); |
113 if (is_webapk_) | |
114 webapk::TrackInstallEvent(webapk::BANNER_IGNORED); | |
115 } | |
103 } | 116 } |
104 | 117 |
105 TrackDismissEvent(DISMISS_EVENT_DISMISSED); | 118 TrackDismissEvent(DISMISS_EVENT_DISMISSED); |
106 JNIEnv* env = base::android::AttachCurrentThread(); | 119 JNIEnv* env = base::android::AttachCurrentThread(); |
107 Java_AppBannerInfoBarDelegateAndroid_destroy(env, java_delegate_); | 120 Java_AppBannerInfoBarDelegateAndroid_destroy(env, java_delegate_); |
108 java_delegate_.Reset(); | 121 java_delegate_.Reset(); |
109 } | 122 } |
110 | 123 |
111 void AppBannerInfoBarDelegateAndroid::UpdateInstallState( | 124 void AppBannerInfoBarDelegateAndroid::UpdateInstallState( |
112 JNIEnv* env, | 125 JNIEnv* env, |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
155 TrackInstallEvent(INSTALL_EVENT_NATIVE_APP_INSTALL_COMPLETED); | 168 TrackInstallEvent(INSTALL_EVENT_NATIVE_APP_INSTALL_COMPLETED); |
156 UpdateInstallState(env, obj); | 169 UpdateInstallState(env, obj); |
157 } else if (infobar()->owner()) { | 170 } else if (infobar()->owner()) { |
158 TrackDismissEvent(DISMISS_EVENT_INSTALL_TIMEOUT); | 171 TrackDismissEvent(DISMISS_EVENT_INSTALL_TIMEOUT); |
159 infobar()->owner()->RemoveInfoBar(infobar()); | 172 infobar()->owner()->RemoveInfoBar(infobar()); |
160 } | 173 } |
161 } | 174 } |
162 | 175 |
163 bool AppBannerInfoBarDelegateAndroid::AcceptWebApk( | 176 bool AppBannerInfoBarDelegateAndroid::AcceptWebApk( |
164 content::WebContents* web_contents) { | 177 content::WebContents* web_contents) { |
178 has_user_interaction_ = true; | |
165 if (IsInfoEmpty(shortcut_info_)) | 179 if (IsInfoEmpty(shortcut_info_)) |
166 return true; | 180 return true; |
167 | 181 |
168 JNIEnv* env = base::android::AttachCurrentThread(); | 182 JNIEnv* env = base::android::AttachCurrentThread(); |
169 // |webapk_package_name_| is set when the WebAPK has finished installing. | 183 // |webapk_package_name_| is set when the WebAPK has finished installing. |
170 // If the |webapk_package_name_| is empty, it means the "Add to Homescreen" | 184 // If the |webapk_package_name_| is empty, it means the "Add to Homescreen" |
171 // button is pressed, so request WebAPK installation. Otherwise, it means | 185 // button is pressed, so request WebAPK installation. Otherwise, it means |
172 // the "Open" button is pressed, so open the installed WebAPK. | 186 // the "Open" button is pressed, so open the installed WebAPK. |
173 if (!webapk_package_name_.empty()) { | 187 if (!webapk_package_name_.empty()) { |
174 // Open the WebAPK. | 188 // Open the WebAPK. |
175 ScopedJavaLocalRef<jstring> java_webapk_package_name = | 189 ScopedJavaLocalRef<jstring> java_webapk_package_name = |
176 base::android::ConvertUTF8ToJavaString(env, webapk_package_name_); | 190 base::android::ConvertUTF8ToJavaString(env, webapk_package_name_); |
177 Java_AppBannerInfoBarDelegateAndroid_openWebApk(env, java_delegate_, | 191 Java_AppBannerInfoBarDelegateAndroid_openWebApk(env, java_delegate_, |
178 java_webapk_package_name); | 192 java_webapk_package_name); |
179 | 193 webapk::TrackUserAction(webapk::USER_ACTION_INSTALLED_OPEN); |
180 SendBannerAccepted(web_contents, "web"); | 194 SendBannerAccepted(web_contents, "web"); |
181 return true; | 195 return true; |
182 } | 196 } |
183 | 197 |
184 // Request install the WebAPK. | 198 // Request install the WebAPK. |
199 install_state_ = INSTALLING; | |
185 TrackUserResponse(USER_RESPONSE_WEB_APP_ACCEPTED); | 200 TrackUserResponse(USER_RESPONSE_WEB_APP_ACCEPTED); |
186 AppBannerSettingsHelper::RecordBannerInstallEvent( | 201 AppBannerSettingsHelper::RecordBannerInstallEvent( |
187 web_contents, shortcut_info_->url.spec(), AppBannerSettingsHelper::WEB); | 202 web_contents, shortcut_info_->url.spec(), AppBannerSettingsHelper::WEB); |
188 | 203 |
189 Java_AppBannerInfoBarDelegateAndroid_setWebApkInstallingState( | 204 Java_AppBannerInfoBarDelegateAndroid_setWebApkInstallingState( |
190 env, java_delegate_, true); | 205 env, java_delegate_, true); |
191 UpdateInstallState(env, nullptr); | 206 UpdateInstallState(env, nullptr); |
192 WebApkInstaller::FinishCallback callback = | 207 WebApkInstaller::FinishCallback callback = |
193 base::Bind(&AppBannerInfoBarDelegateAndroid::OnWebApkInstallFinished, | 208 base::Bind(&AppBannerInfoBarDelegateAndroid::OnWebApkInstallFinished, |
194 weak_ptr_factory_.GetWeakPtr()); | 209 weak_ptr_factory_.GetWeakPtr()); |
(...skipping 14 matching lines...) Expand all Loading... | |
209 std::unique_ptr<SkBitmap> icon, | 224 std::unique_ptr<SkBitmap> icon, |
210 int event_request_id, | 225 int event_request_id, |
211 bool is_webapk) | 226 bool is_webapk) |
212 : weak_manager_(weak_manager), | 227 : weak_manager_(weak_manager), |
213 app_title_(app_title), | 228 app_title_(app_title), |
214 shortcut_info_(std::move(shortcut_info)), | 229 shortcut_info_(std::move(shortcut_info)), |
215 icon_(std::move(icon)), | 230 icon_(std::move(icon)), |
216 event_request_id_(event_request_id), | 231 event_request_id_(event_request_id), |
217 has_user_interaction_(false), | 232 has_user_interaction_(false), |
218 is_webapk_(is_webapk), | 233 is_webapk_(is_webapk), |
234 install_state_(INSTALL_NOT_STARTED), | |
219 weak_ptr_factory_(this) { | 235 weak_ptr_factory_(this) { |
220 DCHECK(!IsInfoEmpty(shortcut_info_)); | 236 DCHECK(!IsInfoEmpty(shortcut_info_)); |
221 CreateJavaDelegate(); | 237 CreateJavaDelegate(); |
222 } | 238 } |
223 | 239 |
224 AppBannerInfoBarDelegateAndroid::AppBannerInfoBarDelegateAndroid( | 240 AppBannerInfoBarDelegateAndroid::AppBannerInfoBarDelegateAndroid( |
225 const base::string16& app_title, | 241 const base::string16& app_title, |
226 const base::android::ScopedJavaGlobalRef<jobject>& native_app_data, | 242 const base::android::ScopedJavaGlobalRef<jobject>& native_app_data, |
227 std::unique_ptr<SkBitmap> icon, | 243 std::unique_ptr<SkBitmap> icon, |
228 const std::string& native_app_package, | 244 const std::string& native_app_package, |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
270 | 286 |
271 content::WebContents* web_contents = | 287 content::WebContents* web_contents = |
272 InfoBarService::WebContentsFromInfoBar(infobar()); | 288 InfoBarService::WebContentsFromInfoBar(infobar()); |
273 | 289 |
274 web_contents->GetMainFrame()->Send( | 290 web_contents->GetMainFrame()->Send( |
275 new ChromeViewMsg_AppBannerDismissed( | 291 new ChromeViewMsg_AppBannerDismissed( |
276 web_contents->GetMainFrame()->GetRoutingID(), | 292 web_contents->GetMainFrame()->GetRoutingID(), |
277 event_request_id_)); | 293 event_request_id_)); |
278 | 294 |
279 if (native_app_data_.is_null()) { | 295 if (native_app_data_.is_null()) { |
296 if (is_webapk_) | |
297 TrackWebApkInstallationDismissEvents(install_state_); | |
280 TrackUserResponse(USER_RESPONSE_WEB_APP_DISMISSED); | 298 TrackUserResponse(USER_RESPONSE_WEB_APP_DISMISSED); |
281 AppBannerSettingsHelper::RecordBannerDismissEvent( | 299 AppBannerSettingsHelper::RecordBannerDismissEvent( |
282 web_contents, shortcut_info_->url.spec(), AppBannerSettingsHelper::WEB); | 300 web_contents, shortcut_info_->url.spec(), AppBannerSettingsHelper::WEB); |
283 } else { | 301 } else { |
284 TrackUserResponse(USER_RESPONSE_NATIVE_APP_DISMISSED); | 302 TrackUserResponse(USER_RESPONSE_NATIVE_APP_DISMISSED); |
285 AppBannerSettingsHelper::RecordBannerDismissEvent( | 303 AppBannerSettingsHelper::RecordBannerDismissEvent( |
286 web_contents, native_app_package_, AppBannerSettingsHelper::NATIVE); | 304 web_contents, native_app_package_, AppBannerSettingsHelper::NATIVE); |
287 } | 305 } |
288 } | 306 } |
289 | 307 |
(...skipping 11 matching lines...) Expand all Loading... | |
301 content::WebContents* web_contents = | 319 content::WebContents* web_contents = |
302 InfoBarService::WebContentsFromInfoBar(infobar()); | 320 InfoBarService::WebContentsFromInfoBar(infobar()); |
303 if (!web_contents) { | 321 if (!web_contents) { |
304 TrackDismissEvent(DISMISS_EVENT_ERROR); | 322 TrackDismissEvent(DISMISS_EVENT_ERROR); |
305 return true; | 323 return true; |
306 } | 324 } |
307 | 325 |
308 if (!native_app_data_.is_null()) | 326 if (!native_app_data_.is_null()) |
309 return AcceptNativeApp(web_contents); | 327 return AcceptNativeApp(web_contents); |
310 | 328 |
311 if (is_webapk_) | 329 if (is_webapk_) { |
330 webapk::TrackInstallStartType(webapk::STARTED_FROM_BANNER); | |
312 return AcceptWebApk(web_contents); | 331 return AcceptWebApk(web_contents); |
332 } | |
313 | 333 |
314 return AcceptWebApp(web_contents); | 334 return AcceptWebApp(web_contents); |
315 } | 335 } |
316 | 336 |
317 bool AppBannerInfoBarDelegateAndroid::AcceptNativeApp( | 337 bool AppBannerInfoBarDelegateAndroid::AcceptNativeApp( |
318 content::WebContents* web_contents) { | 338 content::WebContents* web_contents) { |
319 TrackUserResponse(USER_RESPONSE_NATIVE_APP_ACCEPTED); | 339 TrackUserResponse(USER_RESPONSE_NATIVE_APP_ACCEPTED); |
320 JNIEnv* env = base::android::AttachCurrentThread(); | 340 JNIEnv* env = base::android::AttachCurrentThread(); |
321 | 341 |
322 TabAndroid* tab = TabAndroid::FromWebContents(web_contents); | 342 TabAndroid* tab = TabAndroid::FromWebContents(web_contents); |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
358 return true; | 378 return true; |
359 } | 379 } |
360 | 380 |
361 void AppBannerInfoBarDelegateAndroid::OnWebApkInstallFinished( | 381 void AppBannerInfoBarDelegateAndroid::OnWebApkInstallFinished( |
362 bool success, | 382 bool success, |
363 const std::string& webapk_package_name) { | 383 const std::string& webapk_package_name) { |
364 JNIEnv* env = base::android::AttachCurrentThread(); | 384 JNIEnv* env = base::android::AttachCurrentThread(); |
365 if (!success) { | 385 if (!success) { |
366 DVLOG(1) << "The WebAPK installation failed."; | 386 DVLOG(1) << "The WebAPK installation failed."; |
367 Java_AppBannerInfoBarDelegateAndroid_showWebApkInstallFailureToast(env); | 387 Java_AppBannerInfoBarDelegateAndroid_showWebApkInstallFailureToast(env); |
388 webapk::TrackInstallEvent(webapk::INSTALL_FAILED); | |
368 if (infobar()) | 389 if (infobar()) |
369 infobar()->RemoveSelf(); | 390 infobar()->RemoveSelf(); |
370 return; | 391 return; |
371 } | 392 } |
372 | 393 |
373 webapk_package_name_ = webapk_package_name; | 394 webapk_package_name_ = webapk_package_name; |
374 ScopedJavaLocalRef<jstring> java_webapk_package_name = | 395 ScopedJavaLocalRef<jstring> java_webapk_package_name = |
375 base::android::ConvertUTF8ToJavaString(env, webapk_package_name); | 396 base::android::ConvertUTF8ToJavaString(env, webapk_package_name); |
376 Java_AppBannerInfoBarDelegateAndroid_setWebApkInstallingState( | 397 Java_AppBannerInfoBarDelegateAndroid_setWebApkInstallingState( |
377 env, java_delegate_, false); | 398 env, java_delegate_, false); |
378 Java_AppBannerInfoBarDelegateAndroid_setWebApkPackageName( | 399 Java_AppBannerInfoBarDelegateAndroid_setWebApkPackageName( |
379 env, java_delegate_, java_webapk_package_name); | 400 env, java_delegate_, java_webapk_package_name); |
380 UpdateInstallState(env, nullptr); | 401 UpdateInstallState(env, nullptr); |
402 install_state_ = INSTALLED; | |
403 webapk::TrackInstallEvent(webapk::INSTALL_COMPLETED); | |
404 } | |
405 | |
406 void AppBannerInfoBarDelegateAndroid::TrackWebApkInstallationDismissEvents( | |
407 InstallState install_state) { | |
408 if (install_state == INSTALL_NOT_STARTED) | |
409 webapk::TrackInstallEvent(webapk::BANNER_DISMISSED_BEFORE_INSTALLATION); | |
410 else if (install_state == INSTALLING) | |
411 webapk::TrackInstallEvent(webapk::BANNER_DISMISSED_DURING_INSTALLATION); | |
412 else if (install_state == INSTALLED) | |
dominickn
2016/09/21 06:54:27
Minor nit: add an explicit comment saying that whe
Xi Han
2016/09/21 14:22:08
Done.
| |
413 webapk::TrackUserAction(webapk::USER_ACTION_INSTALLED_OPEN_DISMISS); | |
381 } | 414 } |
382 | 415 |
383 bool AppBannerInfoBarDelegateAndroid::LinkClicked( | 416 bool AppBannerInfoBarDelegateAndroid::LinkClicked( |
384 WindowOpenDisposition disposition) { | 417 WindowOpenDisposition disposition) { |
385 if (native_app_data_.is_null()) | 418 if (native_app_data_.is_null()) |
386 return false; | 419 return false; |
387 | 420 |
388 // Try to show the details for the native app. | 421 // Try to show the details for the native app. |
389 JNIEnv* env = base::android::AttachCurrentThread(); | 422 JNIEnv* env = base::android::AttachCurrentThread(); |
390 | 423 |
391 content::WebContents* web_contents = | 424 content::WebContents* web_contents = |
392 InfoBarService::WebContentsFromInfoBar(infobar()); | 425 InfoBarService::WebContentsFromInfoBar(infobar()); |
393 TabAndroid* tab = TabAndroid::FromWebContents(web_contents); | 426 TabAndroid* tab = TabAndroid::FromWebContents(web_contents); |
394 DCHECK(tab); | 427 DCHECK(tab); |
395 | 428 |
396 Java_AppBannerInfoBarDelegateAndroid_showAppDetails( | 429 Java_AppBannerInfoBarDelegateAndroid_showAppDetails( |
397 env, java_delegate_, tab->GetJavaObject(), native_app_data_); | 430 env, java_delegate_, tab->GetJavaObject(), native_app_data_); |
398 | 431 |
399 TrackDismissEvent(DISMISS_EVENT_BANNER_CLICK); | 432 TrackDismissEvent(DISMISS_EVENT_BANNER_CLICK); |
400 return true; | 433 return true; |
401 } | 434 } |
402 | 435 |
403 bool RegisterAppBannerInfoBarDelegateAndroid(JNIEnv* env) { | 436 bool RegisterAppBannerInfoBarDelegateAndroid(JNIEnv* env) { |
404 return RegisterNativesImpl(env); | 437 return RegisterNativesImpl(env); |
405 } | 438 } |
406 | 439 |
407 } // namespace banners | 440 } // namespace banners |
OLD | NEW |