Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(114)

Side by Side Diff: chrome/browser/android/banners/app_banner_infobar_delegate_android.h

Issue 2259553002: Make AppBannerInfoBar install WebAPK. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase. Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CHROME_BROWSER_ANDROID_BANNERS_APP_BANNER_INFOBAR_DELEGATE_ANDROID_H_ 5 #ifndef CHROME_BROWSER_ANDROID_BANNERS_APP_BANNER_INFOBAR_DELEGATE_ANDROID_H_
6 #define CHROME_BROWSER_ANDROID_BANNERS_APP_BANNER_INFOBAR_DELEGATE_ANDROID_H_ 6 #define CHROME_BROWSER_ANDROID_BANNERS_APP_BANNER_INFOBAR_DELEGATE_ANDROID_H_
7 7
8 #include "base/android/scoped_java_ref.h" 8 #include "base/android/scoped_java_ref.h"
9 #include "base/macros.h" 9 #include "base/macros.h"
10 #include "base/memory/weak_ptr.h" 10 #include "base/memory/weak_ptr.h"
(...skipping 20 matching lines...) Expand all
31 class AppBannerInfoBarDelegateAndroid : public ConfirmInfoBarDelegate { 31 class AppBannerInfoBarDelegateAndroid : public ConfirmInfoBarDelegate {
32 public: 32 public:
33 // Delegate for promoting a web app. 33 // Delegate for promoting a web app.
34 AppBannerInfoBarDelegateAndroid( 34 AppBannerInfoBarDelegateAndroid(
35 base::WeakPtr<AppBannerManager> weak_manager, 35 base::WeakPtr<AppBannerManager> weak_manager,
36 const base::string16& app_title, 36 const base::string16& app_title,
37 const GURL& manifest_url, 37 const GURL& manifest_url,
38 const content::Manifest& manifest, 38 const content::Manifest& manifest,
39 const GURL& icon_url, 39 const GURL& icon_url,
40 std::unique_ptr<SkBitmap> icon, 40 std::unique_ptr<SkBitmap> icon,
41 int event_request_id); 41 int event_request_id,
42 bool is_webapk);
42 43
43 // Delegate for promoting an Android app. 44 // Delegate for promoting an Android app.
44 AppBannerInfoBarDelegateAndroid( 45 AppBannerInfoBarDelegateAndroid(
45 const base::string16& app_title, 46 const base::string16& app_title,
46 const base::android::ScopedJavaGlobalRef<jobject>& native_app_data, 47 const base::android::ScopedJavaGlobalRef<jobject>& native_app_data,
47 std::unique_ptr<SkBitmap> icon, 48 std::unique_ptr<SkBitmap> icon,
48 const std::string& native_app_package, 49 const std::string& native_app_package,
49 const std::string& referrer, 50 const std::string& referrer,
50 int event_request_id); 51 int event_request_id);
51 52
52 ~AppBannerInfoBarDelegateAndroid() override; 53 ~AppBannerInfoBarDelegateAndroid() override;
53 54
54 // Called when the AppBannerInfoBar's button needs to be updated. 55 // Called when the AppBannerInfoBar's button needs to be updated.
55 void UpdateInstallState(JNIEnv* env, 56 void UpdateInstallState(JNIEnv* env,
56 const base::android::JavaParamRef<jobject>& obj); 57 const base::android::JavaParamRef<jobject>& obj);
57 58
58 // Called when the installation Intent has been handled and focus has been 59 // Called when the installation Intent has been handled and focus has been
59 // returned to Chrome. 60 // returned to Chrome.
60 void OnInstallIntentReturned(JNIEnv* env, 61 void OnInstallIntentReturned(JNIEnv* env,
61 const base::android::JavaParamRef<jobject>& obj, 62 const base::android::JavaParamRef<jobject>& obj,
62 jboolean jis_installing); 63 jboolean jis_installing);
63 64
64 // Called when the InstallerDelegate task has finished. 65 // Called when the InstallerDelegate task has finished.
65 void OnInstallFinished(JNIEnv* env, 66 void OnInstallFinished(JNIEnv* env,
66 const base::android::JavaParamRef<jobject>& obj, 67 const base::android::JavaParamRef<jobject>& obj,
67 jboolean success); 68 jboolean success);
68 69
70 // Check the status of the associated app banner infobar, and close it if
71 // the infobar is for a WebAPK, and the WebAPK wasn't installed.
72 bool CloseAppBannerInfobarIfNeeded(
73 JNIEnv* env,
74 const base::android::JavaParamRef<jobject>& obj);
75
69 private: 76 private:
70 void CreateJavaDelegate(); 77 void CreateJavaDelegate();
78 bool AcceptNativeApp(content::WebContents* web_contents);
79 bool AcceptWebApp(content::WebContents* web_contents);
80 bool AcceptWebApk(content::WebContents* web_contents);
71 void SendBannerAccepted(content::WebContents* web_contents, 81 void SendBannerAccepted(content::WebContents* web_contents,
72 const std::string& platform); 82 const std::string& platform);
83 void OnWebApkPackageNameAvailable(const std::string& webapk_package);
84 void RemoveInfoBarOnUIThread();
73 85
74 // ConfirmInfoBarDelegate: 86 // ConfirmInfoBarDelegate:
75 infobars::InfoBarDelegate::InfoBarIdentifier GetIdentifier() const override; 87 infobars::InfoBarDelegate::InfoBarIdentifier GetIdentifier() const override;
76 gfx::Image GetIcon() const override; 88 gfx::Image GetIcon() const override;
77 void InfoBarDismissed() override; 89 void InfoBarDismissed() override;
78 base::string16 GetMessageText() const override; 90 base::string16 GetMessageText() const override;
79 int GetButtons() const override; 91 int GetButtons() const override;
80 bool Accept() override; 92 bool Accept() override;
81 bool LinkClicked(WindowOpenDisposition disposition) override; 93 bool LinkClicked(WindowOpenDisposition disposition) override;
82 94
83 base::android::ScopedJavaGlobalRef<jobject> java_delegate_; 95 base::android::ScopedJavaGlobalRef<jobject> java_delegate_;
84 96
85 // Used to fetch the splash screen icon for webapps. 97 // Used to fetch the splash screen icon for webapps.
86 base::WeakPtr<AppBannerManager> weak_manager_; 98 base::WeakPtr<AppBannerManager> weak_manager_;
87 99
88 base::string16 app_title_; 100 base::string16 app_title_;
89 GURL manifest_url_; 101 GURL manifest_url_;
90 content::Manifest manifest_; 102 content::Manifest manifest_;
91 103
92 base::android::ScopedJavaGlobalRef<jobject> native_app_data_; 104 base::android::ScopedJavaGlobalRef<jobject> native_app_data_;
93 105
94 GURL icon_url_; 106 GURL icon_url_;
95 std::unique_ptr<SkBitmap> icon_; 107 std::unique_ptr<SkBitmap> icon_;
96 108
97 std::string native_app_package_; 109 std::string native_app_package_;
98 std::string referrer_; 110 std::string referrer_;
99 int event_request_id_; 111 int event_request_id_;
100 bool has_user_interaction_; 112 bool has_user_interaction_;
101 113
114 std::string webapk_package_name_;
115 bool is_webapk_;
116
102 DISALLOW_COPY_AND_ASSIGN(AppBannerInfoBarDelegateAndroid); 117 DISALLOW_COPY_AND_ASSIGN(AppBannerInfoBarDelegateAndroid);
103 }; // AppBannerInfoBarDelegateAndroid 118 }; // AppBannerInfoBarDelegateAndroid
104 119
105 // Register native methods. 120 // Register native methods.
106 bool RegisterAppBannerInfoBarDelegateAndroid(JNIEnv* env); 121 bool RegisterAppBannerInfoBarDelegateAndroid(JNIEnv* env);
107 122
108 } // namespace banners 123 } // namespace banners
109 124
110 #endif // CHROME_BROWSER_ANDROID_BANNERS_APP_BANNER_INFOBAR_DELEGATE_ANDROID_H_ 125 #endif // CHROME_BROWSER_ANDROID_BANNERS_APP_BANNER_INFOBAR_DELEGATE_ANDROID_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698