Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1106)

Side by Side Diff: chrome/browser/extensions/extension_updater.cc

Issue 3056029: Move the number conversions from string_util to a new file.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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/histogram.h" 13 #include "base/histogram.h"
14 #include "base/rand_util.h" 14 #include "base/rand_util.h"
15 #include "base/sha2.h" 15 #include "base/sha2.h"
16 #include "base/stl_util-inl.h" 16 #include "base/stl_util-inl.h"
17 #include "base/string_number_conversions.h"
17 #include "base/string_util.h" 18 #include "base/string_util.h"
18 #include "base/time.h" 19 #include "base/time.h"
19 #include "base/thread.h" 20 #include "base/thread.h"
20 #include "base/version.h" 21 #include "base/version.h"
21 #include "chrome/browser/browser_process.h" 22 #include "chrome/browser/browser_process.h"
22 #include "chrome/browser/extensions/extension_error_reporter.h" 23 #include "chrome/browser/extensions/extension_error_reporter.h"
23 #include "chrome/browser/extensions/extensions_service.h" 24 #include "chrome/browser/extensions/extensions_service.h"
24 #include "chrome/browser/pref_service.h" 25 #include "chrome/browser/pref_service.h"
25 #include "chrome/browser/profile.h" 26 #include "chrome/browser/profile.h"
26 #include "chrome/browser/utility_process_host.h" 27 #include "chrome/browser/utility_process_host.h"
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 return false; 99 return false;
99 } 100 }
100 101
101 // Compute the string we'd append onto the full_url_, and see if it fits. 102 // Compute the string we'd append onto the full_url_, and see if it fits.
102 std::vector<std::string> parts; 103 std::vector<std::string> parts;
103 parts.push_back("id=" + id); 104 parts.push_back("id=" + id);
104 parts.push_back("v=" + version); 105 parts.push_back("v=" + version);
105 parts.push_back("uc"); 106 parts.push_back("uc");
106 107
107 if (ShouldPing(days)) { 108 if (ShouldPing(days)) {
108 parts.push_back("ping=" + EscapeQueryParamValue("r=" + IntToString(days), 109 parts.push_back("ping=" +
109 true)); 110 EscapeQueryParamValue("r=" + base::IntToString(days), true));
110 } 111 }
111 112
112 std::string extra = full_url_.has_query() ? "&" : "?"; 113 std::string extra = full_url_.has_query() ? "&" : "?";
113 extra += "x=" + EscapeQueryParamValue(JoinString(parts, '&'), true); 114 extra += "x=" + EscapeQueryParamValue(JoinString(parts, '&'), true);
114 115
115 // Check against our max url size, exempting the first extension added. 116 // Check against our max url size, exempting the first extension added.
116 int new_size = full_url_.possibly_invalid_spec().size() + extra.size(); 117 int new_size = full_url_.possibly_invalid_spec().size() + extra.size();
117 if (extension_ids_.size() > 0 && new_size > kExtensionsManifestMaxURLSize) { 118 if (extension_ids_.size() > 0 && new_size > kExtensionsManifestMaxURLSize) {
118 UMA_HISTOGRAM_PERCENTAGE("Extensions.UpdateCheckHitUrlSizeLimit", 1); 119 UMA_HISTOGRAM_PERCENTAGE("Extensions.UpdateCheckHitUrlSizeLimit", 1);
119 return false; 120 return false;
(...skipping 429 matching lines...) Expand 10 before | Expand all | Expand 10 after
549 } 550 }
550 } 551 }
551 } 552 }
552 } 553 }
553 } 554 }
554 555
555 void ExtensionUpdater::ProcessBlacklist(const std::string& data) { 556 void ExtensionUpdater::ProcessBlacklist(const std::string& data) {
556 // Verify sha256 hash value. 557 // Verify sha256 hash value.
557 char sha256_hash_value[base::SHA256_LENGTH]; 558 char sha256_hash_value[base::SHA256_LENGTH];
558 base::SHA256HashString(data, sha256_hash_value, base::SHA256_LENGTH); 559 base::SHA256HashString(data, sha256_hash_value, base::SHA256_LENGTH);
559 std::string hash_in_hex = HexEncode(sha256_hash_value, base::SHA256_LENGTH); 560 std::string hash_in_hex = base::HexEncode(sha256_hash_value,
561 base::SHA256_LENGTH);
560 562
561 if (current_extension_fetch_.package_hash != hash_in_hex) { 563 if (current_extension_fetch_.package_hash != hash_in_hex) {
562 NOTREACHED() << "Fetched blacklist checksum is not as expected. " 564 NOTREACHED() << "Fetched blacklist checksum is not as expected. "
563 << "Expected: " << current_extension_fetch_.package_hash 565 << "Expected: " << current_extension_fetch_.package_hash
564 << " Actual: " << hash_in_hex; 566 << " Actual: " << hash_in_hex;
565 return; 567 return;
566 } 568 }
567 std::vector<std::string> blacklist; 569 std::vector<std::string> blacklist;
568 SplitString(data, '\n', &blacklist); 570 SplitString(data, '\n', &blacklist);
569 571
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after
835 extension_fetcher_.reset( 837 extension_fetcher_.reset(
836 URLFetcher::Create(kExtensionFetcherId, url, URLFetcher::GET, this)); 838 URLFetcher::Create(kExtensionFetcherId, url, URLFetcher::GET, this));
837 extension_fetcher_->set_request_context( 839 extension_fetcher_->set_request_context(
838 Profile::GetDefaultRequestContext()); 840 Profile::GetDefaultRequestContext());
839 extension_fetcher_->set_load_flags(net::LOAD_DO_NOT_SEND_COOKIES | 841 extension_fetcher_->set_load_flags(net::LOAD_DO_NOT_SEND_COOKIES |
840 net::LOAD_DO_NOT_SAVE_COOKIES); 842 net::LOAD_DO_NOT_SAVE_COOKIES);
841 extension_fetcher_->Start(); 843 extension_fetcher_->Start();
842 current_extension_fetch_ = ExtensionFetch(id, url, hash, version); 844 current_extension_fetch_ = ExtensionFetch(id, url, hash, version);
843 } 845 }
844 } 846 }
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_tabs_module.cc ('k') | chrome/browser/extensions/extension_updater_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698