| 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 "chrome/browser/extensions/updater/manifest_fetch_data.h" | 5 #include "chrome/browser/extensions/updater/manifest_fetch_data.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 // Extension 2- id:bbbb version:2.0 | 60 // Extension 2- id:bbbb version:2.0 |
| 61 // | 61 // |
| 62 // the full update url would be: | 62 // the full update url would be: |
| 63 // http://somehost/path?x=id%3Daaaa%26v%3D1.1%26uc&x=id%3Dbbbb%26v%3D2.0%26uc | 63 // http://somehost/path?x=id%3Daaaa%26v%3D1.1%26uc&x=id%3Dbbbb%26v%3D2.0%26uc |
| 64 // | 64 // |
| 65 // (Note that '=' is %3D and '&' is %26 when urlencoded.) | 65 // (Note that '=' is %3D and '&' is %26 when urlencoded.) |
| 66 bool ManifestFetchData::AddExtension(const std::string& id, | 66 bool ManifestFetchData::AddExtension(const std::string& id, |
| 67 const std::string& version, | 67 const std::string& version, |
| 68 const PingData* ping_data, | 68 const PingData* ping_data, |
| 69 const std::string& update_url_data, | 69 const std::string& update_url_data, |
| 70 const std::string& install_source) { | 70 const std::string& install_source, |
| 71 bool force_update) { |
| 71 if (extension_ids_.find(id) != extension_ids_.end()) { | 72 if (extension_ids_.find(id) != extension_ids_.end()) { |
| 72 NOTREACHED() << "Duplicate extension id " << id; | 73 NOTREACHED() << "Duplicate extension id " << id; |
| 73 return false; | 74 return false; |
| 74 } | 75 } |
| 75 | 76 |
| 77 if (force_update) |
| 78 forced_updates_.insert(id); |
| 79 |
| 80 // If we want to force an update, we send 0.0.0.0 as the installed version |
| 81 // number. |
| 82 const std::string installed_version = force_update ? "0.0.0.0" : version; |
| 83 |
| 76 // Compute the string we'd append onto the full_url_, and see if it fits. | 84 // Compute the string we'd append onto the full_url_, and see if it fits. |
| 77 std::vector<std::string> parts; | 85 std::vector<std::string> parts; |
| 78 parts.push_back("id=" + id); | 86 parts.push_back("id=" + id); |
| 79 parts.push_back("v=" + version); | 87 parts.push_back("v=" + installed_version); |
| 80 if (!install_source.empty()) | 88 if (!install_source.empty()) |
| 81 parts.push_back("installsource=" + install_source); | 89 parts.push_back("installsource=" + install_source); |
| 82 parts.push_back("uc"); | 90 parts.push_back("uc"); |
| 83 | 91 |
| 84 if (!update_url_data.empty()) { | 92 if (!update_url_data.empty()) { |
| 85 // Make sure the update_url_data string is escaped before using it so that | 93 // Make sure the update_url_data string is escaped before using it so that |
| 86 // there is no chance of overriding the id or v other parameter value | 94 // there is no chance of overriding the id or v other parameter value |
| 87 // we place into the x= value. | 95 // we place into the x= value. |
| 88 parts.push_back("ap=" + net::EscapeQueryParamValue(update_url_data, true)); | 96 parts.push_back("ap=" + net::EscapeQueryParamValue(update_url_data, true)); |
| 89 } | 97 } |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 156 else | 164 else |
| 157 NOTREACHED(); | 165 NOTREACHED(); |
| 158 return value == kNeverPinged || value > 0; | 166 return value == kNeverPinged || value > 0; |
| 159 } | 167 } |
| 160 | 168 |
| 161 void ManifestFetchData::Merge(const ManifestFetchData& other) { | 169 void ManifestFetchData::Merge(const ManifestFetchData& other) { |
| 162 DCHECK(full_url() == other.full_url()); | 170 DCHECK(full_url() == other.full_url()); |
| 163 request_ids_.insert(other.request_ids_.begin(), other.request_ids_.end()); | 171 request_ids_.insert(other.request_ids_.begin(), other.request_ids_.end()); |
| 164 } | 172 } |
| 165 | 173 |
| 174 bool ManifestFetchData::DidForceUpdate(const std::string& extension_id) const { |
| 175 return forced_updates_.find(extension_id) != forced_updates_.end(); |
| 176 } |
| 177 |
| 166 } // namespace extensions | 178 } // namespace extensions |
| OLD | NEW |