OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "chrome/browser/chromeos/app_mode/kiosk_external_update_validator.h" |
| 6 |
| 7 #include "base/bind.h" |
| 8 #include "base/location.h" |
| 9 #include "extensions/common/extension.h" |
| 10 |
| 11 namespace chromeos { |
| 12 |
| 13 KioskExternalUpdateValidator::KioskExternalUpdateValidator( |
| 14 const scoped_refptr<base::SequencedTaskRunner>& backend_task_runner, |
| 15 const std::string& app_id, |
| 16 const base::FilePath& crx_dir, |
| 17 const base::FilePath& crx_unpack_dir, |
| 18 KioskExternalUpdateValidatorDelegate* delegate) |
| 19 : backend_task_runner_(backend_task_runner), |
| 20 app_id_(app_id), |
| 21 crx_dir_(crx_dir), |
| 22 crx_unpack_dir_(crx_unpack_dir), |
| 23 delegate_(delegate) { |
| 24 } |
| 25 |
| 26 KioskExternalUpdateValidator::~KioskExternalUpdateValidator() { |
| 27 } |
| 28 |
| 29 void KioskExternalUpdateValidator::Start() { |
| 30 scoped_refptr<extensions::SandboxedUnpacker> unpacker( |
| 31 new extensions::SandboxedUnpacker(crx_dir_, |
| 32 extensions::Manifest::EXTERNAL_PREF, |
| 33 extensions::Extension::NO_FLAGS, |
| 34 crx_unpack_dir_, |
| 35 backend_task_runner_.get(), |
| 36 this)); |
| 37 if (!backend_task_runner_->PostTask( |
| 38 FROM_HERE, |
| 39 base::Bind(&extensions::SandboxedUnpacker::Start, unpacker.get()))) { |
| 40 NOTREACHED(); |
| 41 } |
| 42 } |
| 43 |
| 44 void KioskExternalUpdateValidator::OnUnpackFailure( |
| 45 const base::string16& error_message) { |
| 46 LOG(ERROR) << "Failed to unpack external kiosk crx file: " << app_id_ << " " |
| 47 << error_message; |
| 48 if (delegate_) |
| 49 delegate_->OnExternalUpdateUnpackFailure(app_id_); |
| 50 } |
| 51 |
| 52 void KioskExternalUpdateValidator::OnUnpackSuccess( |
| 53 const base::FilePath& temp_dir, |
| 54 const base::FilePath& extension_dir, |
| 55 const base::DictionaryValue* original_manifest, |
| 56 const extensions::Extension* extension, |
| 57 const SkBitmap& install_icon) { |
| 58 DCHECK(app_id_ == extension->id()); |
| 59 if (delegate_) |
| 60 delegate_->OnExtenalUpdateUnpackSuccess(app_id_, temp_dir, extension); |
| 61 } |
| 62 |
| 63 } // namespace chromeos |
OLD | NEW |