| 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 #include "chrome/browser/android/webapps/add_to_homescreen_data_fetcher.h" | 5 #include "chrome/browser/android/webapps/add_to_homescreen_data_fetcher.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/callback.h" | 10 #include "base/callback.h" |
| 11 #include "base/location.h" | 11 #include "base/location.h" |
| 12 #include "base/strings/string16.h" | 12 #include "base/strings/string16.h" |
| 13 #include "chrome/browser/android/offline_pages/offline_page_utils.h" | 13 #include "chrome/browser/android/offline_pages/offline_page_utils.h" |
| 14 #include "chrome/browser/android/shortcut_helper.h" | 14 #include "chrome/browser/android/shortcut_helper.h" |
| 15 #include "chrome/browser/android/webapk/webapk_web_manifest_checker.h" |
| 15 #include "chrome/browser/favicon/favicon_service_factory.h" | 16 #include "chrome/browser/favicon/favicon_service_factory.h" |
| 16 #include "chrome/browser/installable/installable_manager.h" | 17 #include "chrome/browser/installable/installable_manager.h" |
| 17 #include "chrome/browser/manifest/manifest_icon_selector.h" | 18 #include "chrome/browser/manifest/manifest_icon_selector.h" |
| 18 #include "chrome/browser/profiles/profile.h" | 19 #include "chrome/browser/profiles/profile.h" |
| 19 #include "chrome/common/chrome_constants.h" | 20 #include "chrome/common/chrome_constants.h" |
| 20 #include "chrome/common/render_messages.h" | 21 #include "chrome/common/render_messages.h" |
| 21 #include "chrome/common/web_application_info.h" | 22 #include "chrome/common/web_application_info.h" |
| 22 #include "components/dom_distiller/core/url_utils.h" | 23 #include "components/dom_distiller/core/url_utils.h" |
| 23 #include "components/favicon/core/favicon_service.h" | 24 #include "components/favicon/core/favicon_service.h" |
| 24 #include "components/favicon_base/favicon_types.h" | 25 #include "components/favicon_base/favicon_types.h" |
| (...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 198 CreateLauncherIcon(SkBitmap()); | 199 CreateLauncherIcon(SkBitmap()); |
| 199 } | 200 } |
| 200 | 201 |
| 201 void AddToHomescreenDataFetcher::OnDidPerformInstallableCheck( | 202 void AddToHomescreenDataFetcher::OnDidPerformInstallableCheck( |
| 202 const InstallableData& data) { | 203 const InstallableData& data) { |
| 203 if (!web_contents() || !weak_observer_) | 204 if (!web_contents() || !weak_observer_) |
| 204 return; | 205 return; |
| 205 | 206 |
| 206 is_installable_check_complete_ = true; | 207 is_installable_check_complete_ = true; |
| 207 | 208 |
| 208 if (check_webapk_compatibility_) | 209 if (check_webapk_compatibility_) { |
| 209 weak_observer_->OnDidDetermineWebApkCompatibility(data.is_installable); | 210 bool webapk_compatible = |
| 211 (data.error_code == NO_ERROR_DETECTED && |
| 212 AreWebManifestUrlsWebApkCompatible(data.manifest)); |
| 213 weak_observer_->OnDidDetermineWebApkCompatibility(webapk_compatible); |
| 214 } |
| 210 | 215 |
| 211 if (!data.manifest.IsEmpty()) { | 216 if (!data.manifest.IsEmpty()) { |
| 212 content::RecordAction( | 217 content::RecordAction( |
| 213 base::UserMetricsAction("webapps.AddShortcut.Manifest")); | 218 base::UserMetricsAction("webapps.AddShortcut.Manifest")); |
| 214 shortcut_info_.UpdateFromManifest(data.manifest); | 219 shortcut_info_.UpdateFromManifest(data.manifest); |
| 215 shortcut_info_.manifest_url = data.manifest_url; | 220 shortcut_info_.manifest_url = data.manifest_url; |
| 216 } | 221 } |
| 217 | 222 |
| 218 // Save the splash screen URL for the later download. | 223 // Save the splash screen URL for the later download. |
| 219 splash_screen_url_ = ManifestIconSelector::FindBestMatchingIcon( | 224 splash_screen_url_ = ManifestIconSelector::FindBestMatchingIcon( |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 319 void AddToHomescreenDataFetcher::NotifyObserver(const SkBitmap& icon) { | 324 void AddToHomescreenDataFetcher::NotifyObserver(const SkBitmap& icon) { |
| 320 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 325 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| 321 if (!web_contents() || !weak_observer_ || is_icon_saved_) | 326 if (!web_contents() || !weak_observer_ || is_icon_saved_) |
| 322 return; | 327 return; |
| 323 | 328 |
| 324 is_icon_saved_ = true; | 329 is_icon_saved_ = true; |
| 325 shortcut_icon_ = icon; | 330 shortcut_icon_ = icon; |
| 326 is_ready_ = true; | 331 is_ready_ = true; |
| 327 weak_observer_->OnDataAvailable(shortcut_info_, shortcut_icon_); | 332 weak_observer_->OnDataAvailable(shortcut_info_, shortcut_icon_); |
| 328 } | 333 } |
| OLD | NEW |