| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_app_data.h" | 5 #include "chrome/browser/chromeos/app_mode/kiosk_app_data.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/files/file_util.h" | 10 #include "base/files/file_util.h" |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 102 | 102 |
| 103 private: | 103 private: |
| 104 ~CrxLoader() override {}; | 104 ~CrxLoader() override {}; |
| 105 | 105 |
| 106 // extensions::SandboxedUnpackerClient | 106 // extensions::SandboxedUnpackerClient |
| 107 void OnUnpackSuccess(const base::FilePath& temp_dir, | 107 void OnUnpackSuccess(const base::FilePath& temp_dir, |
| 108 const base::FilePath& extension_root, | 108 const base::FilePath& extension_root, |
| 109 std::unique_ptr<base::DictionaryValue> original_manifest, | 109 std::unique_ptr<base::DictionaryValue> original_manifest, |
| 110 const extensions::Extension* extension, | 110 const extensions::Extension* extension, |
| 111 const SkBitmap& install_icon) override { | 111 const SkBitmap& install_icon) override { |
| 112 DCHECK(task_runner_->RunsTasksOnCurrentThread()); | 112 DCHECK(task_runner_->RunsTasksInCurrentSequence()); |
| 113 | 113 |
| 114 const extensions::KioskModeInfo* info = | 114 const extensions::KioskModeInfo* info = |
| 115 extensions::KioskModeInfo::Get(extension); | 115 extensions::KioskModeInfo::Get(extension); |
| 116 if (info == nullptr) { | 116 if (info == nullptr) { |
| 117 LOG(ERROR) << extension->id() << " is not a valid kiosk app."; | 117 LOG(ERROR) << extension->id() << " is not a valid kiosk app."; |
| 118 success_ = false; | 118 success_ = false; |
| 119 } else { | 119 } else { |
| 120 success_ = true; | 120 success_ = true; |
| 121 name_ = extension->name(); | 121 name_ = extension->name(); |
| 122 icon_ = install_icon; | 122 icon_ = install_icon; |
| 123 required_platform_version_ = info->required_platform_version; | 123 required_platform_version_ = info->required_platform_version; |
| 124 } | 124 } |
| 125 NotifyFinishedOnBlockingPool(); | 125 NotifyFinishedOnBlockingPool(); |
| 126 } | 126 } |
| 127 void OnUnpackFailure(const extensions::CrxInstallError& error) override { | 127 void OnUnpackFailure(const extensions::CrxInstallError& error) override { |
| 128 DCHECK(task_runner_->RunsTasksOnCurrentThread()); | 128 DCHECK(task_runner_->RunsTasksInCurrentSequence()); |
| 129 | 129 |
| 130 success_ = false; | 130 success_ = false; |
| 131 NotifyFinishedOnBlockingPool(); | 131 NotifyFinishedOnBlockingPool(); |
| 132 } | 132 } |
| 133 | 133 |
| 134 void StartOnBlockingPool() { | 134 void StartOnBlockingPool() { |
| 135 DCHECK(task_runner_->RunsTasksOnCurrentThread()); | 135 DCHECK(task_runner_->RunsTasksInCurrentSequence()); |
| 136 | 136 |
| 137 if (!temp_dir_.CreateUniqueTempDir()) { | 137 if (!temp_dir_.CreateUniqueTempDir()) { |
| 138 success_ = false; | 138 success_ = false; |
| 139 NotifyFinishedOnBlockingPool(); | 139 NotifyFinishedOnBlockingPool(); |
| 140 return; | 140 return; |
| 141 } | 141 } |
| 142 | 142 |
| 143 scoped_refptr<extensions::SandboxedUnpacker> unpacker( | 143 scoped_refptr<extensions::SandboxedUnpacker> unpacker( |
| 144 new extensions::SandboxedUnpacker( | 144 new extensions::SandboxedUnpacker( |
| 145 extensions::Manifest::INTERNAL, extensions::Extension::NO_FLAGS, | 145 extensions::Manifest::INTERNAL, extensions::Extension::NO_FLAGS, |
| 146 temp_dir_.GetPath(), task_runner_.get(), this)); | 146 temp_dir_.GetPath(), task_runner_.get(), this)); |
| 147 unpacker->StartWithCrx(extensions::CRXFileInfo(crx_file_)); | 147 unpacker->StartWithCrx(extensions::CRXFileInfo(crx_file_)); |
| 148 } | 148 } |
| 149 | 149 |
| 150 void NotifyFinishedOnBlockingPool() { | 150 void NotifyFinishedOnBlockingPool() { |
| 151 DCHECK(task_runner_->RunsTasksOnCurrentThread()); | 151 DCHECK(task_runner_->RunsTasksInCurrentSequence()); |
| 152 | 152 |
| 153 if (!temp_dir_.Delete()) { | 153 if (!temp_dir_.Delete()) { |
| 154 LOG(WARNING) << "Can not delete temp directory at " | 154 LOG(WARNING) << "Can not delete temp directory at " |
| 155 << temp_dir_.GetPath().value(); | 155 << temp_dir_.GetPath().value(); |
| 156 } | 156 } |
| 157 | 157 |
| 158 BrowserThread::PostTask( | 158 BrowserThread::PostTask( |
| 159 BrowserThread::UI, FROM_HERE, | 159 BrowserThread::UI, FROM_HERE, |
| 160 base::Bind(&CrxLoader::NotifyFinishedOnUIThread, this)); | 160 base::Bind(&CrxLoader::NotifyFinishedOnUIThread, this)); |
| 161 } | 161 } |
| (...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 538 | 538 |
| 539 SkBitmap icon = crx_loader->icon(); | 539 SkBitmap icon = crx_loader->icon(); |
| 540 if (icon.empty()) | 540 if (icon.empty()) |
| 541 icon = *extensions::util::GetDefaultAppIcon().bitmap(); | 541 icon = *extensions::util::GetDefaultAppIcon().bitmap(); |
| 542 SetCache(crx_loader->name(), icon, crx_loader->required_platform_version()); | 542 SetCache(crx_loader->name(), icon, crx_loader->required_platform_version()); |
| 543 | 543 |
| 544 SetStatus(STATUS_LOADED); | 544 SetStatus(STATUS_LOADED); |
| 545 } | 545 } |
| 546 | 546 |
| 547 } // namespace chromeos | 547 } // namespace chromeos |
| OLD | NEW |