Add more checks to investigate SupervisedUserPrefStore crash at startup.
[chromium-blink-merge.git] / chrome / browser / android / banners / app_banner_infobar_delegate.h
blob3601290de17364bc3685f49ca0101ee889d351ae
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"
13 #include "url/gurl.h"
15 namespace infobars {
16 class InfoBarManager;
17 } // namespace infobars
19 class AppBannerInfoBar;
21 namespace banners {
23 // Manages installation of an app being promoted by a webpage.
24 class AppBannerInfoBarDelegate : public ConfirmInfoBarDelegate {
25 public:
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,
31 SkBitmap* app_icon,
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,
40 SkBitmap* app_icon,
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,
51 jobject obj,
52 jboolean jis_installing);
54 // Called when the InstallerDelegate task has finished.
55 void OnInstallFinished(JNIEnv* env,
56 jobject obj,
57 jboolean success);
59 // InfoBarDelegate overrides.
60 gfx::Image GetIcon() const override;
61 void InfoBarDismissed() override;
63 // ConfirmInfoBarDelegate overrides.
64 base::string16 GetMessageText() const override;
65 int GetButtons() const override;
66 bool Accept() override;
67 bool LinkClicked(WindowOpenDisposition disposition) override;
69 private:
70 AppBannerInfoBarDelegate(
71 const base::string16& app_title,
72 SkBitmap* app_icon,
73 const content::Manifest& web_app_data,
74 const base::android::ScopedJavaGlobalRef<jobject>& native_app_data,
75 const std::string& native_app_package);
77 base::android::ScopedJavaGlobalRef<jobject> java_delegate_;
79 base::string16 app_title_;
80 scoped_ptr<SkBitmap> app_icon_;
82 content::Manifest web_app_data_;
84 base::android::ScopedJavaGlobalRef<jobject> native_app_data_;
85 std::string native_app_package_;
87 DISALLOW_COPY_AND_ASSIGN(AppBannerInfoBarDelegate);
88 }; // AppBannerInfoBarDelegate
90 // Register native methods.
91 bool RegisterAppBannerInfoBarDelegate(JNIEnv* env);
93 } // namespace banners
95 #endif // CHROME_BROWSER_ANDROID_BANNERS_APP_BANNER_INFOBAR_DELEGATE_H_