| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/installable/installable_manager.h" | 5 #include "chrome/browser/installable/installable_manager.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/stl_util.h" | 8 #include "base/stl_util.h" |
| 9 #include "base/strings/string_util.h" | 9 #include "base/strings/string_util.h" |
| 10 #include "chrome/browser/manifest/manifest_icon_downloader.h" | |
| 11 #include "chrome/browser/manifest/manifest_icon_selector.h" | |
| 12 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
| 13 #include "chrome/browser/ssl/security_state_tab_helper.h" | 11 #include "chrome/browser/ssl/security_state_tab_helper.h" |
| 14 #include "components/security_state/core/security_state.h" | 12 #include "components/security_state/core/security_state.h" |
| 15 #include "content/public/browser/browser_context.h" | 13 #include "content/public/browser/browser_context.h" |
| 16 #include "content/public/browser/browser_thread.h" | 14 #include "content/public/browser/browser_thread.h" |
| 15 #include "content/public/browser/manifest_icon_downloader.h" |
| 16 #include "content/public/browser/manifest_icon_selector.h" |
| 17 #include "content/public/browser/navigation_handle.h" | 17 #include "content/public/browser/navigation_handle.h" |
| 18 #include "content/public/browser/service_worker_context.h" | 18 #include "content/public/browser/service_worker_context.h" |
| 19 #include "content/public/browser/storage_partition.h" | 19 #include "content/public/browser/storage_partition.h" |
| 20 #include "net/base/url_util.h" | 20 #include "net/base/url_util.h" |
| 21 #include "third_party/WebKit/public/platform/WebDisplayMode.h" | 21 #include "third_party/WebKit/public/platform/WebDisplayMode.h" |
| 22 | 22 |
| 23 using IconPurpose = content::Manifest::Icon::IconPurpose; | 23 using IconPurpose = content::Manifest::Icon::IconPurpose; |
| 24 | 24 |
| 25 namespace { | 25 namespace { |
| 26 | 26 |
| (...skipping 498 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 525 void InstallableManager::CheckAndFetchBestIcon(const IconParams& params) { | 525 void InstallableManager::CheckAndFetchBestIcon(const IconParams& params) { |
| 526 DCHECK(!manifest().IsEmpty()); | 526 DCHECK(!manifest().IsEmpty()); |
| 527 | 527 |
| 528 int ideal_icon_size_in_px = std::get<0>(params); | 528 int ideal_icon_size_in_px = std::get<0>(params); |
| 529 int minimum_icon_size_in_px = std::get<1>(params); | 529 int minimum_icon_size_in_px = std::get<1>(params); |
| 530 IconPurpose icon_purpose = std::get<2>(params); | 530 IconPurpose icon_purpose = std::get<2>(params); |
| 531 | 531 |
| 532 IconProperty& icon = icons_[params]; | 532 IconProperty& icon = icons_[params]; |
| 533 icon.fetched = true; | 533 icon.fetched = true; |
| 534 | 534 |
| 535 GURL icon_url = ManifestIconSelector::FindBestMatchingIcon( | 535 GURL icon_url = content::ManifestIconSelector::FindBestMatchingIcon( |
| 536 manifest().icons, ideal_icon_size_in_px, minimum_icon_size_in_px, | 536 manifest().icons, ideal_icon_size_in_px, minimum_icon_size_in_px, |
| 537 icon_purpose); | 537 icon_purpose); |
| 538 | 538 |
| 539 if (icon_url.is_empty()) { | 539 if (icon_url.is_empty()) { |
| 540 icon.error = NO_ACCEPTABLE_ICON; | 540 icon.error = NO_ACCEPTABLE_ICON; |
| 541 } else { | 541 } else { |
| 542 bool can_download_icon = ManifestIconDownloader::Download( | 542 bool can_download_icon = content::ManifestIconDownloader::Download( |
| 543 GetWebContents(), icon_url, ideal_icon_size_in_px, | 543 GetWebContents(), icon_url, ideal_icon_size_in_px, |
| 544 minimum_icon_size_in_px, | 544 minimum_icon_size_in_px, |
| 545 base::Bind(&InstallableManager::OnIconFetched, | 545 base::Bind(&InstallableManager::OnIconFetched, |
| 546 weak_factory_.GetWeakPtr(), icon_url, params)); | 546 weak_factory_.GetWeakPtr(), icon_url, params)); |
| 547 if (can_download_icon) | 547 if (can_download_icon) |
| 548 return; | 548 return; |
| 549 icon.error = CANNOT_DOWNLOAD_ICON; | 549 icon.error = CANNOT_DOWNLOAD_ICON; |
| 550 } | 550 } |
| 551 | 551 |
| 552 WorkOnTask(); | 552 WorkOnTask(); |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 586 return manifest_->url; | 586 return manifest_->url; |
| 587 } | 587 } |
| 588 | 588 |
| 589 const content::Manifest& InstallableManager::manifest() const { | 589 const content::Manifest& InstallableManager::manifest() const { |
| 590 return manifest_->manifest; | 590 return manifest_->manifest; |
| 591 } | 591 } |
| 592 | 592 |
| 593 bool InstallableManager::is_installable() const { | 593 bool InstallableManager::is_installable() const { |
| 594 return installable_->installable; | 594 return installable_->installable; |
| 595 } | 595 } |
| OLD | NEW |