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

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

Issue 829583002: Validate hash_sha256 checksum on .crx update. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add histogram description. Created 5 years, 11 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/updater/extension_updater.h" 5 #include "chrome/browser/extensions/updater/extension_updater.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <set> 8 #include <set>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 namespace extensions { 183 namespace extensions {
184 184
185 ExtensionUpdater::CheckParams::CheckParams() 185 ExtensionUpdater::CheckParams::CheckParams()
186 : install_immediately(false) {} 186 : install_immediately(false) {}
187 187
188 ExtensionUpdater::CheckParams::~CheckParams() {} 188 ExtensionUpdater::CheckParams::~CheckParams() {}
189 189
190 ExtensionUpdater::FetchedCRXFile::FetchedCRXFile( 190 ExtensionUpdater::FetchedCRXFile::FetchedCRXFile(
191 const std::string& i, 191 const std::string& i,
192 const base::FilePath& p, 192 const base::FilePath& p,
193 const std::string& h,
193 bool file_ownership_passed, 194 bool file_ownership_passed,
194 const std::set<int>& request_ids) 195 const std::set<int>& request_ids)
195 : extension_id(i), 196 : extension_id(i),
196 path(p), 197 path(p),
198 hash(h),
197 file_ownership_passed(file_ownership_passed), 199 file_ownership_passed(file_ownership_passed),
198 request_ids(request_ids) {} 200 request_ids(request_ids) {
201 }
199 202
200 ExtensionUpdater::FetchedCRXFile::FetchedCRXFile() 203 ExtensionUpdater::FetchedCRXFile::FetchedCRXFile()
201 : path(), file_ownership_passed(true) {} 204 : path(), file_ownership_passed(true) {}
202 205
203 ExtensionUpdater::FetchedCRXFile::~FetchedCRXFile() {} 206 ExtensionUpdater::FetchedCRXFile::~FetchedCRXFile() {}
204 207
205 ExtensionUpdater::InProgressCheck::InProgressCheck() 208 ExtensionUpdater::InProgressCheck::InProgressCheck()
206 : install_immediately(false) {} 209 : install_immediately(false) {}
207 210
208 ExtensionUpdater::InProgressCheck::~InProgressCheck() {} 211 ExtensionUpdater::InProgressCheck::~InProgressCheck() {}
(...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after
585 // check might have queued an update for this extension already. If a 588 // check might have queued an update for this extension already. If a
586 // current update check has |install_immediately| set the previously 589 // current update check has |install_immediately| set the previously
587 // queued update should be installed now. 590 // queued update should be installed now.
588 if (install_immediately && service_->GetPendingExtensionUpdate(id)) 591 if (install_immediately && service_->GetPendingExtensionUpdate(id))
589 service_->FinishDelayedInstallation(id); 592 service_->FinishDelayedInstallation(id);
590 } 593 }
591 594
592 void ExtensionUpdater::OnExtensionDownloadFinished( 595 void ExtensionUpdater::OnExtensionDownloadFinished(
593 const std::string& id, 596 const std::string& id,
594 const base::FilePath& path, 597 const base::FilePath& path,
598 const std::string& hash,
595 bool file_ownership_passed, 599 bool file_ownership_passed,
596 const GURL& download_url, 600 const GURL& download_url,
597 const std::string& version, 601 const std::string& version,
598 const PingResult& ping, 602 const PingResult& ping,
599 const std::set<int>& request_ids) { 603 const std::set<int>& request_ids) {
600 DCHECK(alive_); 604 DCHECK(alive_);
601 UpdatePingData(id, ping); 605 UpdatePingData(id, ping);
602 606
603 VLOG(2) << download_url << " written to " << path.value(); 607 VLOG(2) << download_url << " written to " << path.value();
604 608
605 FetchedCRXFile fetched(id, path, file_ownership_passed, request_ids); 609 FetchedCRXFile fetched(id, path, hash, file_ownership_passed, request_ids);
606 fetched_crx_files_.push(fetched); 610 fetched_crx_files_.push(fetched);
607 611
608 // MaybeInstallCRXFile() removes extensions from |in_progress_ids_| after 612 // MaybeInstallCRXFile() removes extensions from |in_progress_ids_| after
609 // starting the crx installer. 613 // starting the crx installer.
610 MaybeInstallCRXFile(); 614 MaybeInstallCRXFile();
611 } 615 }
612 616
613 bool ExtensionUpdater::GetPingDataForExtension( 617 bool ExtensionUpdater::GetPingDataForExtension(
614 const std::string& id, 618 const std::string& id,
615 ManifestFetchData::PingData* ping_data) { 619 ManifestFetchData::PingData* ping_data) {
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
680 684
681 while (!fetched_crx_files_.empty() && !crx_install_is_running_) { 685 while (!fetched_crx_files_.empty() && !crx_install_is_running_) {
682 const FetchedCRXFile& crx_file = fetched_crx_files_.top(); 686 const FetchedCRXFile& crx_file = fetched_crx_files_.top();
683 687
684 VLOG(2) << "updating " << crx_file.extension_id 688 VLOG(2) << "updating " << crx_file.extension_id
685 << " with " << crx_file.path.value(); 689 << " with " << crx_file.path.value();
686 690
687 // The ExtensionService is now responsible for cleaning up the temp file 691 // The ExtensionService is now responsible for cleaning up the temp file
688 // at |crx_file.path|. 692 // at |crx_file.path|.
689 CrxInstaller* installer = NULL; 693 CrxInstaller* installer = NULL;
690 if (service_->UpdateExtension(crx_file.extension_id, 694 if (service_->CheckAndUpdateExtension(
691 crx_file.path, 695 crx_file.extension_id, crx_file.path, crx_file.hash,
692 crx_file.file_ownership_passed, 696 crx_file.file_ownership_passed, &installer)) {
693 &installer)) {
694 crx_install_is_running_ = true; 697 crx_install_is_running_ = true;
695 current_crx_file_ = crx_file; 698 current_crx_file_ = crx_file;
696 699
697 for (std::set<int>::const_iterator it = crx_file.request_ids.begin(); 700 for (std::set<int>::const_iterator it = crx_file.request_ids.begin();
698 it != crx_file.request_ids.end(); ++it) { 701 it != crx_file.request_ids.end(); ++it) {
699 InProgressCheck& request = requests_in_progress_[*it]; 702 InProgressCheck& request = requests_in_progress_[*it];
700 if (request.install_immediately) { 703 if (request.install_immediately) {
701 installer->set_install_immediately(true); 704 installer->set_install_immediately(true);
702 break; 705 break;
703 } 706 }
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
767 const InProgressCheck& request = requests_in_progress_[request_id]; 770 const InProgressCheck& request = requests_in_progress_[request_id];
768 if (request.in_progress_ids_.empty()) { 771 if (request.in_progress_ids_.empty()) {
769 VLOG(2) << "Finished update check " << request_id; 772 VLOG(2) << "Finished update check " << request_id;
770 if (!request.callback.is_null()) 773 if (!request.callback.is_null())
771 request.callback.Run(); 774 request.callback.Run();
772 requests_in_progress_.erase(request_id); 775 requests_in_progress_.erase(request_id);
773 } 776 }
774 } 777 }
775 778
776 } // namespace extensions 779 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698