| OLD | NEW |
| 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_BANNERS_APP_BANNER_DATA_FETCHER_H_ | 5 #ifndef CHROME_BROWSER_BANNERS_APP_BANNER_DATA_FETCHER_H_ |
| 6 #define CHROME_BROWSER_BANNERS_APP_BANNER_DATA_FETCHER_H_ | 6 #define CHROME_BROWSER_BANNERS_APP_BANNER_DATA_FETCHER_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 | 9 |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| 11 #include "base/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
| 12 #include "base/memory/weak_ptr.h" | 12 #include "base/memory/weak_ptr.h" |
| 13 #include "base/observer_list.h" | 13 #include "base/observer_list.h" |
| 14 #include "base/time/time.h" | 14 #include "base/time/time.h" |
| 15 #include "chrome/browser/banners/app_banner_debug_log.h" |
| 15 #include "chrome/common/web_application_info.h" | 16 #include "chrome/common/web_application_info.h" |
| 16 #include "content/public/browser/browser_thread.h" | 17 #include "content/public/browser/browser_thread.h" |
| 17 #include "content/public/browser/web_contents.h" | 18 #include "content/public/browser/web_contents.h" |
| 18 #include "content/public/browser/web_contents_observer.h" | 19 #include "content/public/browser/web_contents_observer.h" |
| 19 #include "content/public/common/manifest.h" | 20 #include "content/public/common/manifest.h" |
| 20 #include "third_party/WebKit/public/platform/modules/app_banner/WebAppBannerProm
ptReply.h" | 21 #include "third_party/WebKit/public/platform/modules/app_banner/WebAppBannerProm
ptReply.h" |
| 21 | 22 |
| 22 namespace chrome { | 23 namespace chrome { |
| 23 class BitmapFetcher; | 24 class BitmapFetcher; |
| 24 } // namespace chrome | 25 } // namespace chrome |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 123 void OnBannerPromptReply(content::RenderFrameHost* render_frame_host, | 124 void OnBannerPromptReply(content::RenderFrameHost* render_frame_host, |
| 124 int request_id, | 125 int request_id, |
| 125 blink::WebAppBannerPromptReply reply, | 126 blink::WebAppBannerPromptReply reply, |
| 126 std::string referrer); | 127 std::string referrer); |
| 127 | 128 |
| 128 // Called when the client has prevented a banner from being shown, and is | 129 // Called when the client has prevented a banner from being shown, and is |
| 129 // now requesting that it be shown later. | 130 // now requesting that it be shown later. |
| 130 void OnRequestShowAppBanner(content::RenderFrameHost* render_frame_host, | 131 void OnRequestShowAppBanner(content::RenderFrameHost* render_frame_host, |
| 131 int request_id); | 132 int request_id); |
| 132 | 133 |
| 134 // Returns whether the given Manifest meets the requirements to show a web app |
| 135 // banner. If not, sets |code| to the reason why. |
| 136 virtual bool CheckManifest(const content::Manifest& manifest, |
| 137 OutputDeveloperMessageCode* code); |
| 138 |
| 133 content::WebContents* GetWebContents(); | 139 content::WebContents* GetWebContents(); |
| 134 virtual std::string GetAppIdentifier(); | 140 virtual std::string GetAppIdentifier(); |
| 135 const content::Manifest& web_app_data() { return web_app_data_; } | 141 const content::Manifest& web_app_data() { return web_app_data_; } |
| 136 void set_app_title(const base::string16& title) { app_title_ = title; } | 142 void set_app_title(const base::string16& title) { app_title_ = title; } |
| 137 int event_request_id() { return event_request_id_; } | 143 int event_request_id() { return event_request_id_; } |
| 138 | 144 |
| 139 // Fetches the icon at the given URL asynchronously, returning |false| if a | 145 // Fetches the icon at the given URL asynchronously, returning |false| if a |
| 140 // load could not be started. | 146 // load could not be started. |
| 141 bool FetchAppIcon(content::WebContents* web_contents, const GURL& url); | 147 bool FetchAppIcon(content::WebContents* web_contents, const GURL& url); |
| 142 | 148 |
| (...skipping 26 matching lines...) Expand all Loading... |
| 169 const base::string16& title, | 175 const base::string16& title, |
| 170 const std::string& referrer) = 0; | 176 const std::string& referrer) = 0; |
| 171 | 177 |
| 172 // Returns whether the banner should be shown. | 178 // Returns whether the banner should be shown. |
| 173 bool CheckIfShouldShowBanner(); | 179 bool CheckIfShouldShowBanner(); |
| 174 | 180 |
| 175 // Returns whether the fetcher is active and web contents have not been | 181 // Returns whether the fetcher is active and web contents have not been |
| 176 // closed. | 182 // closed. |
| 177 bool CheckFetcherIsStillAlive(content::WebContents* web_contents); | 183 bool CheckFetcherIsStillAlive(content::WebContents* web_contents); |
| 178 | 184 |
| 179 // Returns whether the given Manifest is following the requirements to show | |
| 180 // a web app banner. | |
| 181 static bool IsManifestValidForWebApp(const content::Manifest& manifest, | |
| 182 content::WebContents* web_contents, | |
| 183 bool is_debug_mode); | |
| 184 | |
| 185 const base::WeakPtr<Delegate> weak_delegate_; | 185 const base::WeakPtr<Delegate> weak_delegate_; |
| 186 const int ideal_icon_size_in_dp_; | 186 const int ideal_icon_size_in_dp_; |
| 187 const int minimum_icon_size_in_dp_; | 187 const int minimum_icon_size_in_dp_; |
| 188 base::ObserverList<Observer> observer_list_; | 188 base::ObserverList<Observer> observer_list_; |
| 189 bool is_active_; | 189 bool is_active_; |
| 190 bool was_canceled_by_page_; | 190 bool was_canceled_by_page_; |
| 191 bool page_requested_prompt_; | 191 bool page_requested_prompt_; |
| 192 const bool is_debug_mode_; | 192 const bool is_debug_mode_; |
| 193 ui::PageTransition transition_type_; | 193 ui::PageTransition transition_type_; |
| 194 int event_request_id_; | 194 int event_request_id_; |
| 195 std::unique_ptr<SkBitmap> app_icon_; | 195 std::unique_ptr<SkBitmap> app_icon_; |
| 196 std::string referrer_; | 196 std::string referrer_; |
| 197 | 197 |
| 198 GURL validated_url_; | 198 GURL validated_url_; |
| 199 base::string16 app_title_; | 199 base::string16 app_title_; |
| 200 content::Manifest web_app_data_; | 200 content::Manifest web_app_data_; |
| 201 | 201 |
| 202 friend struct content::BrowserThread::DeleteOnThread< | 202 friend struct content::BrowserThread::DeleteOnThread< |
| 203 content::BrowserThread::UI>; | 203 content::BrowserThread::UI>; |
| 204 friend class base::DeleteHelper<AppBannerDataFetcher>; | 204 friend class base::DeleteHelper<AppBannerDataFetcher>; |
| 205 friend class AppBannerDataFetcherUnitTest; | 205 friend class AppBannerDataFetcherUnitTest; |
| 206 friend class base::RefCounted<AppBannerDataFetcher>; | 206 friend class base::RefCounted<AppBannerDataFetcher>; |
| 207 DISALLOW_COPY_AND_ASSIGN(AppBannerDataFetcher); | 207 DISALLOW_COPY_AND_ASSIGN(AppBannerDataFetcher); |
| 208 }; | 208 }; |
| 209 | 209 |
| 210 } // namespace banners | 210 } // namespace banners |
| 211 | 211 |
| 212 #endif // CHROME_BROWSER_BANNERS_APP_BANNER_DATA_FETCHER_H_ | 212 #endif // CHROME_BROWSER_BANNERS_APP_BANNER_DATA_FETCHER_H_ |
| OLD | NEW |