| 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/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 62 | 62 |
| 63 // Returns true if |params| specifies a full PWA check. | 63 // Returns true if |params| specifies a full PWA check. |
| 64 bool IsParamsForPwaCheck(const InstallableParams& params) { | 64 bool IsParamsForPwaCheck(const InstallableParams& params) { |
| 65 return params.check_installable && params.fetch_valid_primary_icon; | 65 return params.check_installable && params.fetch_valid_primary_icon; |
| 66 } | 66 } |
| 67 | 67 |
| 68 } // namespace | 68 } // namespace |
| 69 | 69 |
| 70 DEFINE_WEB_CONTENTS_USER_DATA_KEY(InstallableManager); | 70 DEFINE_WEB_CONTENTS_USER_DATA_KEY(InstallableManager); |
| 71 | 71 |
| 72 struct InstallableManager::ManifestProperty { | 72 InstallableManager::IconProperty::IconProperty() |
| 73 InstallableStatusCode error = NO_ERROR_DETECTED; | 73 : error(NO_ERROR_DETECTED), url(), icon(), fetched(false) {} |
| 74 GURL url; | |
| 75 content::Manifest manifest; | |
| 76 bool fetched = false; | |
| 77 }; | |
| 78 | 74 |
| 79 struct InstallableManager::ValidManifestProperty { | 75 InstallableManager::IconProperty::IconProperty(IconProperty&& other) = default; |
| 80 InstallableStatusCode error = NO_ERROR_DETECTED; | |
| 81 bool is_valid = false; | |
| 82 bool fetched = false; | |
| 83 }; | |
| 84 | 76 |
| 85 struct InstallableManager::ServiceWorkerProperty { | 77 InstallableManager::IconProperty::~IconProperty() {} |
| 86 InstallableStatusCode error = NO_ERROR_DETECTED; | |
| 87 bool has_worker = false; | |
| 88 bool is_waiting = false; | |
| 89 bool fetched = false; | |
| 90 }; | |
| 91 | |
| 92 struct InstallableManager::IconProperty { | |
| 93 IconProperty() : | |
| 94 error(NO_ERROR_DETECTED), url(), icon(), fetched(false) { } | |
| 95 IconProperty(IconProperty&& other) = default; | |
| 96 IconProperty& operator=(IconProperty&& other) = default; | |
| 97 | |
| 98 InstallableStatusCode error = NO_ERROR_DETECTED; | |
| 99 GURL url; | |
| 100 std::unique_ptr<SkBitmap> icon; | |
| 101 bool fetched; | |
| 102 | |
| 103 private: | |
| 104 // This class contains a std::unique_ptr and therefore must be move-only. | |
| 105 DISALLOW_COPY_AND_ASSIGN(IconProperty); | |
| 106 }; | |
| 107 | 78 |
| 108 InstallableManager::InstallableManager(content::WebContents* web_contents) | 79 InstallableManager::InstallableManager(content::WebContents* web_contents) |
| 109 : content::WebContentsObserver(web_contents), | 80 : content::WebContentsObserver(web_contents), |
| 110 manifest_(base::MakeUnique<ManifestProperty>()), | 81 manifest_(base::MakeUnique<ManifestProperty>()), |
| 111 valid_manifest_(base::MakeUnique<ValidManifestProperty>()), | 82 valid_manifest_(base::MakeUnique<ValidManifestProperty>()), |
| 112 worker_(base::MakeUnique<ServiceWorkerProperty>()), | 83 worker_(base::MakeUnique<ServiceWorkerProperty>()), |
| 113 service_worker_context_(nullptr), | 84 service_worker_context_(nullptr), |
| 114 page_status_(InstallabilityCheckStatus::NOT_STARTED), | 85 page_status_(InstallabilityCheckStatus::NOT_STARTED), |
| 115 menu_open_count_(0), | 86 menu_open_count_(0), |
| 116 menu_item_add_to_homescreen_count_(0), | 87 menu_item_add_to_homescreen_count_(0), |
| (...skipping 529 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 646 return manifest_->url; | 617 return manifest_->url; |
| 647 } | 618 } |
| 648 | 619 |
| 649 const content::Manifest& InstallableManager::manifest() const { | 620 const content::Manifest& InstallableManager::manifest() const { |
| 650 return manifest_->manifest; | 621 return manifest_->manifest; |
| 651 } | 622 } |
| 652 | 623 |
| 653 bool InstallableManager::is_installable() const { | 624 bool InstallableManager::is_installable() const { |
| 654 return valid_manifest_->is_valid && worker_->has_worker; | 625 return valid_manifest_->is_valid && worker_->has_worker; |
| 655 } | 626 } |
| OLD | NEW |