Chromium Code Reviews| 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" |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 142 | 142 |
| 143 // Records that a banner was shown. The |event_name| corresponds to the RAPPOR | 143 // Records that a banner was shown. The |event_name| corresponds to the RAPPOR |
| 144 // metric being recorded. | 144 // metric being recorded. |
| 145 void RecordDidShowBanner(const std::string& event_name); | 145 void RecordDidShowBanner(const std::string& event_name); |
| 146 | 146 |
| 147 private: | 147 private: |
| 148 // Callbacks for data retrieval. | 148 // Callbacks for data retrieval. |
| 149 void OnDidHasManifest(bool has_manifest); | 149 void OnDidHasManifest(bool has_manifest); |
| 150 void OnDidGetManifest(const content::Manifest& manifest); | 150 void OnDidGetManifest(const content::Manifest& manifest); |
| 151 void OnDidCheckHasServiceWorker(bool has_service_worker); | 151 void OnDidCheckHasServiceWorker(bool has_service_worker); |
| 152 void OnAppIconFetched(const SkBitmap& bitmap); | 152 void OnAppIconFetched(const GURL& app_icon_url, const SkBitmap& bitmap); |
| 153 | 153 |
| 154 // Called when it is determined that the webapp has fulfilled the initial | 154 // Called when it is determined that the webapp has fulfilled the initial |
| 155 // criteria of having a manifest and a service worker. | 155 // criteria of having a manifest and a service worker. |
| 156 void OnHasServiceWorker(content::WebContents* web_contents); | 156 void OnHasServiceWorker(content::WebContents* web_contents); |
| 157 | 157 |
| 158 // Returns whether the given web app has already been installed. | 158 // Returns whether the given web app has already been installed. |
| 159 // Implemented on desktop platforms only. | 159 // Implemented on desktop platforms only. |
| 160 virtual bool IsWebAppInstalled(content::BrowserContext* browser_context, | 160 virtual bool IsWebAppInstalled(content::BrowserContext* browser_context, |
| 161 const GURL& start_url); | 161 const GURL& start_url); |
| 162 | 162 |
| 163 // Record that the banner could be shown at this point, if the triggering | 163 // Record that the banner could be shown at this point, if the triggering |
| 164 // heuristic allowed. | 164 // heuristic allowed. |
| 165 void RecordCouldShowBanner(); | 165 void RecordCouldShowBanner(); |
| 166 | 166 |
| 167 // Creates a banner for the app using the given |icon|. | 167 // Creates a banner for the app using the given icon. |
| 168 virtual void ShowBanner(const SkBitmap* icon, | 168 virtual void ShowBanner(const GURL& icon_url, |
|
dominickn
2016/06/15 19:17:14
This needs to also fix up AppBannerDataFetcherDesk
pkotwicz
2016/06/15 20:34:24
Done.
| |
| 169 const SkBitmap* icon, | |
| 169 const base::string16& title, | 170 const base::string16& title, |
| 170 const std::string& referrer) = 0; | 171 const std::string& referrer) = 0; |
| 171 | 172 |
| 172 // Returns whether the banner should be shown. | 173 // Returns whether the banner should be shown. |
| 173 bool CheckIfShouldShowBanner(); | 174 bool CheckIfShouldShowBanner(); |
| 174 | 175 |
| 175 // Returns whether the fetcher is active and web contents have not been | 176 // Returns whether the fetcher is active and web contents have not been |
| 176 // closed. | 177 // closed. |
| 177 bool CheckFetcherIsStillAlive(content::WebContents* web_contents); | 178 bool CheckFetcherIsStillAlive(content::WebContents* web_contents); |
| 178 | 179 |
| 179 // Returns whether the given Manifest is following the requirements to show | 180 // Returns whether the given Manifest is following the requirements to show |
| 180 // a web app banner. | 181 // a web app banner. |
| 181 static bool IsManifestValidForWebApp(const content::Manifest& manifest, | 182 static bool IsManifestValidForWebApp(const content::Manifest& manifest, |
| 182 content::WebContents* web_contents, | 183 content::WebContents* web_contents, |
| 183 bool is_debug_mode); | 184 bool is_debug_mode); |
| 184 | 185 |
| 185 const base::WeakPtr<Delegate> weak_delegate_; | 186 const base::WeakPtr<Delegate> weak_delegate_; |
| 186 const int ideal_icon_size_in_dp_; | 187 const int ideal_icon_size_in_dp_; |
| 187 const int minimum_icon_size_in_dp_; | 188 const int minimum_icon_size_in_dp_; |
| 188 base::ObserverList<Observer> observer_list_; | 189 base::ObserverList<Observer> observer_list_; |
| 189 bool is_active_; | 190 bool is_active_; |
| 190 bool was_canceled_by_page_; | 191 bool was_canceled_by_page_; |
| 191 bool page_requested_prompt_; | 192 bool page_requested_prompt_; |
| 192 const bool is_debug_mode_; | 193 const bool is_debug_mode_; |
| 193 ui::PageTransition transition_type_; | 194 ui::PageTransition transition_type_; |
| 194 int event_request_id_; | 195 int event_request_id_; |
| 196 GURL app_icon_url_; | |
| 195 std::unique_ptr<SkBitmap> app_icon_; | 197 std::unique_ptr<SkBitmap> app_icon_; |
| 196 std::string referrer_; | 198 std::string referrer_; |
| 197 | 199 |
| 198 GURL validated_url_; | 200 GURL validated_url_; |
| 199 base::string16 app_title_; | 201 base::string16 app_title_; |
| 200 content::Manifest web_app_data_; | 202 content::Manifest web_app_data_; |
| 201 | 203 |
| 202 friend struct content::BrowserThread::DeleteOnThread< | 204 friend struct content::BrowserThread::DeleteOnThread< |
| 203 content::BrowserThread::UI>; | 205 content::BrowserThread::UI>; |
| 204 friend class base::DeleteHelper<AppBannerDataFetcher>; | 206 friend class base::DeleteHelper<AppBannerDataFetcher>; |
| 205 friend class AppBannerDataFetcherUnitTest; | 207 friend class AppBannerDataFetcherUnitTest; |
| 206 friend class base::RefCounted<AppBannerDataFetcher>; | 208 friend class base::RefCounted<AppBannerDataFetcher>; |
| 207 DISALLOW_COPY_AND_ASSIGN(AppBannerDataFetcher); | 209 DISALLOW_COPY_AND_ASSIGN(AppBannerDataFetcher); |
| 208 }; | 210 }; |
| 209 | 211 |
| 210 } // namespace banners | 212 } // namespace banners |
| 211 | 213 |
| 212 #endif // CHROME_BROWSER_BANNERS_APP_BANNER_DATA_FETCHER_H_ | 214 #endif // CHROME_BROWSER_BANNERS_APP_BANNER_DATA_FETCHER_H_ |
| OLD | NEW |