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

Side by Side Diff: chrome/browser/chromeos/app_mode/kiosk_external_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 histogram value. 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/chromeos/app_mode/kiosk_external_updater.h" 5 #include "chrome/browser/chromeos/app_mode/kiosk_external_updater.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/files/file_enumerator.h" 8 #include "base/files/file_enumerator.h"
9 #include "base/files/file_util.h" 9 #include "base/files/file_util.h"
10 #include "base/json/json_file_value_serializer.h" 10 #include "base/json/json_file_value_serializer.h"
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 return true; 86 return true;
87 else 87 else
88 return false; 88 return false;
89 } 89 }
90 90
91 } // namespace 91 } // namespace
92 92
93 KioskExternalUpdater::ExternalUpdate::ExternalUpdate() { 93 KioskExternalUpdater::ExternalUpdate::ExternalUpdate() {
94 } 94 }
95 95
96 KioskExternalUpdater::ExternalUpdate::~ExternalUpdate() {
97 }
98
96 KioskExternalUpdater::KioskExternalUpdater( 99 KioskExternalUpdater::KioskExternalUpdater(
97 const scoped_refptr<base::SequencedTaskRunner>& backend_task_runner, 100 const scoped_refptr<base::SequencedTaskRunner>& backend_task_runner,
98 const base::FilePath& crx_cache_dir, 101 const base::FilePath& crx_cache_dir,
99 const base::FilePath& crx_unpack_dir) 102 const base::FilePath& crx_unpack_dir)
100 : backend_task_runner_(backend_task_runner), 103 : backend_task_runner_(backend_task_runner),
101 crx_cache_dir_(crx_cache_dir), 104 crx_cache_dir_(crx_cache_dir),
102 crx_unpack_dir_(crx_unpack_dir), 105 crx_unpack_dir_(crx_unpack_dir),
103 weak_factory_(this) { 106 weak_factory_(this) {
104 // Subscribe to DiskMountManager. 107 // Subscribe to DiskMountManager.
105 DCHECK(disks::DiskMountManager::GetInstance()); 108 DCHECK(disks::DiskMountManager::GetInstance());
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 if (!ShouldDoExternalUpdate(app_id, version, min_browser_version)) { 192 if (!ShouldDoExternalUpdate(app_id, version, min_browser_version)) {
190 external_updates_[app_id].update_status = FAILED; 193 external_updates_[app_id].update_status = FAILED;
191 MaybeValidateNextExternalUpdate(); 194 MaybeValidateNextExternalUpdate();
192 return; 195 return;
193 } 196 }
194 197
195 // User might pull out the usb stick before updating is completed. 198 // User might pull out the usb stick before updating is completed.
196 if (CheckExternalUpdateInterrupted()) 199 if (CheckExternalUpdateInterrupted())
197 return; 200 return;
198 201
199 base::FilePath external_crx_path = external_updates_[app_id].external_crx; 202 base::FilePath external_crx_path =
203 external_updates_[app_id].external_crx.path;
200 base::FilePath temp_crx_path = 204 base::FilePath temp_crx_path =
201 crx_unpack_dir_.Append(external_crx_path.BaseName()); 205 crx_unpack_dir_.Append(external_crx_path.BaseName());
202 bool* success = new bool; 206 bool* success = new bool;
203 backend_task_runner_->PostTaskAndReply( 207 backend_task_runner_->PostTaskAndReply(
204 FROM_HERE, 208 FROM_HERE,
205 base::Bind(&CopyExternalCrxAndDeleteTempDir, 209 base::Bind(&CopyExternalCrxAndDeleteTempDir,
206 external_crx_path, 210 external_crx_path,
207 temp_crx_path, 211 temp_crx_path,
208 temp_dir, 212 temp_dir,
209 success), 213 success),
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
284 } 288 }
285 } 289 }
286 290
287 ExternalUpdate update; 291 ExternalUpdate update;
288 KioskAppManager::App app; 292 KioskAppManager::App app;
289 if (KioskAppManager::Get()->GetApp(app_id, &app)) { 293 if (KioskAppManager::Get()->GetApp(app_id, &app)) {
290 update.app_name = app.name; 294 update.app_name = app.name;
291 } else { 295 } else {
292 NOTREACHED(); 296 NOTREACHED();
293 } 297 }
294 update.external_crx = external_update_path_.AppendASCII(external_crx_str); 298 update.external_crx = extensions::CRXFileInfo(
299 app_id, external_update_path_.AppendASCII(external_crx_str));
295 update.update_status = PENDING; 300 update.update_status = PENDING;
296 external_updates_[app_id] = update; 301 external_updates_[app_id] = update;
297 } 302 }
298 303
299 if (external_updates_.empty()) { 304 if (external_updates_.empty()) {
300 NotifyKioskUpdateProgress( 305 NotifyKioskUpdateProgress(
301 ui::ResourceBundle::GetSharedInstance().GetLocalizedString( 306 ui::ResourceBundle::GetSharedInstance().GetLocalizedString(
302 IDS_KIOSK_EXTERNAL_UPDATE_NO_UPDATES)); 307 IDS_KIOSK_EXTERNAL_UPDATE_NO_UPDATES));
303 KioskAppManager::Get()->OnKioskAppExternalUpdateComplete(false); 308 KioskAppManager::Get()->OnKioskAppExternalUpdateComplete(false);
304 return; 309 return;
(...skipping 14 matching lines...) Expand all
319 return false; 324 return false;
320 } 325 }
321 326
322 void KioskExternalUpdater::ValidateExternalUpdates() { 327 void KioskExternalUpdater::ValidateExternalUpdates() {
323 for (ExternalUpdateMap::iterator it = external_updates_.begin(); 328 for (ExternalUpdateMap::iterator it = external_updates_.begin();
324 it != external_updates_.end(); 329 it != external_updates_.end();
325 ++it) { 330 ++it) {
326 if (it->second.update_status == PENDING) { 331 if (it->second.update_status == PENDING) {
327 scoped_refptr<KioskExternalUpdateValidator> crx_validator = 332 scoped_refptr<KioskExternalUpdateValidator> crx_validator =
328 new KioskExternalUpdateValidator(backend_task_runner_, 333 new KioskExternalUpdateValidator(backend_task_runner_,
329 it->first,
330 it->second.external_crx, 334 it->second.external_crx,
331 crx_unpack_dir_, 335 crx_unpack_dir_,
332 weak_factory_.GetWeakPtr()); 336 weak_factory_.GetWeakPtr());
333 crx_validator->Start(); 337 crx_validator->Start();
334 break; 338 break;
335 } 339 }
336 } 340 }
337 } 341 }
338 342
339 bool KioskExternalUpdater::IsExternalUpdatePending() { 343 bool KioskExternalUpdater::IsExternalUpdatePending() {
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
422 void KioskExternalUpdater::OnPutValidatedExtension(const std::string& app_id, 426 void KioskExternalUpdater::OnPutValidatedExtension(const std::string& app_id,
423 bool success) { 427 bool success) {
424 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 428 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
425 if (CheckExternalUpdateInterrupted()) 429 if (CheckExternalUpdateInterrupted())
426 return; 430 return;
427 431
428 if (!success) { 432 if (!success) {
429 external_updates_[app_id].update_status = FAILED; 433 external_updates_[app_id].update_status = FAILED;
430 external_updates_[app_id].error = l10n_util::GetStringFUTF16( 434 external_updates_[app_id].error = l10n_util::GetStringFUTF16(
431 IDS_KIOSK_EXTERNAL_UPDATE_CANNOT_INSTALL_IN_LOCAL_CACHE, 435 IDS_KIOSK_EXTERNAL_UPDATE_CANNOT_INSTALL_IN_LOCAL_CACHE,
432 base::UTF8ToUTF16(external_updates_[app_id].external_crx.value())); 436 base::UTF8ToUTF16(external_updates_[app_id].external_crx.path.value()));
433 } else { 437 } else {
434 external_updates_[app_id].update_status = SUCCESS; 438 external_updates_[app_id].update_status = SUCCESS;
435 } 439 }
436 440
437 // Validate the next pending external update. 441 // Validate the next pending external update.
438 MaybeValidateNextExternalUpdate(); 442 MaybeValidateNextExternalUpdate();
439 } 443 }
440 444
441 void KioskExternalUpdater::MaybeValidateNextExternalUpdate() { 445 void KioskExternalUpdater::MaybeValidateNextExternalUpdate() {
442 if (IsExternalUpdatePending()) 446 if (IsExternalUpdatePending())
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
521 if (failed) { 525 if (failed) {
522 failed_app_msg = ui::ResourceBundle::GetSharedInstance().GetLocalizedString( 526 failed_app_msg = ui::ResourceBundle::GetSharedInstance().GetLocalizedString(
523 IDS_KIOSK_EXTERNAL_UPDATE_FAILED_UPDATED_APPS) + 527 IDS_KIOSK_EXTERNAL_UPDATE_FAILED_UPDATED_APPS) +
524 base::ASCIIToUTF16("\n") + failed_apps; 528 base::ASCIIToUTF16("\n") + failed_apps;
525 message = message + base::ASCIIToUTF16("\n") + failed_app_msg; 529 message = message + base::ASCIIToUTF16("\n") + failed_app_msg;
526 } 530 }
527 return message; 531 return message;
528 } 532 }
529 533
530 } // namespace chromeos 534 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698