| 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 <utility> | 5 #include <utility> |
| 6 | 6 |
| 7 #include "chrome/browser/android/banners/app_banner_manager_android.h" | 7 #include "chrome/browser/android/banners/app_banner_manager_android.h" |
| 8 | 8 |
| 9 #include "base/android/jni_android.h" | 9 #include "base/android/jni_android.h" |
| 10 #include "base/android/jni_string.h" | 10 #include "base/android/jni_string.h" |
| 11 #include "base/memory/ptr_util.h" | 11 #include "base/memory/ptr_util.h" |
| 12 #include "base/strings/utf_string_conversions.h" | 12 #include "base/strings/utf_string_conversions.h" |
| 13 #include "chrome/browser/android/banners/app_banner_infobar_delegate_android.h" | 13 #include "chrome/browser/android/banners/app_banner_infobar_delegate_android.h" |
| 14 #include "chrome/browser/android/shortcut_helper.h" | 14 #include "chrome/browser/android/shortcut_helper.h" |
| 15 #include "chrome/browser/android/webapk/chrome_webapk_host.h" |
| 15 #include "chrome/browser/banners/app_banner_metrics.h" | 16 #include "chrome/browser/banners/app_banner_metrics.h" |
| 16 #include "chrome/browser/infobars/infobar_service.h" | 17 #include "chrome/browser/infobars/infobar_service.h" |
| 17 #include "chrome/browser/manifest/manifest_icon_downloader.h" | 18 #include "chrome/browser/manifest/manifest_icon_downloader.h" |
| 18 #include "chrome/browser/manifest/manifest_icon_selector.h" | 19 #include "chrome/browser/manifest/manifest_icon_selector.h" |
| 19 #include "chrome/browser/ui/android/infobars/app_banner_infobar_android.h" | 20 #include "chrome/browser/ui/android/infobars/app_banner_infobar_android.h" |
| 20 #include "chrome/common/chrome_constants.h" | 21 #include "chrome/common/chrome_constants.h" |
| 21 #include "content/public/browser/web_contents.h" | 22 #include "content/public/browser/web_contents.h" |
| 22 #include "content/public/common/frame_navigate_params.h" | 23 #include "content/public/common/frame_navigate_params.h" |
| 23 #include "jni/AppBannerManager_jni.h" | 24 #include "jni/AppBannerManager_jni.h" |
| 24 #include "third_party/skia/include/core/SkBitmap.h" | 25 #include "third_party/skia/include/core/SkBitmap.h" |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 170 icon_.reset(new SkBitmap(bitmap)); | 171 icon_.reset(new SkBitmap(bitmap)); |
| 171 SendBannerPromptRequest(); | 172 SendBannerPromptRequest(); |
| 172 } | 173 } |
| 173 | 174 |
| 174 void AppBannerManagerAndroid::ShowBanner() { | 175 void AppBannerManagerAndroid::ShowBanner() { |
| 175 content::WebContents* contents = web_contents(); | 176 content::WebContents* contents = web_contents(); |
| 176 DCHECK(contents); | 177 DCHECK(contents); |
| 177 | 178 |
| 178 infobars::InfoBar* infobar = nullptr; | 179 infobars::InfoBar* infobar = nullptr; |
| 179 if (native_app_data_.is_null()) { | 180 if (native_app_data_.is_null()) { |
| 181 bool is_webapk = ChromeWebApkHost::AreWebApkEnabled(); |
| 180 std::unique_ptr<AppBannerInfoBarDelegateAndroid> delegate( | 182 std::unique_ptr<AppBannerInfoBarDelegateAndroid> delegate( |
| 181 new AppBannerInfoBarDelegateAndroid( | 183 new AppBannerInfoBarDelegateAndroid( |
| 182 GetWeakPtr(), app_title_, manifest_url_, manifest_, icon_url_, | 184 GetWeakPtr(), app_title_, manifest_url_, manifest_, icon_url_, |
| 183 std::move(icon_), event_request_id())); | 185 std::move(icon_), event_request_id(), is_webapk)); |
| 184 | 186 |
| 185 infobar = new AppBannerInfoBarAndroid(std::move(delegate), | 187 infobar = new AppBannerInfoBarAndroid( |
| 186 manifest_.start_url); | 188 std::move(delegate), manifest_.start_url, is_webapk); |
| 187 if (infobar) { | 189 if (infobar) { |
| 188 RecordDidShowBanner("AppBanner.WebApp.Shown"); | 190 RecordDidShowBanner("AppBanner.WebApp.Shown"); |
| 189 TrackDisplayEvent(DISPLAY_EVENT_WEB_APP_BANNER_CREATED); | 191 TrackDisplayEvent(DISPLAY_EVENT_WEB_APP_BANNER_CREATED); |
| 190 ReportStatus(contents, SHOWING_WEB_APP_BANNER); | 192 ReportStatus(contents, SHOWING_WEB_APP_BANNER); |
| 191 } else { | 193 } else { |
| 192 ReportStatus(contents, FAILED_TO_CREATE_BANNER); | 194 ReportStatus(contents, FAILED_TO_CREATE_BANNER); |
| 193 } | 195 } |
| 194 } else { | 196 } else { |
| 195 std::unique_ptr<AppBannerInfoBarDelegateAndroid> delegate( | 197 std::unique_ptr<AppBannerInfoBarDelegateAndroid> delegate( |
| 196 new AppBannerInfoBarDelegateAndroid( | 198 new AppBannerInfoBarDelegateAndroid( |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 320 } | 322 } |
| 321 | 323 |
| 322 // static | 324 // static |
| 323 void SetTimeDeltaForTesting(JNIEnv* env, | 325 void SetTimeDeltaForTesting(JNIEnv* env, |
| 324 const JavaParamRef<jclass>& clazz, | 326 const JavaParamRef<jclass>& clazz, |
| 325 jint days) { | 327 jint days) { |
| 326 AppBannerManager::SetTimeDeltaForTesting(days); | 328 AppBannerManager::SetTimeDeltaForTesting(days); |
| 327 } | 329 } |
| 328 | 330 |
| 329 } // namespace banners | 331 } // namespace banners |
| OLD | NEW |