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

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: Fix unit tests. Created 5 years, 10 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 #include <vector> 9 #include <vector>
10 10
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 } // namespace 182 } // namespace
183 183
184 namespace extensions { 184 namespace extensions {
185 185
186 ExtensionUpdater::CheckParams::CheckParams() 186 ExtensionUpdater::CheckParams::CheckParams()
187 : install_immediately(false) {} 187 : install_immediately(false) {}
188 188
189 ExtensionUpdater::CheckParams::~CheckParams() {} 189 ExtensionUpdater::CheckParams::~CheckParams() {}
190 190
191 ExtensionUpdater::FetchedCRXFile::FetchedCRXFile( 191 ExtensionUpdater::FetchedCRXFile::FetchedCRXFile(
192 const std::string& i, 192 const CRXFileInfo& file,
193 const base::FilePath& p,
194 bool file_ownership_passed, 193 bool file_ownership_passed,
195 const std::set<int>& request_ids) 194 const std::set<int>& request_ids)
196 : extension_id(i), 195 : CRXFileInfo(file),
asargent_no_longer_on_chrome 2015/02/03 00:42:55 As FYI, if we were to continue inheritance instead
197 path(p),
198 file_ownership_passed(file_ownership_passed), 196 file_ownership_passed(file_ownership_passed),
199 request_ids(request_ids) {} 197 request_ids(request_ids) {
198 }
200 199
201 ExtensionUpdater::FetchedCRXFile::FetchedCRXFile() 200 ExtensionUpdater::FetchedCRXFile::FetchedCRXFile()
202 : path(), file_ownership_passed(true) {} 201 : CRXFileInfo(), file_ownership_passed(true) {
202 }
203 203
204 ExtensionUpdater::FetchedCRXFile::~FetchedCRXFile() {} 204 ExtensionUpdater::FetchedCRXFile::~FetchedCRXFile() {}
205 205
206 ExtensionUpdater::InProgressCheck::InProgressCheck() 206 ExtensionUpdater::InProgressCheck::InProgressCheck()
207 : install_immediately(false) {} 207 : install_immediately(false) {}
208 208
209 ExtensionUpdater::InProgressCheck::~InProgressCheck() {} 209 ExtensionUpdater::InProgressCheck::~InProgressCheck() {}
210 210
211 struct ExtensionUpdater::ThrottleInfo { 211 struct ExtensionUpdater::ThrottleInfo {
212 ThrottleInfo() 212 ThrottleInfo()
(...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after
584 584
585 // This method is called if no updates were found. However a previous update 585 // This method is called if no updates were found. However a previous update
586 // check might have queued an update for this extension already. If a 586 // check might have queued an update for this extension already. If a
587 // current update check has |install_immediately| set the previously 587 // current update check has |install_immediately| set the previously
588 // queued update should be installed now. 588 // queued update should be installed now.
589 if (install_immediately && service_->GetPendingExtensionUpdate(id)) 589 if (install_immediately && service_->GetPendingExtensionUpdate(id))
590 service_->FinishDelayedInstallation(id); 590 service_->FinishDelayedInstallation(id);
591 } 591 }
592 592
593 void ExtensionUpdater::OnExtensionDownloadFinished( 593 void ExtensionUpdater::OnExtensionDownloadFinished(
594 const std::string& id, 594 const CRXFileInfo& file,
595 const base::FilePath& path,
596 bool file_ownership_passed, 595 bool file_ownership_passed,
597 const GURL& download_url, 596 const GURL& download_url,
598 const std::string& version, 597 const std::string& version,
599 const PingResult& ping, 598 const PingResult& ping,
600 const std::set<int>& request_ids) { 599 const std::set<int>& request_ids) {
601 DCHECK(alive_); 600 DCHECK(alive_);
602 UpdatePingData(id, ping); 601 UpdatePingData(file.extension_id, ping);
603 602
604 VLOG(2) << download_url << " written to " << path.value(); 603 VLOG(2) << download_url << " written to " << file.path.value();
605 604
606 FetchedCRXFile fetched(id, path, file_ownership_passed, request_ids); 605 FetchedCRXFile fetched(file, file_ownership_passed, request_ids);
607 fetched_crx_files_.push(fetched); 606 fetched_crx_files_.push(fetched);
608 607
609 // MaybeInstallCRXFile() removes extensions from |in_progress_ids_| after 608 // MaybeInstallCRXFile() removes extensions from |in_progress_ids_| after
610 // starting the crx installer. 609 // starting the crx installer.
611 MaybeInstallCRXFile(); 610 MaybeInstallCRXFile();
612 } 611 }
613 612
614 bool ExtensionUpdater::GetPingDataForExtension( 613 bool ExtensionUpdater::GetPingDataForExtension(
615 const std::string& id, 614 const std::string& id,
616 ManifestFetchData::PingData* ping_data) { 615 ManifestFetchData::PingData* ping_data) {
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
681 680
682 while (!fetched_crx_files_.empty() && !crx_install_is_running_) { 681 while (!fetched_crx_files_.empty() && !crx_install_is_running_) {
683 const FetchedCRXFile& crx_file = fetched_crx_files_.top(); 682 const FetchedCRXFile& crx_file = fetched_crx_files_.top();
684 683
685 VLOG(2) << "updating " << crx_file.extension_id 684 VLOG(2) << "updating " << crx_file.extension_id
686 << " with " << crx_file.path.value(); 685 << " with " << crx_file.path.value();
687 686
688 // The ExtensionService is now responsible for cleaning up the temp file 687 // The ExtensionService is now responsible for cleaning up the temp file
689 // at |crx_file.path|. 688 // at |crx_file.path|.
690 CrxInstaller* installer = NULL; 689 CrxInstaller* installer = NULL;
691 if (service_->UpdateExtension(crx_file.extension_id, 690 if (service_->UpdateExtension(crx_file, crx_file.file_ownership_passed,
692 crx_file.path,
693 crx_file.file_ownership_passed,
694 &installer)) { 691 &installer)) {
695 crx_install_is_running_ = true; 692 crx_install_is_running_ = true;
696 current_crx_file_ = crx_file; 693 current_crx_file_ = crx_file;
697 694
698 for (std::set<int>::const_iterator it = crx_file.request_ids.begin(); 695 for (std::set<int>::const_iterator it = crx_file.request_ids.begin();
699 it != crx_file.request_ids.end(); ++it) { 696 it != crx_file.request_ids.end(); ++it) {
700 InProgressCheck& request = requests_in_progress_[*it]; 697 InProgressCheck& request = requests_in_progress_[*it];
701 if (request.install_immediately) { 698 if (request.install_immediately) {
702 installer->set_install_immediately(true); 699 installer->set_install_immediately(true);
703 break; 700 break;
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
768 const InProgressCheck& request = requests_in_progress_[request_id]; 765 const InProgressCheck& request = requests_in_progress_[request_id];
769 if (request.in_progress_ids_.empty()) { 766 if (request.in_progress_ids_.empty()) {
770 VLOG(2) << "Finished update check " << request_id; 767 VLOG(2) << "Finished update check " << request_id;
771 if (!request.callback.is_null()) 768 if (!request.callback.is_null())
772 request.callback.Run(); 769 request.callback.Run();
773 requests_in_progress_.erase(request_id); 770 requests_in_progress_.erase(request_id);
774 } 771 }
775 } 772 }
776 773
777 } // namespace extensions 774 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698