| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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/extensions/unpacked_installer.h" | 5 #include "chrome/browser/extensions/unpacked_installer.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/callback.h" | 8 #include "base/callback.h" |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
| (...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 278 extension_path_, | 278 extension_path_, |
| 279 installer_.extension()->manifest()->value(), | 279 installer_.extension()->manifest()->value(), |
| 280 &error)) { | 280 &error)) { |
| 281 BrowserThread::PostTask( | 281 BrowserThread::PostTask( |
| 282 BrowserThread::UI, | 282 BrowserThread::UI, |
| 283 FROM_HERE, | 283 FROM_HERE, |
| 284 base::Bind(&UnpackedInstaller::ReportExtensionLoadError, this, error)); | 284 base::Bind(&UnpackedInstaller::ReportExtensionLoadError, this, error)); |
| 285 return; | 285 return; |
| 286 } | 286 } |
| 287 | 287 |
| 288 // The installation prompt is about to be shown, which means we're past the | |
| 289 // point of detecting installation errors. We can now safely remove the retry | |
| 290 // handler that listens for them. | |
| 291 BrowserThread::PostTask( | |
| 292 BrowserThread::UI, | |
| 293 FROM_HERE, | |
| 294 base::Bind(&UnpackedInstaller::UnregisterLoadRetryListener, this)); | |
| 295 | |
| 296 BrowserThread::PostTask( | 288 BrowserThread::PostTask( |
| 297 BrowserThread::UI, | 289 BrowserThread::UI, |
| 298 FROM_HERE, | 290 FROM_HERE, |
| 299 base::Bind(&UnpackedInstaller::ShowInstallPrompt, this)); | 291 base::Bind(&UnpackedInstaller::ShowInstallPrompt, this)); |
| 300 } | 292 } |
| 301 | 293 |
| 302 void UnpackedInstaller::UnregisterLoadRetryListener() { | |
| 303 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | |
| 304 if (!service_weak_.get()) | |
| 305 return; | |
| 306 service_weak_->NotifyLoadRetry(false, extension_path_); | |
| 307 } | |
| 308 | |
| 309 void UnpackedInstaller::ReportExtensionLoadError(const std::string &error) { | 294 void UnpackedInstaller::ReportExtensionLoadError(const std::string &error) { |
| 310 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 295 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 311 if (!service_weak_.get()) | 296 if (!on_failure_callback_.is_null()) |
| 312 return; | 297 on_failure_callback_.Run(extension_path_, error); |
| 313 service_weak_->ReportExtensionLoadError(extension_path_, error, true); | 298 |
| 299 if (service_weak_.get()) |
| 300 service_weak_->ReportExtensionLoadError(extension_path_, error); |
| 314 } | 301 } |
| 315 | 302 |
| 316 void UnpackedInstaller::ConfirmInstall() { | 303 void UnpackedInstaller::ConfirmInstall() { |
| 317 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 304 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 318 base::string16 error = installer_.CheckManagementPolicy(); | 305 base::string16 error = installer_.CheckManagementPolicy(); |
| 319 if (!error.empty()) { | 306 if (!error.empty()) { |
| 320 ReportExtensionLoadError(base::UTF16ToUTF8(error)); | 307 ReportExtensionLoadError(base::UTF16ToUTF8(error)); |
| 321 return; | 308 return; |
| 322 } | 309 } |
| 323 | 310 |
| 324 PermissionsUpdater perms_updater(service_weak_->profile()); | 311 PermissionsUpdater perms_updater(service_weak_->profile()); |
| 325 perms_updater.GrantActivePermissions(installer_.extension().get()); | 312 perms_updater.GrantActivePermissions(installer_.extension().get()); |
| 326 | 313 |
| 327 service_weak_->OnExtensionInstalled( | 314 service_weak_->OnExtensionInstalled( |
| 328 installer_.extension().get(), | 315 installer_.extension().get(), |
| 329 syncer::StringOrdinal(), | 316 syncer::StringOrdinal(), |
| 330 false /* no requirement errors */, | 317 false /* no requirement errors */, |
| 331 NOT_BLACKLISTED, | 318 NOT_BLACKLISTED, |
| 332 false /* don't wait for idle */); | 319 false /* don't wait for idle */); |
| 333 } | 320 } |
| 334 | 321 |
| 335 } // namespace extensions | 322 } // namespace extensions |
| OLD | NEW |