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) { | |
Yoyo Zhou
2014/09/02 19:30:04
nit: no braces
Ken Rockot(use gerrit already)
2014/09/02 20:04:30
Done.
| |
78 forced_updates_.insert(id); | |
79 } | |
80 | |
81 // If we want to force an update, we send 0.0.0.0 as the installed version | |
82 // number. | |
83 std::string installed_version = force_update ? "0.0.0.0" : version; | |
Sorin Jianu
2014/09/02 20:06:39
could be made const.
Ken Rockot(use gerrit already)
2014/09/02 20:19:20
Done.
| |
84 | |
76 // Compute the string we'd append onto the full_url_, and see if it fits. | 85 // Compute the string we'd append onto the full_url_, and see if it fits. |
77 std::vector<std::string> parts; | 86 std::vector<std::string> parts; |
78 parts.push_back("id=" + id); | 87 parts.push_back("id=" + id); |
79 parts.push_back("v=" + version); | 88 parts.push_back("v=" + installed_version); |
80 if (!install_source.empty()) | 89 if (!install_source.empty()) |
81 parts.push_back("installsource=" + install_source); | 90 parts.push_back("installsource=" + install_source); |
82 parts.push_back("uc"); | 91 parts.push_back("uc"); |
83 | 92 |
84 if (!update_url_data.empty()) { | 93 if (!update_url_data.empty()) { |
85 // Make sure the update_url_data string is escaped before using it so that | 94 // 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 | 95 // there is no chance of overriding the id or v other parameter value |
87 // we place into the x= value. | 96 // we place into the x= value. |
88 parts.push_back("ap=" + net::EscapeQueryParamValue(update_url_data, true)); | 97 parts.push_back("ap=" + net::EscapeQueryParamValue(update_url_data, true)); |
89 } | 98 } |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
156 else | 165 else |
157 NOTREACHED(); | 166 NOTREACHED(); |
158 return value == kNeverPinged || value > 0; | 167 return value == kNeverPinged || value > 0; |
159 } | 168 } |
160 | 169 |
161 void ManifestFetchData::Merge(const ManifestFetchData& other) { | 170 void ManifestFetchData::Merge(const ManifestFetchData& other) { |
162 DCHECK(full_url() == other.full_url()); | 171 DCHECK(full_url() == other.full_url()); |
163 request_ids_.insert(other.request_ids_.begin(), other.request_ids_.end()); | 172 request_ids_.insert(other.request_ids_.begin(), other.request_ids_.end()); |
164 } | 173 } |
165 | 174 |
175 bool ManifestFetchData::DidForceUpdate(const std::string& extension_id) const { | |
176 return forced_updates_.find(extension_id) != forced_updates_.end(); | |
177 } | |
178 | |
166 } // namespace extensions | 179 } // namespace extensions |
OLD | NEW |