OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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/logging.h" | 10 #include "base/logging.h" |
11 #include "base/file_util.h" | 11 #include "base/file_util.h" |
12 #include "base/file_version_info.h" | 12 #include "base/file_version_info.h" |
13 #include "base/rand_util.h" | 13 #include "base/rand_util.h" |
14 #include "base/sha2.h" | 14 #include "base/sha2.h" |
15 #include "base/stl_util-inl.h" | 15 #include "base/stl_util-inl.h" |
16 #include "base/string_util.h" | 16 #include "base/string_util.h" |
17 #include "base/time.h" | 17 #include "base/time.h" |
18 #include "base/thread.h" | 18 #include "base/thread.h" |
19 #include "base/version.h" | 19 #include "base/version.h" |
20 #include "chrome/app/chrome_version_info.h" | 20 #include "chrome/app/chrome_version_info.h" |
21 #include "chrome/browser/browser_process.h" | 21 #include "chrome/browser/browser_process.h" |
22 #include "chrome/browser/extensions/extension_error_reporter.h" | 22 #include "chrome/browser/extensions/extension_error_reporter.h" |
23 #include "chrome/browser/extensions/extensions_service.h" | 23 #include "chrome/browser/extensions/extensions_service.h" |
24 #include "chrome/browser/pref_service.h" | 24 #include "chrome/browser/pref_service.h" |
25 #include "chrome/browser/profile.h" | 25 #include "chrome/browser/profile.h" |
26 #include "chrome/browser/utility_process_host.h" | 26 #include "chrome/browser/utility_process_host.h" |
27 #include "chrome/common/chrome_switches.h" | 27 #include "chrome/common/chrome_switches.h" |
28 #include "chrome/common/extensions/extension.h" | 28 #include "chrome/common/extensions/extension.h" |
| 29 #include "chrome/common/extensions/extension_constants.h" |
29 #include "chrome/common/pref_names.h" | 30 #include "chrome/common/pref_names.h" |
30 #include "googleurl/src/gurl.h" | 31 #include "googleurl/src/gurl.h" |
31 #include "net/base/escape.h" | 32 #include "net/base/escape.h" |
32 #include "net/base/load_flags.h" | 33 #include "net/base/load_flags.h" |
33 #include "net/url_request/url_request_status.h" | 34 #include "net/url_request/url_request_status.h" |
34 | 35 |
35 #if defined(OS_WIN) | 36 #if defined(OS_WIN) |
36 #include "base/registry.h" | 37 #include "base/registry.h" |
37 #elif defined(OS_MACOSX) | 38 #elif defined(OS_MACOSX) |
38 #include "base/sys_string_conversions.h" | 39 #include "base/sys_string_conversions.h" |
39 #endif | 40 #endif |
40 | 41 |
41 using base::RandDouble; | 42 using base::RandDouble; |
42 using base::RandInt; | 43 using base::RandInt; |
43 using base::Time; | 44 using base::Time; |
44 using base::TimeDelta; | 45 using base::TimeDelta; |
45 using prefs::kExtensionBlacklistUpdateVersion; | 46 using prefs::kExtensionBlacklistUpdateVersion; |
46 using prefs::kLastExtensionsUpdateCheck; | 47 using prefs::kLastExtensionsUpdateCheck; |
47 using prefs::kNextExtensionsUpdateCheck; | 48 using prefs::kNextExtensionsUpdateCheck; |
48 | 49 |
49 // The default URL to fall back to if an extension doesn't have an | |
50 // update URL. | |
51 const char kDefaultUpdateURL[] = | |
52 "http://clients2.google.com/service/update2/crx"; | |
53 | |
54 // NOTE: HTTPS is used here to ensure the response from omaha can be trusted. | 50 // NOTE: HTTPS is used here to ensure the response from omaha can be trusted. |
55 // The response contains a url for fetching the blacklist and a hash value | 51 // The response contains a url for fetching the blacklist and a hash value |
56 // for validation. | 52 // for validation. |
57 const char* ExtensionUpdater::kBlacklistUpdateUrl = | 53 const char* ExtensionUpdater::kBlacklistUpdateUrl = |
58 "https://clients2.google.com/service/update2/crx"; | 54 "https://clients2.google.com/service/update2/crx"; |
59 | 55 |
60 // Update AppID for extension blacklist. | 56 // Update AppID for extension blacklist. |
61 const char* ExtensionUpdater::kBlacklistAppID = "com.google.crx.blacklist"; | 57 const char* ExtensionUpdater::kBlacklistAppID = "com.google.crx.blacklist"; |
62 | 58 |
63 // Wait at least 5 minutes after browser startup before we do any checks. If you | 59 // Wait at least 5 minutes after browser startup before we do any checks. If you |
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
234 // scripts. | 230 // scripts. |
235 if (converted_from_user_script && update_url.is_empty()) { | 231 if (converted_from_user_script && update_url.is_empty()) { |
236 return; | 232 return; |
237 } | 233 } |
238 | 234 |
239 if (update_url.DomainIs("google.com")) { | 235 if (update_url.DomainIs("google.com")) { |
240 url_stats_.google_url_count++; | 236 url_stats_.google_url_count++; |
241 } else if (update_url.is_empty()) { | 237 } else if (update_url.is_empty()) { |
242 url_stats_.no_url_count++; | 238 url_stats_.no_url_count++; |
243 // Fill in default update URL. | 239 // Fill in default update URL. |
244 update_url = GURL(kDefaultUpdateURL); | 240 update_url = GURL(extension_urls::kGalleryUpdateURL); |
245 } else { | 241 } else { |
246 url_stats_.other_url_count++; | 242 url_stats_.other_url_count++; |
247 } | 243 } |
248 | 244 |
249 if (is_theme) { | 245 if (is_theme) { |
250 url_stats_.theme_count++; | 246 url_stats_.theme_count++; |
251 } | 247 } |
252 | 248 |
253 DCHECK(!update_url.is_empty()); | 249 DCHECK(!update_url.is_empty()); |
254 DCHECK(update_url.is_valid()); | 250 DCHECK(update_url.is_valid()); |
(...skipping 588 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
843 extension_fetcher_.reset( | 839 extension_fetcher_.reset( |
844 URLFetcher::Create(kExtensionFetcherId, url, URLFetcher::GET, this)); | 840 URLFetcher::Create(kExtensionFetcherId, url, URLFetcher::GET, this)); |
845 extension_fetcher_->set_request_context( | 841 extension_fetcher_->set_request_context( |
846 Profile::GetDefaultRequestContext()); | 842 Profile::GetDefaultRequestContext()); |
847 extension_fetcher_->set_load_flags(net::LOAD_DO_NOT_SEND_COOKIES | | 843 extension_fetcher_->set_load_flags(net::LOAD_DO_NOT_SEND_COOKIES | |
848 net::LOAD_DO_NOT_SAVE_COOKIES); | 844 net::LOAD_DO_NOT_SAVE_COOKIES); |
849 extension_fetcher_->Start(); | 845 extension_fetcher_->Start(); |
850 current_extension_fetch_ = ExtensionFetch(id, url, hash, version); | 846 current_extension_fetch_ = ExtensionFetch(id, url, hash, version); |
851 } | 847 } |
852 } | 848 } |
OLD | NEW |