| 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 "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/callback.h" | 8 #include "base/callback.h" |
| 9 #include "base/location.h" | 9 #include "base/location.h" |
| 10 #include "base/strings/string16.h" | 10 #include "base/strings/string16.h" |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 156 return false; | 156 return false; |
| 157 if (!IsManifestValidForWebApp(web_contents, manifest)) | 157 if (!IsManifestValidForWebApp(web_contents, manifest)) |
| 158 return false; | 158 return false; |
| 159 return true; | 159 return true; |
| 160 } | 160 } |
| 161 | 161 |
| 162 void AddToHomescreenDataFetcher::OnDidCheckHasServiceWorker( | 162 void AddToHomescreenDataFetcher::OnDidCheckHasServiceWorker( |
| 163 const std::vector<content::Manifest::Icon>& icons, | 163 const std::vector<content::Manifest::Icon>& icons, |
| 164 bool has_service_worker) { | 164 bool has_service_worker) { |
| 165 if (has_service_worker) | 165 if (has_service_worker) |
| 166 shortcut_info_.is_web_apk = true; | 166 shortcut_info_.is_webapk = true; |
| 167 DownloadIcons(icons); | 167 DownloadIcons(icons); |
| 168 } | 168 } |
| 169 | 169 |
| 170 void AddToHomescreenDataFetcher::DownloadIcons( | 170 void AddToHomescreenDataFetcher::DownloadIcons( |
| 171 const std::vector<content::Manifest::Icon>& icons) { | 171 const std::vector<content::Manifest::Icon>& icons) { |
| 172 GURL icon_src = ManifestIconSelector::FindBestMatchingIcon( | 172 GURL icon_src = ManifestIconSelector::FindBestMatchingIcon( |
| 173 icons, ideal_icon_size_in_dp_, minimum_icon_size_in_dp_); | 173 icons, ideal_icon_size_in_dp_, minimum_icon_size_in_dp_); |
| 174 | 174 |
| 175 // If fetching the Manifest icon fails, fallback to the best favicon | 175 // If fetching the Manifest icon fails, fallback to the best favicon |
| 176 // for the page. | 176 // for the page. |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 325 dom_distiller::url_utils::GetOriginalUrlFromDistillerUrl(actual_url); | 325 dom_distiller::url_utils::GetOriginalUrlFromDistillerUrl(actual_url); |
| 326 | 326 |
| 327 // If URL points to an offline content, get original URL. | 327 // If URL points to an offline content, get original URL. |
| 328 GURL online_url = offline_pages::OfflinePageUtils::GetOnlineURLForOfflineURL( | 328 GURL online_url = offline_pages::OfflinePageUtils::GetOnlineURLForOfflineURL( |
| 329 web_contents()->GetBrowserContext(), original_url); | 329 web_contents()->GetBrowserContext(), original_url); |
| 330 if (online_url.is_valid()) | 330 if (online_url.is_valid()) |
| 331 return online_url; | 331 return online_url; |
| 332 | 332 |
| 333 return original_url; | 333 return original_url; |
| 334 } | 334 } |
| OLD | NEW |