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 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
107 ExtensionService* extension_service) { | 107 ExtensionService* extension_service) { |
108 DCHECK(extension_service); | 108 DCHECK(extension_service); |
109 return scoped_refptr<UnpackedInstaller>( | 109 return scoped_refptr<UnpackedInstaller>( |
110 new UnpackedInstaller(extension_service)); | 110 new UnpackedInstaller(extension_service)); |
111 } | 111 } |
112 | 112 |
113 UnpackedInstaller::UnpackedInstaller(ExtensionService* extension_service) | 113 UnpackedInstaller::UnpackedInstaller(ExtensionService* extension_service) |
114 : service_weak_(extension_service->AsWeakPtr()), | 114 : service_weak_(extension_service->AsWeakPtr()), |
115 prompt_for_plugins_(true), | 115 prompt_for_plugins_(true), |
116 require_modern_manifest_version_(true), | 116 require_modern_manifest_version_(true), |
117 be_noisy_on_failure_(true), | 117 be_noisy_on_failure_(false), |
118 installer_(extension_service->profile()) { | 118 installer_(extension_service->profile()) { |
119 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 119 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
120 } | 120 } |
121 | 121 |
122 UnpackedInstaller::~UnpackedInstaller() { | 122 UnpackedInstaller::~UnpackedInstaller() { |
123 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI) || | 123 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI) || |
124 BrowserThread::CurrentlyOn(BrowserThread::FILE)); | 124 BrowserThread::CurrentlyOn(BrowserThread::FILE)); |
125 } | 125 } |
126 | 126 |
127 void UnpackedInstaller::Load(const base::FilePath& path_in) { | 127 void UnpackedInstaller::Load(const base::FilePath& path_in) { |
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
289 } | 289 } |
290 | 290 |
291 BrowserThread::PostTask( | 291 BrowserThread::PostTask( |
292 BrowserThread::UI, | 292 BrowserThread::UI, |
293 FROM_HERE, | 293 FROM_HERE, |
294 base::Bind(&UnpackedInstaller::ShowInstallPrompt, this)); | 294 base::Bind(&UnpackedInstaller::ShowInstallPrompt, this)); |
295 } | 295 } |
296 | 296 |
297 void UnpackedInstaller::ReportExtensionLoadError(const std::string &error) { | 297 void UnpackedInstaller::ReportExtensionLoadError(const std::string &error) { |
298 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 298 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
299 if (!on_failure_callback_.is_null()) | |
300 on_failure_callback_.Run(extension_path_, error); | |
301 | 299 |
302 if (service_weak_.get()) { | 300 if (service_weak_.get()) { |
303 ExtensionErrorReporter::GetInstance()->ReportLoadError( | 301 ExtensionErrorReporter::GetInstance()->ReportLoadError( |
304 extension_path_, | 302 extension_path_, |
305 error, | 303 error, |
306 service_weak_->profile(), | 304 service_weak_->profile(), |
307 be_noisy_on_failure_); | 305 be_noisy_on_failure_); |
308 } | 306 } |
309 } | 307 } |
310 | 308 |
311 void UnpackedInstaller::ConfirmInstall() { | 309 void UnpackedInstaller::ConfirmInstall() { |
312 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 310 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
313 base::string16 error = installer_.CheckManagementPolicy(); | 311 base::string16 error = installer_.CheckManagementPolicy(); |
314 if (!error.empty()) { | 312 if (!error.empty()) { |
315 ReportExtensionLoadError(base::UTF16ToUTF8(error)); | 313 ReportExtensionLoadError(base::UTF16ToUTF8(error)); |
316 return; | 314 return; |
317 } | 315 } |
318 | 316 |
319 PermissionsUpdater perms_updater(service_weak_->profile()); | 317 PermissionsUpdater perms_updater(service_weak_->profile()); |
320 perms_updater.GrantActivePermissions(installer_.extension().get()); | 318 perms_updater.GrantActivePermissions(installer_.extension().get()); |
321 | 319 |
322 service_weak_->OnExtensionInstalled(installer_.extension().get(), | 320 service_weak_->OnExtensionInstalled(installer_.extension().get(), |
323 syncer::StringOrdinal(), | 321 syncer::StringOrdinal(), |
324 kInstallFlagInstallImmediately); | 322 kInstallFlagInstallImmediately); |
325 } | 323 } |
326 | 324 |
327 } // namespace extensions | 325 } // namespace extensions |
OLD | NEW |