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
,
44 const std::string
& referrer
);
46 ~AppBannerInfoBarDelegateAndroid() override
;
48 // Called when the AppBannerInfoBar's button needs to be updated.
49 void UpdateInstallState(JNIEnv
* env
, jobject obj
);
51 // Called when the installation Intent has been handled and focus has been
52 // returned to Chrome.
53 void OnInstallIntentReturned(JNIEnv
* env
,
55 jboolean jis_installing
);
57 // Called when the InstallerDelegate task has finished.
58 void OnInstallFinished(JNIEnv
* env
,
63 void CreateJavaDelegate();
64 void SendBannerAccepted(content::WebContents
* web_contents
,
65 const std::string
& platform
);
67 // ConfirmInfoBarDelegate:
68 gfx::Image
GetIcon() const override
;
69 void InfoBarDismissed() override
;
70 base::string16
GetMessageText() const override
;
71 int GetButtons() const override
;
72 bool Accept() override
;
73 bool LinkClicked(WindowOpenDisposition disposition
) override
;
75 base::android::ScopedJavaGlobalRef
<jobject
> java_delegate_
;
77 base::string16 app_title_
;
78 scoped_ptr
<SkBitmap
> app_icon_
;
80 int event_request_id_
;
81 content::Manifest web_app_data_
;
83 base::android::ScopedJavaGlobalRef
<jobject
> native_app_data_
;
84 std::string native_app_package_
;
85 std::string referrer_
;
86 bool has_user_interaction_
;
88 DISALLOW_COPY_AND_ASSIGN(AppBannerInfoBarDelegateAndroid
);
89 }; // AppBannerInfoBarDelegateAndroid
91 // Register native methods.
92 bool RegisterAppBannerInfoBarDelegateAndroid(JNIEnv
* env
);
94 } // namespace banners
96 #endif // CHROME_BROWSER_ANDROID_BANNERS_APP_BANNER_INFOBAR_DELEGATE_ANDROID_H_