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) { | |
72 if (extension_ids_.find(id) != extension_ids_.end()) { | 71 if (extension_ids_.find(id) != extension_ids_.end()) { |
73 NOTREACHED() << "Duplicate extension id " << id; | 72 NOTREACHED() << "Duplicate extension id " << id; |
74 return false; | 73 return false; |
75 } | 74 } |
76 | 75 |
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 | |
84 // Compute the string we'd append onto the full_url_, and see if it fits. | 76 // Compute the string we'd append onto the full_url_, and see if it fits. |
85 std::vector<std::string> parts; | 77 std::vector<std::string> parts; |
86 parts.push_back("id=" + id); | 78 parts.push_back("id=" + id); |
87 parts.push_back("v=" + installed_version); | 79 parts.push_back("v=" + version); |
88 if (!install_source.empty()) | 80 if (!install_source.empty()) |
89 parts.push_back("installsource=" + install_source); | 81 parts.push_back("installsource=" + install_source); |
90 parts.push_back("uc"); | 82 parts.push_back("uc"); |
91 | 83 |
92 if (!update_url_data.empty()) { | 84 if (!update_url_data.empty()) { |
93 // Make sure the update_url_data string is escaped before using it so that | 85 // Make sure the update_url_data string is escaped before using it so that |
94 // there is no chance of overriding the id or v other parameter value | 86 // there is no chance of overriding the id or v other parameter value |
95 // we place into the x= value. | 87 // we place into the x= value. |
96 parts.push_back("ap=" + net::EscapeQueryParamValue(update_url_data, true)); | 88 parts.push_back("ap=" + net::EscapeQueryParamValue(update_url_data, true)); |
97 } | 89 } |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
164 else | 156 else |
165 NOTREACHED(); | 157 NOTREACHED(); |
166 return value == kNeverPinged || value > 0; | 158 return value == kNeverPinged || value > 0; |
167 } | 159 } |
168 | 160 |
169 void ManifestFetchData::Merge(const ManifestFetchData& other) { | 161 void ManifestFetchData::Merge(const ManifestFetchData& other) { |
170 DCHECK(full_url() == other.full_url()); | 162 DCHECK(full_url() == other.full_url()); |
171 request_ids_.insert(other.request_ids_.begin(), other.request_ids_.end()); | 163 request_ids_.insert(other.request_ids_.begin(), other.request_ids_.end()); |
172 } | 164 } |
173 | 165 |
174 bool ManifestFetchData::DidForceUpdate(const std::string& extension_id) const { | |
175 return forced_updates_.find(extension_id) != forced_updates_.end(); | |
176 } | |
177 | |
178 } // namespace extensions | 166 } // namespace extensions |
OLD | NEW |