| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "components/update_client/update_checker.h" | 5 #include "components/update_client/update_checker.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <memory> | 9 #include <memory> |
| 10 #include <string> | 10 #include <string> |
| (...skipping 30 matching lines...) Expand all Loading... |
| 41 update_client::InstallerAttributes sanitized_attrs; | 41 update_client::InstallerAttributes sanitized_attrs; |
| 42 for (const auto& attr : installer_attributes) { | 42 for (const auto& attr : installer_attributes) { |
| 43 if (IsValidInstallerAttribute(attr)) | 43 if (IsValidInstallerAttribute(attr)) |
| 44 sanitized_attrs.insert(attr); | 44 sanitized_attrs.insert(attr); |
| 45 } | 45 } |
| 46 return sanitized_attrs; | 46 return sanitized_attrs; |
| 47 } | 47 } |
| 48 | 48 |
| 49 // Returns true if at least one item requires network encryption. | 49 // Returns true if at least one item requires network encryption. |
| 50 bool IsEncryptionRequired(const std::vector<CrxUpdateItem*>& items) { | 50 bool IsEncryptionRequired(const std::vector<CrxUpdateItem*>& items) { |
| 51 for (const auto& item : items) { | 51 for (auto* item : items) { |
| 52 if (item->component.requires_network_encryption) | 52 if (item->component.requires_network_encryption) |
| 53 return true; | 53 return true; |
| 54 } | 54 } |
| 55 return false; | 55 return false; |
| 56 } | 56 } |
| 57 | 57 |
| 58 // Builds an update check request for |components|. |additional_attributes| is | 58 // Builds an update check request for |components|. |additional_attributes| is |
| 59 // serialized as part of the <request> element of the request to customize it | 59 // serialized as part of the <request> element of the request to customize it |
| 60 // with data that is not platform or component specific. For each |item|, a | 60 // with data that is not platform or component specific. For each |item|, a |
| 61 // corresponding <app> element is created and inserted as a child node of | 61 // corresponding <app> element is created and inserted as a child node of |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 162 } | 162 } |
| 163 | 163 |
| 164 update_check_callback_ = update_check_callback; | 164 update_check_callback_ = update_check_callback; |
| 165 | 165 |
| 166 auto urls(config_->UpdateUrl()); | 166 auto urls(config_->UpdateUrl()); |
| 167 if (IsEncryptionRequired(items_to_check)) | 167 if (IsEncryptionRequired(items_to_check)) |
| 168 RemoveUnsecureUrls(&urls); | 168 RemoveUnsecureUrls(&urls); |
| 169 | 169 |
| 170 std::unique_ptr<std::vector<std::string>> ids_checked( | 170 std::unique_ptr<std::vector<std::string>> ids_checked( |
| 171 new std::vector<std::string>()); | 171 new std::vector<std::string>()); |
| 172 for (auto crx : items_to_check) | 172 for (auto* crx : items_to_check) |
| 173 ids_checked->push_back(crx->id); | 173 ids_checked->push_back(crx->id); |
| 174 request_sender_.reset(new RequestSender(config_)); | 174 request_sender_.reset(new RequestSender(config_)); |
| 175 request_sender_->Send( | 175 request_sender_->Send( |
| 176 config_->UseCupSigning(), | 176 config_->UseCupSigning(), |
| 177 BuildUpdateCheckRequest(*config_, items_to_check, metadata_, | 177 BuildUpdateCheckRequest(*config_, items_to_check, metadata_, |
| 178 additional_attributes), | 178 additional_attributes), |
| 179 urls, base::Bind(&UpdateCheckerImpl::OnRequestSenderComplete, | 179 urls, base::Bind(&UpdateCheckerImpl::OnRequestSenderComplete, |
| 180 base::Unretained(this), base::Passed(&ids_checked))); | 180 base::Unretained(this), base::Passed(&ids_checked))); |
| 181 return true; | 181 return true; |
| 182 } | 182 } |
| (...skipping 29 matching lines...) Expand all Loading... |
| 212 } // namespace | 212 } // namespace |
| 213 | 213 |
| 214 std::unique_ptr<UpdateChecker> UpdateChecker::Create( | 214 std::unique_ptr<UpdateChecker> UpdateChecker::Create( |
| 215 const scoped_refptr<Configurator>& config, | 215 const scoped_refptr<Configurator>& config, |
| 216 PersistedData* persistent) { | 216 PersistedData* persistent) { |
| 217 return std::unique_ptr<UpdateChecker>( | 217 return std::unique_ptr<UpdateChecker>( |
| 218 new UpdateCheckerImpl(config, persistent)); | 218 new UpdateCheckerImpl(config, persistent)); |
| 219 } | 219 } |
| 220 | 220 |
| 221 } // namespace update_client | 221 } // namespace update_client |
| OLD | NEW |