Chromium Code Reviews| 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 "extensions/browser/updater/manifest_fetch_data.h" | 5 #include "extensions/browser/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 19 matching lines...) Expand all Loading... | |
| 30 for (int enum_value = 1; enum_value < Extension::DISABLE_REASON_LAST; | 30 for (int enum_value = 1; enum_value < Extension::DISABLE_REASON_LAST; |
| 31 enum_value <<= 1) { | 31 enum_value <<= 1) { |
| 32 if (ping_data->disable_reasons & enum_value) | 32 if (ping_data->disable_reasons & enum_value) |
| 33 *ping_value += "&dr=" + base::IntToString(enum_value); | 33 *ping_value += "&dr=" + base::IntToString(enum_value); |
| 34 } | 34 } |
| 35 } | 35 } |
| 36 } | 36 } |
| 37 | 37 |
| 38 } // namespace | 38 } // namespace |
| 39 | 39 |
| 40 ManifestFetchData::ExtraParams::ExtraParams() | |
| 41 : is_corrupt_policy_reinstall(false) {} | |
| 42 | |
| 40 ManifestFetchData::ManifestFetchData(const GURL& update_url, | 43 ManifestFetchData::ManifestFetchData(const GURL& update_url, |
| 41 int request_id, | 44 int request_id, |
| 42 const std::string& brand_code, | 45 const std::string& brand_code, |
| 43 const std::string& base_query_params, | 46 const std::string& base_query_params, |
| 44 PingMode ping_mode) | 47 PingMode ping_mode) |
| 45 : base_url_(update_url), | 48 : base_url_(update_url), |
| 46 full_url_(update_url), | 49 full_url_(update_url), |
| 47 brand_code_(brand_code), | 50 brand_code_(brand_code), |
| 48 ping_mode_(ping_mode) { | 51 ping_mode_(ping_mode) { |
| 49 std::string query = | 52 std::string query = |
| (...skipping 27 matching lines...) Expand all Loading... | |
| 77 // Extension 1- id:aaaa version:1.1 | 80 // Extension 1- id:aaaa version:1.1 |
| 78 // Extension 2- id:bbbb version:2.0 | 81 // Extension 2- id:bbbb version:2.0 |
| 79 // | 82 // |
| 80 // the full update url would be: | 83 // the full update url would be: |
| 81 // http://somehost/path?x=id%3Daaaa%26v%3D1.1%26uc&x=id%3Dbbbb%26v%3D2.0%26uc | 84 // http://somehost/path?x=id%3Daaaa%26v%3D1.1%26uc&x=id%3Dbbbb%26v%3D2.0%26uc |
| 82 // | 85 // |
| 83 // (Note that '=' is %3D and '&' is %26 when urlencoded.) | 86 // (Note that '=' is %3D and '&' is %26 when urlencoded.) |
| 84 bool ManifestFetchData::AddExtension(const std::string& id, | 87 bool ManifestFetchData::AddExtension(const std::string& id, |
| 85 const std::string& version, | 88 const std::string& version, |
| 86 const PingData* ping_data, | 89 const PingData* ping_data, |
| 87 const std::string& update_url_data, | 90 const std::string& install_source, |
| 88 const std::string& install_source) { | 91 const ExtraParams* extra_params) { |
| 89 if (extension_ids_.find(id) != extension_ids_.end()) { | 92 if (extension_ids_.find(id) != extension_ids_.end()) { |
| 90 NOTREACHED() << "Duplicate extension id " << id; | 93 NOTREACHED() << "Duplicate extension id " << id; |
| 91 return false; | 94 return false; |
| 92 } | 95 } |
| 93 | 96 |
| 94 // Compute the string we'd append onto the full_url_, and see if it fits. | 97 // Compute the string we'd append onto the full_url_, and see if it fits. |
| 95 std::vector<std::string> parts; | 98 std::vector<std::string> parts; |
| 96 parts.push_back("id=" + id); | 99 parts.push_back("id=" + id); |
| 97 parts.push_back("v=" + version); | 100 parts.push_back("v=" + version); |
| 98 if (!install_source.empty()) | 101 if (!install_source.empty()) |
| 99 parts.push_back("installsource=" + install_source); | 102 parts.push_back("installsource=" + install_source); |
| 100 parts.push_back("uc"); | 103 parts.push_back("uc"); |
| 101 | 104 |
| 102 if (!update_url_data.empty()) { | 105 if (extra_params && !extra_params->update_url_data.empty()) { |
| 103 // Make sure the update_url_data string is escaped before using it so that | 106 // Make sure the update_url_data string is escaped before using it so that |
| 104 // there is no chance of overriding the id or v other parameter value | 107 // there is no chance of overriding the id or v other parameter value |
| 105 // we place into the x= value. | 108 // we place into the x= value. |
| 106 parts.push_back("ap=" + net::EscapeQueryParamValue(update_url_data, true)); | 109 parts.push_back("ap=" + net::EscapeQueryParamValue( |
| 110 extra_params->update_url_data, true)); | |
| 107 } | 111 } |
| 112 if (extra_params && extra_params->is_corrupt_policy_reinstall) | |
| 113 parts.push_back("cpr"); | |
|
lazyboy
2016/09/02 19:21:53
We should update the this function's documentation
asargent_no_longer_on_chrome
2016/09/09 03:30:44
(changes in this file have been reverted, since we
| |
| 108 | 114 |
| 109 // Append brand code, rollcall and active ping parameters. | 115 // Append brand code, rollcall and active ping parameters. |
| 110 if (ping_mode_ != NO_PING) { | 116 if (ping_mode_ != NO_PING) { |
| 111 if (!brand_code_.empty()) | 117 if (!brand_code_.empty()) |
| 112 parts.push_back(base::StringPrintf("brand=%s", brand_code_.c_str())); | 118 parts.push_back(base::StringPrintf("brand=%s", brand_code_.c_str())); |
| 113 | 119 |
| 114 std::string ping_value; | 120 std::string ping_value; |
| 115 pings_[id] = PingData(0, 0, false, 0); | 121 pings_[id] = PingData(0, 0, false, 0); |
| 116 if (ping_data) { | 122 if (ping_data) { |
| 117 if (ping_data->rollcall_days == kNeverPinged || | 123 if (ping_data->rollcall_days == kNeverPinged || |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 170 NOTREACHED(); | 176 NOTREACHED(); |
| 171 return value == kNeverPinged || value > 0; | 177 return value == kNeverPinged || value > 0; |
| 172 } | 178 } |
| 173 | 179 |
| 174 void ManifestFetchData::Merge(const ManifestFetchData& other) { | 180 void ManifestFetchData::Merge(const ManifestFetchData& other) { |
| 175 DCHECK(full_url() == other.full_url()); | 181 DCHECK(full_url() == other.full_url()); |
| 176 request_ids_.insert(other.request_ids_.begin(), other.request_ids_.end()); | 182 request_ids_.insert(other.request_ids_.begin(), other.request_ids_.end()); |
| 177 } | 183 } |
| 178 | 184 |
| 179 } // namespace extensions | 185 } // namespace extensions |
| OLD | NEW |