OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_MANAGER_H_ | 5 #ifndef CHROME_BROWSER_ANDROID_BANNERS_APP_BANNER_MANAGER_H_ |
6 #define CHROME_BROWSER_ANDROID_BANNERS_APP_BANNER_MANAGER_H_ | 6 #define CHROME_BROWSER_ANDROID_BANNERS_APP_BANNER_MANAGER_H_ |
7 | 7 |
8 #include "base/android/jni_android.h" | 8 #include "base/android/jni_android.h" |
9 #include "base/android/jni_weak_ref.h" | 9 #include "base/android/jni_weak_ref.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
11 #include "chrome/browser/android/banners/app_banner_infobar_delegate.h" | 11 #include "chrome/browser/android/banners/app_banner_infobar_delegate.h" |
12 #include "chrome/browser/bitmap_fetcher/bitmap_fetcher.h" | 12 #include "chrome/browser/bitmap_fetcher/bitmap_fetcher.h" |
| 13 #include "chrome/browser/ui/android/infobars/app_banner_infobar.h" |
| 14 #include "components/infobars/core/infobar_manager.h" |
13 #include "content/public/browser/web_contents_observer.h" | 15 #include "content/public/browser/web_contents_observer.h" |
14 #include "content/public/common/manifest.h" | 16 #include "content/public/common/manifest.h" |
15 | 17 |
16 namespace content { | 18 namespace content { |
17 struct FrameNavigateParams; | 19 struct FrameNavigateParams; |
18 struct LoadCommittedDetails; | 20 struct LoadCommittedDetails; |
19 struct Manifest; | 21 struct Manifest; |
20 } // namespace content | 22 } // namespace content |
21 | 23 |
| 24 namespace infobars { |
| 25 class InfoBar; |
| 26 } // namspace infobars |
| 27 |
22 /** | 28 /** |
23 * Manages when an app banner is created or dismissed. | 29 * Manages when an app banner is created or dismissed. |
24 * | 30 * |
25 * Hooks the wiring together for getting the data for a particular app. | 31 * Hooks the wiring together for getting the data for a particular app. |
26 * Monitors at most one package at a time, and tracks the info for the | 32 * Monitors at most one package at a time, and tracks the info for the |
27 * most recent app that was requested. Any work in progress for other apps is | 33 * most recent app that was requested. Any work in progress for other apps is |
28 * discarded. | 34 * discarded. |
29 * | 35 * |
30 * The procedure for creating a banner spans multiple asynchronous calls across | 36 * The procedure for creating a banner spans multiple asynchronous calls across |
31 * the JNI boundary, as well as querying a Service to get info about the app. | 37 * the JNI boundary, as well as querying a Service to get info about the app. |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
98 const content::FrameNavigateParams& params) override; | 104 const content::FrameNavigateParams& params) override; |
99 void DidFinishLoad(content::RenderFrameHost* render_frame_host, | 105 void DidFinishLoad(content::RenderFrameHost* render_frame_host, |
100 const GURL& validated_url) override; | 106 const GURL& validated_url) override; |
101 bool OnMessageReceived(const IPC::Message& message) override; | 107 bool OnMessageReceived(const IPC::Message& message) override; |
102 | 108 |
103 // BitmapFetcherDelegate overrides. | 109 // BitmapFetcherDelegate overrides. |
104 void OnFetchComplete(const GURL url, const SkBitmap* bitmap) override; | 110 void OnFetchComplete(const GURL url, const SkBitmap* bitmap) override; |
105 | 111 |
106 // AppBannerInfoBarDelegate::AppDelegate overrides. | 112 // AppBannerInfoBarDelegate::AppDelegate overrides. |
107 void Block() const override; | 113 void Block() const override; |
108 void Install() const override; | 114 bool OnButtonClicked() const override; |
| 115 void OnInfoBarDestroyed() override; |
| 116 base::string16 GetTitle() const override; |
109 gfx::Image GetIcon() const override; | 117 gfx::Image GetIcon() const override; |
110 | 118 |
111 private: | 119 private: |
112 // Gets the preferred icon size for the banner icons. | 120 // Gets the preferred icon size for the banner icons. |
113 int GetPreferredIconSize(); | 121 int GetPreferredIconSize(); |
114 | 122 |
115 // Called when the manifest has been retrieved, or if there is no manifest to | 123 // Called when the manifest has been retrieved, or if there is no manifest to |
116 // retrieve. | 124 // retrieve. |
117 void OnDidGetManifest(const content::Manifest& manifest); | 125 void OnDidGetManifest(const content::Manifest& manifest); |
118 | 126 |
119 // Called when the renderer has returned information about the meta tag. | 127 // Called when the renderer has returned information about the meta tag. |
120 // If there is some metadata for the play store tag, this kicks off the | 128 // If there is some metadata for the play store tag, this kicks off the |
121 // process of showing a banner for the package designated by |tag_content| on | 129 // process of showing a banner for the package designated by |tag_content| on |
122 // the page at the |expected_url|. | 130 // the page at the |expected_url|. |
123 void OnDidRetrieveMetaTagContent(bool success, | 131 void OnDidRetrieveMetaTagContent(bool success, |
124 const std::string& tag_name, | 132 const std::string& tag_name, |
125 const std::string& tag_content, | 133 const std::string& tag_content, |
126 const GURL& expected_url); | 134 const GURL& expected_url); |
127 | 135 |
128 // Fetches the icon for an app. | 136 // Fetches the icon for an app. |
129 scoped_ptr<chrome::BitmapFetcher> fetcher_; | 137 scoped_ptr<chrome::BitmapFetcher> fetcher_; |
130 GURL validated_url_; | 138 GURL validated_url_; |
131 content::Manifest manifest_; | 139 GURL app_icon_url_; |
| 140 |
| 141 base::string16 app_title_; |
132 scoped_ptr<SkBitmap> app_icon_; | 142 scoped_ptr<SkBitmap> app_icon_; |
133 | 143 |
| 144 content::Manifest web_app_data_; |
| 145 |
| 146 // Weak pointer to the InfoBar that is being managed. |
| 147 AppBannerInfoBar* weak_infobar_ptr_; |
| 148 |
134 // AppBannerManager on the Java side. | 149 // AppBannerManager on the Java side. |
135 JavaObjectWeakGlobalRef weak_java_banner_view_manager_; | 150 JavaObjectWeakGlobalRef weak_java_banner_view_manager_; |
136 | 151 |
137 DISALLOW_COPY_AND_ASSIGN(AppBannerManager); | 152 DISALLOW_COPY_AND_ASSIGN(AppBannerManager); |
138 }; // class AppBannerManager | 153 }; // class AppBannerManager |
139 | 154 |
140 // Register native methods | 155 // Register native methods |
141 bool RegisterAppBannerManager(JNIEnv* env); | 156 bool RegisterAppBannerManager(JNIEnv* env); |
142 | 157 |
143 } // namespace banners | 158 } // namespace banners |
144 | 159 |
145 #endif // CHROME_BROWSER_ANDROID_BANNERS_APP_BANNER_MANAGER_H_ | 160 #endif // CHROME_BROWSER_ANDROID_BANNERS_APP_BANNER_MANAGER_H_ |
OLD | NEW |