| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/crx_installer.h" | 5 #include "chrome/browser/extensions/crx_installer.h" |
| 6 | 6 |
| 7 #include <map> | 7 #include <map> |
| 8 #include <set> | 8 #include <set> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 125 return false; | 125 return false; |
| 126 } | 126 } |
| 127 | 127 |
| 128 CrxInstaller::CrxInstaller(base::WeakPtr<ExtensionService> frontend_weak, | 128 CrxInstaller::CrxInstaller(base::WeakPtr<ExtensionService> frontend_weak, |
| 129 ExtensionInstallUI* client) | 129 ExtensionInstallUI* client) |
| 130 : install_directory_(frontend_weak->install_directory()), | 130 : install_directory_(frontend_weak->install_directory()), |
| 131 install_source_(Extension::INTERNAL), | 131 install_source_(Extension::INTERNAL), |
| 132 extensions_enabled_(frontend_weak->extensions_enabled()), | 132 extensions_enabled_(frontend_weak->extensions_enabled()), |
| 133 delete_source_(false), | 133 delete_source_(false), |
| 134 create_app_shortcut_(false), | 134 create_app_shortcut_(false), |
| 135 page_index_(-1), |
| 135 frontend_weak_(frontend_weak), | 136 frontend_weak_(frontend_weak), |
| 136 profile_(frontend_weak->profile()), | 137 profile_(frontend_weak->profile()), |
| 137 client_(client), | 138 client_(client), |
| 138 apps_require_extension_mime_type_(false), | 139 apps_require_extension_mime_type_(false), |
| 139 allow_silent_install_(false), | 140 allow_silent_install_(false), |
| 140 install_cause_(extension_misc::INSTALL_CAUSE_UNSET), | 141 install_cause_(extension_misc::INSTALL_CAUSE_UNSET), |
| 141 creation_flags_(Extension::NO_FLAGS) { | 142 creation_flags_(Extension::NO_FLAGS) { |
| 142 } | 143 } |
| 143 | 144 |
| 144 CrxInstaller::~CrxInstaller() { | 145 CrxInstaller::~CrxInstaller() { |
| (...skipping 434 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 579 // We update the extension's granted permissions if the user already approved | 580 // We update the extension's granted permissions if the user already approved |
| 580 // the install (client_ is non NULL), or we are allowed to install this | 581 // the install (client_ is non NULL), or we are allowed to install this |
| 581 // silently. We only track granted permissions for INTERNAL extensions. | 582 // silently. We only track granted permissions for INTERNAL extensions. |
| 582 if ((client_ || allow_silent_install_) && | 583 if ((client_ || allow_silent_install_) && |
| 583 extension_->location() == Extension::INTERNAL) | 584 extension_->location() == Extension::INTERNAL) |
| 584 frontend_weak_->GrantPermissions(extension_); | 585 frontend_weak_->GrantPermissions(extension_); |
| 585 | 586 |
| 586 // Tell the frontend about the installation and hand off ownership of | 587 // Tell the frontend about the installation and hand off ownership of |
| 587 // extension_ to it. | 588 // extension_ to it. |
| 588 frontend_weak_->OnExtensionInstalled(extension_, is_gallery_install(), | 589 frontend_weak_->OnExtensionInstalled(extension_, is_gallery_install(), |
| 589 page_ordinal_); | 590 page_index_); |
| 590 | 591 |
| 591 NotifyCrxInstallComplete(extension_.get()); | 592 NotifyCrxInstallComplete(extension_.get()); |
| 592 | 593 |
| 593 extension_ = NULL; | 594 extension_ = NULL; |
| 594 | 595 |
| 595 // We're done. We don't post any more tasks to ourselves so we are deleted | 596 // We're done. We don't post any more tasks to ourselves so we are deleted |
| 596 // soon. | 597 // soon. |
| 597 } | 598 } |
| 598 | 599 |
| 599 void CrxInstaller::NotifyCrxInstallComplete(const Extension* extension) { | 600 void CrxInstaller::NotifyCrxInstallComplete(const Extension* extension) { |
| 600 // Some users (such as the download shelf) need to know when a | 601 // Some users (such as the download shelf) need to know when a |
| 601 // CRXInstaller is done. Listening for the EXTENSION_* events | 602 // CRXInstaller is done. Listening for the EXTENSION_* events |
| 602 // is problematic because they don't know anything about the | 603 // is problematic because they don't know anything about the |
| 603 // extension before it is unpacked, so they cannot filter based | 604 // extension before it is unpacked, so they cannot filter based |
| 604 // on the extension. | 605 // on the extension. |
| 605 content::NotificationService::current()->Notify( | 606 content::NotificationService::current()->Notify( |
| 606 chrome::NOTIFICATION_CRX_INSTALLER_DONE, | 607 chrome::NOTIFICATION_CRX_INSTALLER_DONE, |
| 607 content::Source<CrxInstaller>(this), | 608 content::Source<CrxInstaller>(this), |
| 608 content::Details<const Extension>(extension)); | 609 content::Details<const Extension>(extension)); |
| 609 } | 610 } |
| OLD | NEW |