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 #ifndef CHROME_BROWSER_ANDROID_BANNERS_APP_BANNER_INFOBAR_DELEGATE_ANDROID_H_
6 #define CHROME_BROWSER_ANDROID_BANNERS_APP_BANNER_INFOBAR_DELEGATE_ANDROID_H_
8 #include "base/android/scoped_java_ref.h"
9 #include "base/strings/string16.h"
10 #include "chrome/browser/android/banners/app_banner_data_fetcher_android.h"
11 #include "components/infobars/core/confirm_infobar_delegate.h"
12 #include "content/public/common/manifest.h"
13 #include "ui/gfx/image/image.h"
22 } // namespace infobars
24 class AppBannerInfoBar
;
28 // Manages installation of an app being promoted by a webpage.
29 class AppBannerInfoBarDelegateAndroid
: public ConfirmInfoBarDelegate
{
31 // Delegate for promoting a web app.
32 AppBannerInfoBarDelegateAndroid(
34 scoped_refptr
<AppBannerDataFetcherAndroid
> data_fetcher
,
35 const base::string16
& app_title
,
37 const content::Manifest
& web_app_data
);
39 // Delegate for promoting an Android app.
40 AppBannerInfoBarDelegateAndroid(
42 const base::string16
& app_title
,
44 const base::android::ScopedJavaGlobalRef
<jobject
>& native_app_data
,
45 const std::string
& native_app_package
,
46 const std::string
& referrer
);
48 ~AppBannerInfoBarDelegateAndroid() override
;
50 // Called when the AppBannerInfoBar's button needs to be updated.
51 void UpdateInstallState(JNIEnv
* env
, jobject obj
);
53 // Called when the installation Intent has been handled and focus has been
54 // returned to Chrome.
55 void OnInstallIntentReturned(JNIEnv
* env
,
57 jboolean jis_installing
);
59 // Called when the InstallerDelegate task has finished.
60 void OnInstallFinished(JNIEnv
* env
,
65 void CreateJavaDelegate();
66 void SendBannerAccepted(content::WebContents
* web_contents
,
67 const std::string
& platform
);
69 // ConfirmInfoBarDelegate:
70 gfx::Image
GetIcon() const override
;
71 void InfoBarDismissed() override
;
72 base::string16
GetMessageText() const override
;
73 int GetButtons() const override
;
74 bool Accept() override
;
75 bool LinkClicked(WindowOpenDisposition disposition
) override
;
77 base::android::ScopedJavaGlobalRef
<jobject
> java_delegate_
;
79 // Used to fetch the splash screen icon for webapps.
80 scoped_refptr
<AppBannerDataFetcherAndroid
> data_fetcher_
;
82 base::string16 app_title_
;
83 scoped_ptr
<SkBitmap
> app_icon_
;
85 int event_request_id_
;
86 content::Manifest web_app_data_
;
88 base::android::ScopedJavaGlobalRef
<jobject
> native_app_data_
;
89 std::string native_app_package_
;
90 std::string referrer_
;
91 bool has_user_interaction_
;
93 DISALLOW_COPY_AND_ASSIGN(AppBannerInfoBarDelegateAndroid
);
94 }; // AppBannerInfoBarDelegateAndroid
96 // Register native methods.
97 bool RegisterAppBannerInfoBarDelegateAndroid(JNIEnv
* env
);
99 } // namespace banners
101 #endif // CHROME_BROWSER_ANDROID_BANNERS_APP_BANNER_INFOBAR_DELEGATE_ANDROID_H_