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 "components/infobars/core/confirm_infobar_delegate.h"
11 #include "content/public/common/manifest.h"
12 #include "ui/gfx/image/image.h"
21 } // namespace infobars
23 class AppBannerInfoBar
;
27 // Manages installation of an app being promoted by a webpage.
28 class AppBannerInfoBarDelegateAndroid
: public ConfirmInfoBarDelegate
{
30 // Delegate for promoting a web app.
31 AppBannerInfoBarDelegateAndroid(
33 const base::string16
& app_title
,
35 const content::Manifest
& web_app_data
);
37 // Delegate for promoting an Android app.
38 AppBannerInfoBarDelegateAndroid(
40 const base::string16
& app_title
,
42 const base::android::ScopedJavaGlobalRef
<jobject
>& native_app_data
,
43 const std::string
& native_app_package
);
45 ~AppBannerInfoBarDelegateAndroid() override
;
47 // Called when the AppBannerInfoBar's button needs to be updated.
48 void UpdateInstallState(JNIEnv
* env
, jobject obj
);
50 // Called when the installation Intent has been handled and focus has been
51 // returned to Chrome.
52 void OnInstallIntentReturned(JNIEnv
* env
,
54 jboolean jis_installing
);
56 // Called when the InstallerDelegate task has finished.
57 void OnInstallFinished(JNIEnv
* env
,
62 void CreateJavaDelegate();
63 void SendBannerAccepted(content::WebContents
* web_contents
,
64 const std::string
& platform
);
66 // ConfirmInfoBarDelegate:
67 gfx::Image
GetIcon() const override
;
68 void InfoBarDismissed() override
;
69 base::string16
GetMessageText() const override
;
70 int GetButtons() const override
;
71 bool Accept() override
;
72 bool LinkClicked(WindowOpenDisposition disposition
) override
;
74 base::android::ScopedJavaGlobalRef
<jobject
> java_delegate_
;
76 base::string16 app_title_
;
77 scoped_ptr
<SkBitmap
> app_icon_
;
79 int event_request_id_
;
80 content::Manifest web_app_data_
;
82 base::android::ScopedJavaGlobalRef
<jobject
> native_app_data_
;
83 std::string native_app_package_
;
84 bool has_user_interaction_
;
86 DISALLOW_COPY_AND_ASSIGN(AppBannerInfoBarDelegateAndroid
);
87 }; // AppBannerInfoBarDelegateAndroid
89 // Register native methods.
90 bool RegisterAppBannerInfoBarDelegateAndroid(JNIEnv
* env
);
92 } // namespace banners
94 #endif // CHROME_BROWSER_ANDROID_BANNERS_APP_BANNER_INFOBAR_DELEGATE_ANDROID_H_