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 #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" |
|
dominickn
2017/03/01 02:29:40
I think you can remove the callback.h include now.
| |
| 11 #include "base/location.h" | 11 #include "base/location.h" |
| 12 #include "base/strings/string16.h" | 12 #include "base/strings/string16.h" |
| 13 #include "base/task_runner_util.h" | 13 #include "base/task_runner_util.h" |
| 14 #include "base/threading/sequenced_worker_pool.h" | 14 #include "base/threading/sequenced_worker_pool.h" |
| 15 #include "chrome/browser/android/offline_pages/offline_page_utils.h" | 15 #include "chrome/browser/android/offline_pages/offline_page_utils.h" |
| 16 #include "chrome/browser/android/shortcut_helper.h" | 16 #include "chrome/browser/android/shortcut_helper.h" |
| 17 #include "chrome/browser/android/webapk/webapk_web_manifest_checker.h" | 17 #include "chrome/browser/android/webapk/webapk_web_manifest_checker.h" |
| 18 #include "chrome/browser/favicon/favicon_service_factory.h" | 18 #include "chrome/browser/favicon/favicon_service_factory.h" |
| 19 #include "chrome/browser/installable/installable_manager.h" | 19 #include "chrome/browser/installable/installable_manager.h" |
| 20 #include "chrome/browser/manifest/manifest_icon_selector.h" | 20 #include "chrome/browser/manifest/manifest_icon_selector.h" |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 93 is_installable_check_complete_(false), | 93 is_installable_check_complete_(false), |
| 94 is_icon_saved_(false), | 94 is_icon_saved_(false), |
| 95 is_ready_(false) { | 95 is_ready_(false) { |
| 96 DCHECK(minimum_icon_size_in_px <= ideal_icon_size_in_px); | 96 DCHECK(minimum_icon_size_in_px <= ideal_icon_size_in_px); |
| 97 DCHECK(minimum_splash_image_size_in_px <= ideal_splash_image_size_in_px); | 97 DCHECK(minimum_splash_image_size_in_px <= ideal_splash_image_size_in_px); |
| 98 | 98 |
| 99 // Send a message to the renderer to retrieve information about the page. | 99 // Send a message to the renderer to retrieve information about the page. |
| 100 Send(new ChromeViewMsg_GetWebApplicationInfo(routing_id())); | 100 Send(new ChromeViewMsg_GetWebApplicationInfo(routing_id())); |
| 101 } | 101 } |
| 102 | 102 |
| 103 base::Closure AddToHomescreenDataFetcher::FetchSplashScreenImageCallback( | |
| 104 const std::string& webapp_id) { | |
| 105 return base::Bind(&ShortcutHelper::FetchSplashScreenImage, web_contents(), | |
| 106 splash_screen_url_, ideal_splash_image_size_in_px_, | |
| 107 minimum_splash_image_size_in_px_, webapp_id); | |
| 108 } | |
| 109 | |
| 110 void AddToHomescreenDataFetcher::OnDidGetWebApplicationInfo( | 103 void AddToHomescreenDataFetcher::OnDidGetWebApplicationInfo( |
| 111 const WebApplicationInfo& received_web_app_info) { | 104 const WebApplicationInfo& received_web_app_info) { |
| 112 is_waiting_for_web_application_info_ = false; | 105 is_waiting_for_web_application_info_ = false; |
| 113 if (!web_contents() || !weak_observer_) | 106 if (!web_contents() || !weak_observer_) |
| 114 return; | 107 return; |
| 115 | 108 |
| 116 // Sanitize received_web_app_info. | 109 // Sanitize received_web_app_info. |
| 117 WebApplicationInfo web_app_info = received_web_app_info; | 110 WebApplicationInfo web_app_info = received_web_app_info; |
| 118 web_app_info.title = | 111 web_app_info.title = |
| 119 web_app_info.title.substr(0, chrome::kMaxMetaTagAttributeLength); | 112 web_app_info.title.substr(0, chrome::kMaxMetaTagAttributeLength); |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 237 shortcut_info_.UpdateSource(ShortcutInfo::SOURCE_ADD_TO_HOMESCREEN_PWA); | 230 shortcut_info_.UpdateSource(ShortcutInfo::SOURCE_ADD_TO_HOMESCREEN_PWA); |
| 238 | 231 |
| 239 if (data.badge_icon && !data.badge_icon->drawsNothing()) { | 232 if (data.badge_icon && !data.badge_icon->drawsNothing()) { |
| 240 shortcut_info_.best_badge_icon_url = data.badge_icon_url; | 233 shortcut_info_.best_badge_icon_url = data.badge_icon_url; |
| 241 badge_icon_ = *data.badge_icon; | 234 badge_icon_ = *data.badge_icon; |
| 242 } | 235 } |
| 243 } | 236 } |
| 244 } | 237 } |
| 245 | 238 |
| 246 // Save the splash screen URL for the later download. | 239 // Save the splash screen URL for the later download. |
| 247 splash_screen_url_ = ManifestIconSelector::FindBestMatchingIcon( | 240 shortcut_info_.splash_image_url = ManifestIconSelector::FindBestMatchingIcon( |
| 248 data.manifest.icons, ideal_splash_image_size_in_px_, | 241 data.manifest.icons, ideal_splash_image_size_in_px_, |
| 249 minimum_splash_image_size_in_px_, | 242 minimum_splash_image_size_in_px_, |
| 250 content::Manifest::Icon::IconPurpose::ANY); | 243 content::Manifest::Icon::IconPurpose::ANY); |
| 244 shortcut_info_.ideal_splash_image_size_in_px = ideal_splash_image_size_in_px_; | |
| 245 shortcut_info_.minimum_splash_image_size_in_px = | |
| 246 minimum_splash_image_size_in_px_; | |
| 251 | 247 |
| 252 weak_observer_->OnUserTitleAvailable(shortcut_info_.user_title); | 248 weak_observer_->OnUserTitleAvailable(shortcut_info_.user_title); |
| 253 | 249 |
| 254 if (data.primary_icon) { | 250 if (data.primary_icon) { |
| 255 shortcut_info_.best_primary_icon_url = data.primary_icon_url; | 251 shortcut_info_.best_primary_icon_url = data.primary_icon_url; |
| 256 | 252 |
| 257 CreateLauncherIcon(*(data.primary_icon)); | 253 CreateLauncherIcon(*(data.primary_icon)); |
| 258 return; | 254 return; |
| 259 } | 255 } |
| 260 | 256 |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 344 void AddToHomescreenDataFetcher::NotifyObserver(const SkBitmap& primary_icon) { | 340 void AddToHomescreenDataFetcher::NotifyObserver(const SkBitmap& primary_icon) { |
| 345 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 341 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| 346 if (!web_contents() || !weak_observer_ || is_icon_saved_) | 342 if (!web_contents() || !weak_observer_ || is_icon_saved_) |
| 347 return; | 343 return; |
| 348 | 344 |
| 349 is_icon_saved_ = true; | 345 is_icon_saved_ = true; |
| 350 primary_icon_ = primary_icon; | 346 primary_icon_ = primary_icon; |
| 351 is_ready_ = true; | 347 is_ready_ = true; |
| 352 weak_observer_->OnDataAvailable(shortcut_info_, primary_icon_, badge_icon_); | 348 weak_observer_->OnDataAvailable(shortcut_info_, primary_icon_, badge_icon_); |
| 353 } | 349 } |
| OLD | NEW |