OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/extension_updater.h" | 5 #include "chrome/browser/extensions/extension_updater.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <set> | 8 #include <set> |
9 | 9 |
10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
| 11 #include "base/file_util.h" |
11 #include "base/logging.h" | 12 #include "base/logging.h" |
12 #include "base/file_util.h" | |
13 #include "base/memory/scoped_handle.h" | 13 #include "base/memory/scoped_handle.h" |
14 #include "base/metrics/histogram.h" | 14 #include "base/metrics/histogram.h" |
15 #include "base/rand_util.h" | 15 #include "base/rand_util.h" |
16 #include "base/stl_util.h" | 16 #include "base/stl_util.h" |
17 #include "base/string_number_conversions.h" | 17 #include "base/string_number_conversions.h" |
18 #include "base/string_split.h" | 18 #include "base/string_split.h" |
19 #include "base/string_util.h" | 19 #include "base/string_util.h" |
| 20 #include "base/threading/thread.h" |
20 #include "base/time.h" | 21 #include "base/time.h" |
21 #include "base/threading/thread.h" | |
22 #include "base/version.h" | 22 #include "base/version.h" |
23 #include "crypto/sha2.h" | |
24 #include "content/common/notification_service.h" | |
25 #include "content/common/notification_source.h" | |
26 #include "chrome/browser/browser_process.h" | 23 #include "chrome/browser/browser_process.h" |
27 #include "chrome/browser/extensions/crx_installer.h" | 24 #include "chrome/browser/extensions/crx_installer.h" |
28 #include "chrome/browser/extensions/extension_error_reporter.h" | 25 #include "chrome/browser/extensions/extension_error_reporter.h" |
29 #include "chrome/browser/extensions/extension_service.h" | 26 #include "chrome/browser/extensions/extension_service.h" |
30 #include "chrome/browser/prefs/pref_service.h" | 27 #include "chrome/browser/prefs/pref_service.h" |
31 #include "chrome/browser/profiles/profile.h" | 28 #include "chrome/browser/profiles/profile.h" |
32 #include "chrome/common/chrome_notification_types.h" | 29 #include "chrome/common/chrome_notification_types.h" |
33 #include "chrome/common/chrome_switches.h" | 30 #include "chrome/common/chrome_switches.h" |
34 #include "chrome/common/chrome_utility_messages.h" | 31 #include "chrome/common/chrome_utility_messages.h" |
35 #include "chrome/common/chrome_version_info.h" | 32 #include "chrome/common/chrome_version_info.h" |
36 #include "chrome/common/extensions/extension.h" | 33 #include "chrome/common/extensions/extension.h" |
37 #include "chrome/common/extensions/extension_constants.h" | 34 #include "chrome/common/extensions/extension_constants.h" |
38 #include "chrome/common/extensions/extension_file_util.h" | 35 #include "chrome/common/extensions/extension_file_util.h" |
39 #include "chrome/common/pref_names.h" | 36 #include "chrome/common/pref_names.h" |
40 #include "content/browser/utility_process_host.h" | 37 #include "content/browser/utility_process_host.h" |
| 38 #include "content/common/notification_service.h" |
| 39 #include "content/common/notification_source.h" |
| 40 #include "crypto/sha2.h" |
41 #include "googleurl/src/gurl.h" | 41 #include "googleurl/src/gurl.h" |
42 #include "net/base/escape.h" | 42 #include "net/base/escape.h" |
43 #include "net/base/load_flags.h" | 43 #include "net/base/load_flags.h" |
44 #include "net/url_request/url_request_status.h" | 44 #include "net/url_request/url_request_status.h" |
45 | 45 |
46 #if defined(OS_MACOSX) | 46 #if defined(OS_MACOSX) |
47 #include "base/sys_string_conversions.h" | 47 #include "base/sys_string_conversions.h" |
48 #endif | 48 #endif |
49 | 49 |
50 #define SEND_ACTIVE_PINGS 1 | 50 #define SEND_ACTIVE_PINGS 1 |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
176 // Compute the string we'd append onto the full_url_, and see if it fits. | 176 // Compute the string we'd append onto the full_url_, and see if it fits. |
177 std::vector<std::string> parts; | 177 std::vector<std::string> parts; |
178 parts.push_back("id=" + id); | 178 parts.push_back("id=" + id); |
179 parts.push_back("v=" + version); | 179 parts.push_back("v=" + version); |
180 parts.push_back("uc"); | 180 parts.push_back("uc"); |
181 | 181 |
182 if (!update_url_data.empty()) { | 182 if (!update_url_data.empty()) { |
183 // Make sure the update_url_data string is escaped before using it so that | 183 // Make sure the update_url_data string is escaped before using it so that |
184 // there is no chance of overriding the id or v other parameter value | 184 // there is no chance of overriding the id or v other parameter value |
185 // we place into the x= value. | 185 // we place into the x= value. |
186 parts.push_back("ap=" + EscapeQueryParamValue(update_url_data, true)); | 186 parts.push_back("ap=" + net::EscapeQueryParamValue(update_url_data, true)); |
187 } | 187 } |
188 | 188 |
189 // Append rollcall and active ping parameters. | 189 // Append rollcall and active ping parameters. |
190 if (base_url_.DomainIs("google.com")) { | 190 if (base_url_.DomainIs("google.com")) { |
191 std::string ping_value; | 191 std::string ping_value; |
192 pings_[id] = PingData(0, 0); | 192 pings_[id] = PingData(0, 0); |
193 | 193 |
194 if (ping_data.rollcall_days == kNeverPinged || | 194 if (ping_data.rollcall_days == kNeverPinged || |
195 ping_data.rollcall_days > 0) { | 195 ping_data.rollcall_days > 0) { |
196 ping_value += "r=" + base::IntToString(ping_data.rollcall_days); | 196 ping_value += "r=" + base::IntToString(ping_data.rollcall_days); |
197 pings_[id].rollcall_days = ping_data.rollcall_days; | 197 pings_[id].rollcall_days = ping_data.rollcall_days; |
198 } | 198 } |
199 #if SEND_ACTIVE_PINGS | 199 #if SEND_ACTIVE_PINGS |
200 if (ping_data.active_days == kNeverPinged || ping_data.active_days > 0) { | 200 if (ping_data.active_days == kNeverPinged || ping_data.active_days > 0) { |
201 if (!ping_value.empty()) | 201 if (!ping_value.empty()) |
202 ping_value += "&"; | 202 ping_value += "&"; |
203 ping_value += "a=" + base::IntToString(ping_data.active_days); | 203 ping_value += "a=" + base::IntToString(ping_data.active_days); |
204 pings_[id].active_days = ping_data.active_days; | 204 pings_[id].active_days = ping_data.active_days; |
205 } | 205 } |
206 #endif // SEND_ACTIVE_PINGS | 206 #endif // SEND_ACTIVE_PINGS |
207 if (!ping_value.empty()) | 207 if (!ping_value.empty()) |
208 parts.push_back("ping=" + EscapeQueryParamValue(ping_value, true)); | 208 parts.push_back("ping=" + net::EscapeQueryParamValue(ping_value, true)); |
209 } | 209 } |
210 | 210 |
211 std::string extra = full_url_.has_query() ? "&" : "?"; | 211 std::string extra = full_url_.has_query() ? "&" : "?"; |
212 extra += "x=" + EscapeQueryParamValue(JoinString(parts, '&'), true); | 212 extra += "x=" + net::EscapeQueryParamValue(JoinString(parts, '&'), true); |
213 | 213 |
214 // Check against our max url size, exempting the first extension added. | 214 // Check against our max url size, exempting the first extension added. |
215 int new_size = full_url_.possibly_invalid_spec().size() + extra.size(); | 215 int new_size = full_url_.possibly_invalid_spec().size() + extra.size(); |
216 if (!extension_ids_.empty() && new_size > kExtensionsManifestMaxURLSize) { | 216 if (!extension_ids_.empty() && new_size > kExtensionsManifestMaxURLSize) { |
217 UMA_HISTOGRAM_PERCENTAGE("Extensions.UpdateCheckHitUrlSizeLimit", 1); | 217 UMA_HISTOGRAM_PERCENTAGE("Extensions.UpdateCheckHitUrlSizeLimit", 1); |
218 return false; | 218 return false; |
219 } | 219 } |
220 UMA_HISTOGRAM_PERCENTAGE("Extensions.UpdateCheckHitUrlSizeLimit", 0); | 220 UMA_HISTOGRAM_PERCENTAGE("Extensions.UpdateCheckHitUrlSizeLimit", 0); |
221 | 221 |
222 // We have room so go ahead and add the extension. | 222 // We have room so go ahead and add the extension. |
(...skipping 1013 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1236 std::set<std::string>::const_iterator i; | 1236 std::set<std::string>::const_iterator i; |
1237 for (i = ids.begin(); i != ids.end(); ++i) | 1237 for (i = ids.begin(); i != ids.end(); ++i) |
1238 in_progress_ids_.insert(*i); | 1238 in_progress_ids_.insert(*i); |
1239 } | 1239 } |
1240 | 1240 |
1241 void ExtensionUpdater::RemoveFromInProgress(const std::set<std::string>& ids) { | 1241 void ExtensionUpdater::RemoveFromInProgress(const std::set<std::string>& ids) { |
1242 std::set<std::string>::const_iterator i; | 1242 std::set<std::string>::const_iterator i; |
1243 for (i = ids.begin(); i != ids.end(); ++i) | 1243 for (i = ids.begin(); i != ids.end(); ++i) |
1244 in_progress_ids_.erase(*i); | 1244 in_progress_ids_.erase(*i); |
1245 } | 1245 } |
OLD | NEW |