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
3 // found in the LICENSE file.
5 #include "chrome/browser/android/banners/app_banner_data_fetcher_android.h"
7 #include "chrome/browser/android/banners/app_banner_infobar_delegate.h"
8 #include "chrome/browser/ui/android/infobars/app_banner_infobar.h"
9 #include "third_party/skia/include/core/SkBitmap.h"
13 AppBannerDataFetcherAndroid::AppBannerDataFetcherAndroid(
14 content::WebContents
* web_contents
,
15 base::WeakPtr
<Delegate
> weak_delegate
,
17 : AppBannerDataFetcher(web_contents
, weak_delegate
, ideal_icon_size
) {
20 AppBannerDataFetcherAndroid::~AppBannerDataFetcherAndroid() {
23 std::string
AppBannerDataFetcherAndroid::GetBannerType() {
24 return native_app_data_
.is_null()
25 ? AppBannerDataFetcher::GetBannerType() : "android";
28 bool AppBannerDataFetcherAndroid::ContinueFetching(
29 const base::string16
& app_title
,
30 const std::string
& app_package
,
31 base::android::ScopedJavaLocalRef
<jobject
> app_data
,
32 const GURL
& image_url
) {
33 set_app_title(app_title
);
34 native_app_package_
= app_package
;
35 native_app_data_
.Reset(app_data
);
36 return FetchIcon(image_url
);
39 std::string
AppBannerDataFetcherAndroid::GetAppIdentifier() {
40 return native_app_data_
.is_null()
41 ? AppBannerDataFetcher::GetAppIdentifier() : native_app_package_
;
44 infobars::InfoBar
* AppBannerDataFetcherAndroid::CreateBanner(
46 const base::string16
& title
) {
47 content::WebContents
* web_contents
= GetWebContents();
50 infobars::InfoBar
* infobar
= nullptr;
51 if (native_app_data_
.is_null()) {
52 scoped_ptr
<AppBannerInfoBarDelegate
> delegate(
53 new AppBannerInfoBarDelegate(title
,
57 infobar
= new AppBannerInfoBar(delegate
.Pass(), web_app_data().start_url
);
59 RecordDidShowBanner("AppBanner.WebApp.Shown");
61 scoped_ptr
<AppBannerInfoBarDelegate
> delegate(
62 new AppBannerInfoBarDelegate(title
,
65 native_app_package_
));
66 infobar
= new AppBannerInfoBar(delegate
.Pass(), native_app_data_
);
68 RecordDidShowBanner("AppBanner.NativeApp.Shown");
74 } // namespace banners