| 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" |
| (...skipping 454 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 465 void AppendExtensionInfo(std::string* str, const Extension& extension) { | 465 void AppendExtensionInfo(std::string* str, const Extension& extension) { |
| 466 const Version* version = extension.version(); | 466 const Version* version = extension.version(); |
| 467 DCHECK(version); | 467 DCHECK(version); |
| 468 std::vector<std::string> parts; | 468 std::vector<std::string> parts; |
| 469 | 469 |
| 470 // Push extension id, version, and uc (indicates an update check to Omaha). | 470 // Push extension id, version, and uc (indicates an update check to Omaha). |
| 471 parts.push_back("id=" + extension.id()); | 471 parts.push_back("id=" + extension.id()); |
| 472 parts.push_back("v=" + version->GetString()); | 472 parts.push_back("v=" + version->GetString()); |
| 473 parts.push_back("uc"); | 473 parts.push_back("uc"); |
| 474 | 474 |
| 475 str->append("x=" + EscapeQueryParamValue(JoinString(parts, '&'))); | 475 str->append("x=" + EscapeQueryParamValue(JoinString(parts, '&'), true)); |
| 476 } | 476 } |
| 477 | 477 |
| 478 // Creates a blacklist update url. | 478 // Creates a blacklist update url. |
| 479 GURL ExtensionUpdater::GetBlacklistUpdateUrl(const std::wstring& version) { | 479 GURL ExtensionUpdater::GetBlacklistUpdateUrl(const std::wstring& version) { |
| 480 std::string blklist_info = StringPrintf("id=%s&v=%s&uc", kBlacklistAppID, | 480 std::string blklist_info = StringPrintf("id=%s&v=%s&uc", kBlacklistAppID, |
| 481 WideToASCII(version).c_str()); | 481 WideToASCII(version).c_str()); |
| 482 return GURL(StringPrintf("%s?x=%s", kBlacklistUpdateUrl, | 482 return GURL(StringPrintf("%s?x=%s", kBlacklistUpdateUrl, |
| 483 EscapeQueryParamValue(blklist_info).c_str())); | 483 EscapeQueryParamValue(blklist_info, true).c_str())); |
| 484 } | 484 } |
| 485 | 485 |
| 486 void ExtensionUpdater::ScheduleNextCheck(const TimeDelta& target_delay) { | 486 void ExtensionUpdater::ScheduleNextCheck(const TimeDelta& target_delay) { |
| 487 DCHECK(!timer_.IsRunning()); | 487 DCHECK(!timer_.IsRunning()); |
| 488 DCHECK(target_delay >= TimeDelta::FromSeconds(1)); | 488 DCHECK(target_delay >= TimeDelta::FromSeconds(1)); |
| 489 | 489 |
| 490 // Add +/- 10% random jitter. | 490 // Add +/- 10% random jitter. |
| 491 double delay_ms = target_delay.InMillisecondsF(); | 491 double delay_ms = target_delay.InMillisecondsF(); |
| 492 double jitter_factor = (RandDouble() * .2) - 0.1; | 492 double jitter_factor = (RandDouble() * .2) - 0.1; |
| 493 delay_ms += delay_ms * jitter_factor; | 493 delay_ms += delay_ms * jitter_factor; |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 568 // Append extension information to the url. | 568 // Append extension information to the url. |
| 569 std::string full_url_string = update_url.spec(); | 569 std::string full_url_string = update_url.spec(); |
| 570 full_url_string.append(update_url.has_query() ? "&" : "?"); | 570 full_url_string.append(update_url.has_query() ? "&" : "?"); |
| 571 AppendExtensionInfo(&full_url_string, *extension); | 571 AppendExtensionInfo(&full_url_string, *extension); |
| 572 | 572 |
| 573 // Send the Omaha uid when doing update checks to Omaha. | 573 // Send the Omaha uid when doing update checks to Omaha. |
| 574 if (update_url.DomainIs("google.com")) { | 574 if (update_url.DomainIs("google.com")) { |
| 575 std::string uid = uid_provider_->GetUidString(); | 575 std::string uid = uid_provider_->GetUidString(); |
| 576 if (uid.length() > 0 && uid.length() <= UidProvider::maxUidLength) { | 576 if (uid.length() > 0 && uid.length() <= UidProvider::maxUidLength) { |
| 577 full_url_string.append("&" + std::string(ExtensionUpdater::kUidKey) + | 577 full_url_string.append("&" + std::string(ExtensionUpdater::kUidKey) + |
| 578 "=" + EscapeQueryParamValue(uid)); | 578 "=" + EscapeQueryParamValue(uid, true)); |
| 579 } | 579 } |
| 580 } | 580 } |
| 581 | 581 |
| 582 GURL full_url(full_url_string); | 582 GURL full_url(full_url_string); |
| 583 if (!full_url.is_valid()) { | 583 if (!full_url.is_valid()) { |
| 584 LOG(ERROR) << "invalid url: " << full_url.possibly_invalid_spec(); | 584 LOG(ERROR) << "invalid url: " << full_url.possibly_invalid_spec(); |
| 585 NOTREACHED(); | 585 NOTREACHED(); |
| 586 } else { | 586 } else { |
| 587 urls.insert(full_url); | 587 urls.insert(full_url); |
| 588 } | 588 } |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 721 extension_fetcher_.reset( | 721 extension_fetcher_.reset( |
| 722 URLFetcher::Create(kExtensionFetcherId, url, URLFetcher::GET, this)); | 722 URLFetcher::Create(kExtensionFetcherId, url, URLFetcher::GET, this)); |
| 723 extension_fetcher_->set_request_context( | 723 extension_fetcher_->set_request_context( |
| 724 Profile::GetDefaultRequestContext()); | 724 Profile::GetDefaultRequestContext()); |
| 725 extension_fetcher_->set_load_flags(net::LOAD_DO_NOT_SEND_COOKIES | | 725 extension_fetcher_->set_load_flags(net::LOAD_DO_NOT_SEND_COOKIES | |
| 726 net::LOAD_DO_NOT_SAVE_COOKIES); | 726 net::LOAD_DO_NOT_SAVE_COOKIES); |
| 727 extension_fetcher_->Start(); | 727 extension_fetcher_->Start(); |
| 728 current_extension_fetch_ = ExtensionFetch(id, url, hash, version); | 728 current_extension_fetch_ = ExtensionFetch(id, url, hash, version); |
| 729 } | 729 } |
| 730 } | 730 } |
| OLD | NEW |