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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
49 offline_pages::OfflinePageUtils::MaybeGetOnlineURLForOfflineURL( | 49 offline_pages::OfflinePageUtils::MaybeGetOnlineURLForOfflineURL( |
50 browser_context, original_url); | 50 browser_context, original_url); |
51 if (online_url.is_valid()) | 51 if (online_url.is_valid()) |
52 return online_url; | 52 return online_url; |
53 | 53 |
54 return original_url; | 54 return original_url; |
55 } | 55 } |
56 | 56 |
57 InstallableParams ParamsToPerformInstallableCheck(int ideal_icon_size_in_dp, | 57 InstallableParams ParamsToPerformInstallableCheck(int ideal_icon_size_in_dp, |
58 int minimum_icon_size_in_dp) { | 58 int minimum_icon_size_in_dp) { |
59 // TODO(hanxi): change check_installable to true for WebAPKs. | |
60 InstallableParams params; | 59 InstallableParams params; |
61 params.ideal_icon_size_in_dp = ideal_icon_size_in_dp; | 60 params.ideal_icon_size_in_dp = ideal_icon_size_in_dp; |
62 params.minimum_icon_size_in_dp = minimum_icon_size_in_dp; | 61 params.minimum_icon_size_in_dp = minimum_icon_size_in_dp; |
63 params.check_installable = false; | 62 params.check_installable = false; |
64 params.fetch_valid_icon = true; | 63 params.fetch_valid_icon = true; |
65 return params; | 64 return params; |
66 } | 65 } |
67 | 66 |
68 } // namespace | 67 } // namespace |
69 | 68 |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
166 } | 165 } |
167 | 166 |
168 // Save the splash screen URL for the later download. | 167 // Save the splash screen URL for the later download. |
169 splash_screen_url_ = ManifestIconSelector::FindBestMatchingIcon( | 168 splash_screen_url_ = ManifestIconSelector::FindBestMatchingIcon( |
170 data.manifest.icons, ideal_splash_image_size_in_dp_, | 169 data.manifest.icons, ideal_splash_image_size_in_dp_, |
171 minimum_splash_image_size_in_dp_); | 170 minimum_splash_image_size_in_dp_); |
172 | 171 |
173 weak_observer_->OnUserTitleAvailable(shortcut_info_.user_title); | 172 weak_observer_->OnUserTitleAvailable(shortcut_info_.user_title); |
174 | 173 |
175 if (data.icon) { | 174 if (data.icon) { |
176 // TODO(hanxi): implement WebAPK path if shortcut_info_.url has a secure | |
177 // scheme and data.is_installable is true. | |
178 shortcut_info_.icon_url = data.icon_url; | 175 shortcut_info_.icon_url = data.icon_url; |
179 | 176 |
180 // base::Bind copies the arguments internally, so it is safe to pass it | 177 // base::Bind copies the arguments internally, so it is safe to pass it |
181 // data.icon (which is not owned by us). | 178 // data.icon (which is not owned by us). |
182 content::BrowserThread::GetBlockingPool() | 179 content::BrowserThread::GetBlockingPool() |
183 ->PostWorkerTaskWithShutdownBehavior( | 180 ->PostWorkerTaskWithShutdownBehavior( |
184 FROM_HERE, | 181 FROM_HERE, |
185 base::Bind( | 182 base::Bind( |
186 &AddToHomescreenDataFetcher::CreateLauncherIconInBackground, | 183 &AddToHomescreenDataFetcher::CreateLauncherIconInBackground, |
187 this, *(data.icon)), | 184 this, *(data.icon)), |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
295 void AddToHomescreenDataFetcher::NotifyObserver(const SkBitmap& icon) { | 292 void AddToHomescreenDataFetcher::NotifyObserver(const SkBitmap& icon) { |
296 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 293 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
297 if (!web_contents() || !weak_observer_ || is_icon_saved_) | 294 if (!web_contents() || !weak_observer_ || is_icon_saved_) |
298 return; | 295 return; |
299 | 296 |
300 is_icon_saved_ = true; | 297 is_icon_saved_ = true; |
301 shortcut_icon_ = icon; | 298 shortcut_icon_ = icon; |
302 is_ready_ = true; | 299 is_ready_ = true; |
303 weak_observer_->OnDataAvailable(shortcut_info_, shortcut_icon_); | 300 weak_observer_->OnDataAvailable(shortcut_info_, shortcut_icon_); |
304 } | 301 } |
OLD | NEW |