| 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/location.h" | 10 #include "base/location.h" |
| 11 #include "base/metrics/user_metrics.h" | 11 #include "base/metrics/user_metrics.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" | |
| 21 #include "chrome/browser/profiles/profile.h" | 20 #include "chrome/browser/profiles/profile.h" |
| 22 #include "chrome/common/chrome_constants.h" | 21 #include "chrome/common/chrome_constants.h" |
| 23 #include "chrome/common/render_messages.h" | 22 #include "chrome/common/render_messages.h" |
| 24 #include "chrome/common/web_application_info.h" | 23 #include "chrome/common/web_application_info.h" |
| 25 #include "components/dom_distiller/core/url_utils.h" | 24 #include "components/dom_distiller/core/url_utils.h" |
| 26 #include "components/favicon/core/favicon_service.h" | 25 #include "components/favicon/core/favicon_service.h" |
| 27 #include "components/favicon_base/favicon_types.h" | 26 #include "components/favicon_base/favicon_types.h" |
| 28 #include "content/public/browser/browser_thread.h" | 27 #include "content/public/browser/browser_thread.h" |
| 28 #include "content/public/browser/manifest_icon_selector.h" |
| 29 #include "content/public/browser/web_contents.h" | 29 #include "content/public/browser/web_contents.h" |
| 30 #include "content/public/browser/web_contents_observer.h" | 30 #include "content/public/browser/web_contents_observer.h" |
| 31 #include "content/public/common/manifest.h" | 31 #include "content/public/common/manifest.h" |
| 32 #include "third_party/WebKit/public/platform/modules/screen_orientation/WebScree
nOrientationLockType.h" | 32 #include "third_party/WebKit/public/platform/modules/screen_orientation/WebScree
nOrientationLockType.h" |
| 33 #include "ui/gfx/codec/png_codec.h" | 33 #include "ui/gfx/codec/png_codec.h" |
| 34 #include "ui/gfx/favicon_size.h" | 34 #include "ui/gfx/favicon_size.h" |
| 35 #include "url/gurl.h" | 35 #include "url/gurl.h" |
| 36 | 36 |
| 37 namespace { | 37 namespace { |
| 38 | 38 |
| (...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 229 shortcut_info_.UpdateSource(ShortcutInfo::SOURCE_ADD_TO_HOMESCREEN_PWA); | 229 shortcut_info_.UpdateSource(ShortcutInfo::SOURCE_ADD_TO_HOMESCREEN_PWA); |
| 230 | 230 |
| 231 if (data.badge_icon && !data.badge_icon->drawsNothing()) { | 231 if (data.badge_icon && !data.badge_icon->drawsNothing()) { |
| 232 shortcut_info_.best_badge_icon_url = data.badge_icon_url; | 232 shortcut_info_.best_badge_icon_url = data.badge_icon_url; |
| 233 badge_icon_ = *data.badge_icon; | 233 badge_icon_ = *data.badge_icon; |
| 234 } | 234 } |
| 235 } | 235 } |
| 236 } | 236 } |
| 237 | 237 |
| 238 // Save the splash screen URL for the later download. | 238 // Save the splash screen URL for the later download. |
| 239 shortcut_info_.splash_image_url = ManifestIconSelector::FindBestMatchingIcon( | 239 shortcut_info_.splash_image_url = |
| 240 data.manifest.icons, ideal_splash_image_size_in_px_, | 240 content::ManifestIconSelector::FindBestMatchingIcon( |
| 241 minimum_splash_image_size_in_px_, | 241 data.manifest.icons, ideal_splash_image_size_in_px_, |
| 242 content::Manifest::Icon::IconPurpose::ANY); | 242 minimum_splash_image_size_in_px_, |
| 243 content::Manifest::Icon::IconPurpose::ANY); |
| 243 shortcut_info_.ideal_splash_image_size_in_px = ideal_splash_image_size_in_px_; | 244 shortcut_info_.ideal_splash_image_size_in_px = ideal_splash_image_size_in_px_; |
| 244 shortcut_info_.minimum_splash_image_size_in_px = | 245 shortcut_info_.minimum_splash_image_size_in_px = |
| 245 minimum_splash_image_size_in_px_; | 246 minimum_splash_image_size_in_px_; |
| 246 | 247 |
| 247 weak_observer_->OnUserTitleAvailable(shortcut_info_.user_title); | 248 weak_observer_->OnUserTitleAvailable(shortcut_info_.user_title); |
| 248 | 249 |
| 249 if (data.primary_icon) { | 250 if (data.primary_icon) { |
| 250 shortcut_info_.best_primary_icon_url = data.primary_icon_url; | 251 shortcut_info_.best_primary_icon_url = data.primary_icon_url; |
| 251 | 252 |
| 252 CreateLauncherIcon(*(data.primary_icon)); | 253 CreateLauncherIcon(*(data.primary_icon)); |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 339 void AddToHomescreenDataFetcher::NotifyObserver(const SkBitmap& primary_icon) { | 340 void AddToHomescreenDataFetcher::NotifyObserver(const SkBitmap& primary_icon) { |
| 340 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 341 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| 341 if (!web_contents() || !weak_observer_ || is_icon_saved_) | 342 if (!web_contents() || !weak_observer_ || is_icon_saved_) |
| 342 return; | 343 return; |
| 343 | 344 |
| 344 is_icon_saved_ = true; | 345 is_icon_saved_ = true; |
| 345 primary_icon_ = primary_icon; | 346 primary_icon_ = primary_icon; |
| 346 is_ready_ = true; | 347 is_ready_ = true; |
| 347 weak_observer_->OnDataAvailable(shortcut_info_, primary_icon_, badge_icon_); | 348 weak_observer_->OnDataAvailable(shortcut_info_, primary_icon_, badge_icon_); |
| 348 } | 349 } |
| OLD | NEW |