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_H_
6 #define CHROME_BROWSER_ANDROID_BANNERS_APP_BANNER_INFOBAR_DELEGATE_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"
17 } // namespace infobars
19 class AppBannerInfoBar
;
23 // Manages installation of an app being promoted by a webpage.
24 class AppBannerInfoBarDelegate
: public ConfirmInfoBarDelegate
{
26 // Creates a banner for the current page that promotes a native app.
27 // May return nullptr if the the infobar couldn't be created.
28 static AppBannerInfoBar
* CreateForNativeApp(
29 infobars::InfoBarManager
* infobar_manager
,
30 const base::string16
& app_title
,
32 const base::android::ScopedJavaGlobalRef
<jobject
>& app_data
,
33 const std::string
& app_package
);
35 // Creates a banner for the current page that promotes a web app.
36 // May return nullptr if the the infobar couldn't be created.
37 static AppBannerInfoBar
* CreateForWebApp(
38 infobars::InfoBarManager
* infobar_manager
,
39 const base::string16
& app_title
,
41 const content::Manifest
& web_app_data
);
43 ~AppBannerInfoBarDelegate() override
;
45 // Called when the AppBannerInfoBar's button needs to be updated.
46 void UpdateInstallState(JNIEnv
* env
, jobject obj
);
48 // Called when the installation Intent has been handled and focus has been
49 // returned to Chrome.
50 void OnInstallIntentReturned(JNIEnv
* env
,
52 jboolean jis_installing
);
54 // Called when the InstallerDelegate task has finished.
55 void OnInstallFinished(JNIEnv
* env
,
60 AppBannerInfoBarDelegate(
61 const base::string16
& app_title
,
63 const content::Manifest
& web_app_data
,
64 const base::android::ScopedJavaGlobalRef
<jobject
>& native_app_data
,
65 const std::string
& native_app_package
);
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 content::Manifest web_app_data_
;
82 base::android::ScopedJavaGlobalRef
<jobject
> native_app_data_
;
83 std::string native_app_package_
;
85 DISALLOW_COPY_AND_ASSIGN(AppBannerInfoBarDelegate
);
86 }; // AppBannerInfoBarDelegate
88 // Register native methods.
89 bool RegisterAppBannerInfoBarDelegate(JNIEnv
* env
);
91 } // namespace banners
93 #endif // CHROME_BROWSER_ANDROID_BANNERS_APP_BANNER_INFOBAR_DELEGATE_H_