| 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" |
| (...skipping 29 matching lines...) Expand all Loading... |
| 40 // screen shortcut. | 40 // screen shortcut. |
| 41 GURL GetShortcutUrl(content::BrowserContext* browser_context, | 41 GURL GetShortcutUrl(content::BrowserContext* browser_context, |
| 42 const GURL& actual_url) { | 42 const GURL& actual_url) { |
| 43 return dom_distiller::url_utils::GetOriginalUrlFromDistillerUrl(actual_url); | 43 return dom_distiller::url_utils::GetOriginalUrlFromDistillerUrl(actual_url); |
| 44 } | 44 } |
| 45 | 45 |
| 46 InstallableParams ParamsToPerformInstallableCheck(int ideal_icon_size_in_px, | 46 InstallableParams ParamsToPerformInstallableCheck(int ideal_icon_size_in_px, |
| 47 int minimum_icon_size_in_px, | 47 int minimum_icon_size_in_px, |
| 48 bool check_installable) { | 48 bool check_installable) { |
| 49 InstallableParams params; | 49 InstallableParams params; |
| 50 params.ideal_icon_size_in_px = ideal_icon_size_in_px; | 50 params.ideal_primary_icon_size_in_px = ideal_icon_size_in_px; |
| 51 params.minimum_icon_size_in_px = minimum_icon_size_in_px; | 51 params.minimum_primary_icon_size_in_px = minimum_icon_size_in_px; |
| 52 params.check_installable = check_installable; | 52 params.check_installable = check_installable; |
| 53 params.fetch_valid_icon = true; | 53 params.fetch_valid_primary_icon = true; |
| 54 return params; | 54 return params; |
| 55 } | 55 } |
| 56 | 56 |
| 57 } // namespace | 57 } // namespace |
| 58 | 58 |
| 59 AddToHomescreenDataFetcher::AddToHomescreenDataFetcher( | 59 AddToHomescreenDataFetcher::AddToHomescreenDataFetcher( |
| 60 content::WebContents* web_contents, | 60 content::WebContents* web_contents, |
| 61 int ideal_icon_size_in_px, | 61 int ideal_icon_size_in_px, |
| 62 int minimum_icon_size_in_px, | 62 int minimum_icon_size_in_px, |
| 63 int ideal_splash_image_size_in_px, | 63 int ideal_splash_image_size_in_px, |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 211 shortcut_info_.manifest_url = data.manifest_url; | 211 shortcut_info_.manifest_url = data.manifest_url; |
| 212 } | 212 } |
| 213 | 213 |
| 214 // Save the splash screen URL for the later download. | 214 // Save the splash screen URL for the later download. |
| 215 splash_screen_url_ = ManifestIconSelector::FindBestMatchingIcon( | 215 splash_screen_url_ = ManifestIconSelector::FindBestMatchingIcon( |
| 216 data.manifest.icons, ideal_splash_image_size_in_px_, | 216 data.manifest.icons, ideal_splash_image_size_in_px_, |
| 217 minimum_splash_image_size_in_px_); | 217 minimum_splash_image_size_in_px_); |
| 218 | 218 |
| 219 weak_observer_->OnUserTitleAvailable(shortcut_info_.user_title); | 219 weak_observer_->OnUserTitleAvailable(shortcut_info_.user_title); |
| 220 | 220 |
| 221 if (data.icon) { | 221 if (data.primary_icon) { |
| 222 shortcut_info_.best_icon_url = data.icon_url; | 222 shortcut_info_.best_icon_url = data.primary_icon_url; |
| 223 | 223 |
| 224 CreateLauncherIcon(*(data.icon)); | 224 CreateLauncherIcon(*(data.primary_icon)); |
| 225 return; | 225 return; |
| 226 } | 226 } |
| 227 | 227 |
| 228 FetchFavicon(); | 228 FetchFavicon(); |
| 229 } | 229 } |
| 230 | 230 |
| 231 void AddToHomescreenDataFetcher::FetchFavicon() { | 231 void AddToHomescreenDataFetcher::FetchFavicon() { |
| 232 if (!web_contents() || !weak_observer_) | 232 if (!web_contents() || !weak_observer_) |
| 233 return; | 233 return; |
| 234 | 234 |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 312 void AddToHomescreenDataFetcher::NotifyObserver(const SkBitmap& icon) { | 312 void AddToHomescreenDataFetcher::NotifyObserver(const SkBitmap& icon) { |
| 313 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 313 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| 314 if (!web_contents() || !weak_observer_ || is_icon_saved_) | 314 if (!web_contents() || !weak_observer_ || is_icon_saved_) |
| 315 return; | 315 return; |
| 316 | 316 |
| 317 is_icon_saved_ = true; | 317 is_icon_saved_ = true; |
| 318 shortcut_icon_ = icon; | 318 shortcut_icon_ = icon; |
| 319 is_ready_ = true; | 319 is_ready_ = true; |
| 320 weak_observer_->OnDataAvailable(shortcut_info_, shortcut_icon_); | 320 weak_observer_->OnDataAvailable(shortcut_info_, shortcut_icon_); |
| 321 } | 321 } |
| OLD | NEW |