diff options
Diffstat (limited to 'chrome/browser/android/banners/app_banner_manager_android.cc')
| -rw-r--r-- | chrome/browser/android/banners/app_banner_manager_android.cc | 45 |
1 files changed, 29 insertions, 16 deletions
diff --git a/chrome/browser/android/banners/app_banner_manager_android.cc b/chrome/browser/android/banners/app_banner_manager_android.cc index 36b4045..b1915cc 100644 --- a/chrome/browser/android/banners/app_banner_manager_android.cc +++ b/chrome/browser/android/banners/app_banner_manager_android.cc @@ -56,8 +56,9 @@ void AppBannerManagerAndroid::ReplaceWebContents( bool AppBannerManagerAndroid::HandleNonWebApp(const std::string& platform, const GURL& url, - const std::string& id) { - if (!CheckPlatformAndId(platform, id)) + const std::string& id, + bool is_debug_mode) { + if (!CheckPlatformAndId(platform, id, is_debug_mode)) return false; banners::TrackDisplayEvent(DISPLAY_EVENT_NATIVE_APP_BANNER_REQUESTED); @@ -70,8 +71,8 @@ bool AppBannerManagerAndroid::HandleNonWebApp(const std::string& platform, std::string id_from_app_url = ExtractQueryValueForName(url, kIdName); if (id_from_app_url.size() && id != id_from_app_url) { - banners::OutputDeveloperDebugMessage(web_contents(), - banners::kIgnoredIdsDoNotMatch); + banners::OutputDeveloperDebugMessage( + web_contents(), banners::kIgnoredIdsDoNotMatch, is_debug_mode); return false; } @@ -99,27 +100,31 @@ bool AppBannerManagerAndroid::HandleNonWebApp(const std::string& platform, } bool AppBannerManagerAndroid::CheckPlatformAndId(const std::string& platform, - const std::string& id) { + const std::string& id, + bool is_debug_mode) { if (platform != kPlayPlatform) { banners::OutputDeveloperDebugMessage( - web_contents(), platform + banners::kIgnoredNotSupportedOnAndroid); + web_contents(), platform + banners::kIgnoredNotSupportedOnAndroid, + is_debug_mode); return false; } if (id.empty()) { - banners::OutputDeveloperDebugMessage(web_contents(), banners::kIgnoredNoId); + banners::OutputDeveloperDebugMessage(web_contents(), banners::kIgnoredNoId, + is_debug_mode); return false; } return true; } -bool AppBannerManagerAndroid::CheckFetcherMatchesContents() { +bool AppBannerManagerAndroid::CheckFetcherMatchesContents(bool is_debug_mode) { if (!web_contents()) return false; if (!data_fetcher() || data_fetcher()->validated_url() != web_contents()->GetURL()) { banners::OutputDeveloperNotShownMessage( - web_contents(), banners::kUserNavigatedBeforeBannerShown); + web_contents(), banners::kUserNavigatedBeforeBannerShown, + is_debug_mode); return false; } return true; @@ -142,14 +147,14 @@ std::string AppBannerManagerAndroid::ExtractQueryValueForName( } AppBannerDataFetcher* AppBannerManagerAndroid::CreateAppBannerDataFetcher( - base::WeakPtr<Delegate> weak_delegate) { + base::WeakPtr<Delegate> weak_delegate, + bool is_debug_mode) { return new AppBannerDataFetcherAndroid( - web_contents(), - weak_delegate, + web_contents(), weak_delegate, ShortcutHelper::GetIdealHomescreenIconSizeInDp(), ShortcutHelper::GetMinimumHomescreenIconSizeInDp(), ShortcutHelper::GetIdealSplashImageSizeInDp(), - ShortcutHelper::GetMinimumSplashImageSizeInDp()); + ShortcutHelper::GetMinimumSplashImageSizeInDp(), is_debug_mode); } bool AppBannerManagerAndroid::OnAppDetailsRetrieved( @@ -159,13 +164,13 @@ bool AppBannerManagerAndroid::OnAppDetailsRetrieved( const JavaParamRef<jstring>& japp_title, const JavaParamRef<jstring>& japp_package, const JavaParamRef<jstring>& jicon_url) { - if (!CheckFetcherMatchesContents()) + AppBannerDataFetcherAndroid* android_fetcher = + static_cast<AppBannerDataFetcherAndroid*>(data_fetcher().get()); + if (!CheckFetcherMatchesContents(android_fetcher->is_debug_mode())) return false; GURL image_url = GURL(ConvertJavaStringToUTF8(env, jicon_url)); - AppBannerDataFetcherAndroid* android_fetcher = - static_cast<AppBannerDataFetcherAndroid*>(data_fetcher().get()); return android_fetcher->ContinueFetching( ConvertJavaStringToUTF16(env, japp_title), ConvertJavaStringToUTF8(env, japp_package), japp_data, image_url); @@ -177,6 +182,14 @@ bool AppBannerManagerAndroid::IsFetcherActive( return AppBannerManager::IsFetcherActive(); } +void AppBannerManagerAndroid::RequestAppBanner( + JNIEnv* env, + const JavaParamRef<jobject>& obj) { + AppBannerManager::RequestAppBanner(web_contents()->GetMainFrame(), + web_contents()->GetLastCommittedURL(), + true); +} + // static bool AppBannerManagerAndroid::Register(JNIEnv* env) { return RegisterNativesImpl(env); |
