Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4309)

Unified Diff: chrome/browser/android/banners/app_banner_data_fetcher_android.cc

Issue 2156113002: Replace AppBannerDataFetcher with InstallableManager. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@banner-refactor
Patch Set: Naming, includes Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/android/banners/app_banner_data_fetcher_android.cc
diff --git a/chrome/browser/android/banners/app_banner_data_fetcher_android.cc b/chrome/browser/android/banners/app_banner_data_fetcher_android.cc
deleted file mode 100644
index 3357f612ef13a9e166dcaed5975ca2ed6ee5632b..0000000000000000000000000000000000000000
--- a/chrome/browser/android/banners/app_banner_data_fetcher_android.cc
+++ /dev/null
@@ -1,121 +0,0 @@
-// Copyright 2015 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "chrome/browser/android/banners/app_banner_data_fetcher_android.h"
-
-#include <utility>
-
-#include "base/bind.h"
-#include "base/callback.h"
-#include "base/memory/ptr_util.h"
-#include "chrome/browser/android/banners/app_banner_infobar_delegate_android.h"
-#include "chrome/browser/android/shortcut_helper.h"
-#include "chrome/browser/banners/app_banner_metrics.h"
-#include "chrome/browser/infobars/infobar_service.h"
-#include "chrome/browser/manifest/manifest_icon_selector.h"
-#include "chrome/browser/ui/android/infobars/app_banner_infobar_android.h"
-#include "third_party/skia/include/core/SkBitmap.h"
-
-namespace banners {
-
-AppBannerDataFetcherAndroid::AppBannerDataFetcherAndroid(
- content::WebContents* web_contents,
- base::WeakPtr<Delegate> weak_delegate,
- int ideal_icon_size_in_dp,
- int minimum_icon_size_in_dp,
- int ideal_splash_image_size_in_dp,
- int minimum_splash_image_size_in_dp,
- bool is_debug_mode)
- : AppBannerDataFetcher(web_contents,
- weak_delegate,
- ideal_icon_size_in_dp,
- minimum_icon_size_in_dp,
- is_debug_mode),
- ideal_splash_image_size_in_dp_(ideal_splash_image_size_in_dp),
- minimum_splash_image_size_in_dp_(minimum_splash_image_size_in_dp) {}
-
-AppBannerDataFetcherAndroid::~AppBannerDataFetcherAndroid() {
-}
-
-std::string AppBannerDataFetcherAndroid::GetBannerType() {
- return native_app_data_.is_null()
- ? AppBannerDataFetcher::GetBannerType() : "android";
-}
-
-bool AppBannerDataFetcherAndroid::ContinueFetching(
- const base::string16& app_title,
- const std::string& app_package,
- const base::android::JavaRef<jobject>& app_data,
- const GURL& image_url) {
- set_app_title(app_title);
- native_app_package_ = app_package;
- native_app_data_.Reset(app_data);
- return FetchAppIcon(GetWebContents(), image_url);
-}
-
-std::string AppBannerDataFetcherAndroid::GetAppIdentifier() {
- return native_app_data_.is_null()
- ? AppBannerDataFetcher::GetAppIdentifier() : native_app_package_;
-}
-
-base::Closure AppBannerDataFetcherAndroid::FetchWebappSplashScreenImageCallback(
- const std::string& webapp_id) {
- content::WebContents* web_contents = GetWebContents();
- DCHECK(web_contents);
-
- GURL image_url = ManifestIconSelector::FindBestMatchingIcon(
- manifest().icons, ideal_splash_image_size_in_dp_,
- minimum_splash_image_size_in_dp_);
-
- return base::Bind(&ShortcutHelper::FetchSplashScreenImage,
- web_contents, image_url, ideal_splash_image_size_in_dp_,
- minimum_splash_image_size_in_dp_, webapp_id);
-}
-
-bool AppBannerDataFetcherAndroid::IsWebAppInstalled(
- content::BrowserContext* browser_context,
- const GURL& start_url) {
- // Check whether a WebAPK is installed in order to block showing the app
- // banner if a WebAPK is installed even after a user clears Chrome's data.
- // This function does not check whether a non-WebAPK web app is installed.
- return ShortcutHelper::IsWebApkInstalled(start_url);
-}
-
-void AppBannerDataFetcherAndroid::ShowBanner(const GURL& icon_url,
- const SkBitmap* icon,
- const base::string16& title,
- const std::string& referrer) {
- content::WebContents* web_contents = GetWebContents();
- DCHECK(web_contents);
-
- infobars::InfoBar* infobar = nullptr;
- if (native_app_data_.is_null()) {
- std::unique_ptr<AppBannerInfoBarDelegateAndroid> delegate(
- new AppBannerInfoBarDelegateAndroid(event_request_id(), this, title,
- icon_url, new SkBitmap(*icon),
- manifest_url(), manifest()));
-
- infobar = new AppBannerInfoBarAndroid(std::move(delegate),
- manifest().start_url);
- if (infobar) {
- RecordDidShowBanner("AppBanner.WebApp.Shown");
- TrackDisplayEvent(DISPLAY_EVENT_WEB_APP_BANNER_CREATED);
- }
- } else {
- std::unique_ptr<AppBannerInfoBarDelegateAndroid> delegate(
- new AppBannerInfoBarDelegateAndroid(
- event_request_id(), title, new SkBitmap(*icon), native_app_data_,
- native_app_package_, referrer));
- infobar =
- new AppBannerInfoBarAndroid(std::move(delegate), native_app_data_);
- if (infobar) {
- RecordDidShowBanner("AppBanner.NativeApp.Shown");
- TrackDisplayEvent(DISPLAY_EVENT_NATIVE_APP_BANNER_CREATED);
- }
- }
- InfoBarService::FromWebContents(web_contents)
- ->AddInfoBar(base::WrapUnique(infobar));
-}
-
-} // namespace banners

Powered by Google App Engine
This is Rietveld 408576698