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/extension_service.h" | 5 #include "chrome/browser/extensions/extension_service.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <iterator> | 8 #include <iterator> |
9 #include <set> | 9 #include <set> |
10 | 10 |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
134 // For example, an extension that requires experimental permissions | 134 // For example, an extension that requires experimental permissions |
135 // will not be loaded if the experimental command line flag is not used. | 135 // will not be loaded if the experimental command line flag is not used. |
136 // In this case, do not uninstall. | 136 // In this case, do not uninstall. |
137 if (!GetInstalledExtension(id)) { | 137 if (!GetInstalledExtension(id)) { |
138 // We can't call UninstallExtension with an unloaded/invalid | 138 // We can't call UninstallExtension with an unloaded/invalid |
139 // extension ID. | 139 // extension ID. |
140 LOG(WARNING) << "Attempted uninstallation of unloaded/invalid extension " | 140 LOG(WARNING) << "Attempted uninstallation of unloaded/invalid extension " |
141 << "with id: " << id; | 141 << "with id: " << id; |
142 return; | 142 return; |
143 } | 143 } |
144 UninstallExtension( | 144 UninstallExtension(id, |
145 id, extensions::UNINSTALL_REASON_ORPHANED_EXTERNAL_EXTENSION, NULL); | 145 extensions::UNINSTALL_REASON_ORPHANED_EXTERNAL_EXTENSION, |
| 146 base::Bind(&base::DoNothing), |
| 147 NULL); |
146 } | 148 } |
147 | 149 |
148 void ExtensionService::SetFileTaskRunnerForTesting( | 150 void ExtensionService::SetFileTaskRunnerForTesting( |
149 base::SequencedTaskRunner* task_runner) { | 151 base::SequencedTaskRunner* task_runner) { |
150 file_task_runner_ = task_runner; | 152 file_task_runner_ = task_runner; |
151 } | 153 } |
152 | 154 |
153 void ExtensionService::ClearProvidersForTesting() { | 155 void ExtensionService::ClearProvidersForTesting() { |
154 external_extension_providers_.clear(); | 156 external_extension_providers_.clear(); |
155 } | 157 } |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
215 // We can't call UninstallExtension with an invalid extension ID. | 217 // We can't call UninstallExtension with an invalid extension ID. |
216 if (!extensions_service->GetInstalledExtension(extension_id)) { | 218 if (!extensions_service->GetInstalledExtension(extension_id)) { |
217 LOG(WARNING) << "Attempted uninstallation of non-existent extension with " | 219 LOG(WARNING) << "Attempted uninstallation of non-existent extension with " |
218 << "id: " << extension_id; | 220 << "id: " << extension_id; |
219 return false; | 221 return false; |
220 } | 222 } |
221 | 223 |
222 // The following call to UninstallExtension will not allow an uninstall of a | 224 // The following call to UninstallExtension will not allow an uninstall of a |
223 // policy-controlled extension. | 225 // policy-controlled extension. |
224 base::string16 error; | 226 base::string16 error; |
225 if (!extensions_service->UninstallExtension(extension_id, reason, &error)) { | 227 if (!extensions_service->UninstallExtension( |
| 228 extension_id, reason, base::Bind(&base::DoNothing), &error)) { |
226 LOG(WARNING) << "Cannot uninstall extension with id " << extension_id | 229 LOG(WARNING) << "Cannot uninstall extension with id " << extension_id |
227 << ": " << error; | 230 << ": " << error; |
228 return false; | 231 return false; |
229 } | 232 } |
230 | 233 |
231 return true; | 234 return true; |
232 } | 235 } |
233 | 236 |
234 ExtensionService::ExtensionService(Profile* profile, | 237 ExtensionService::ExtensionService(Profile* profile, |
235 const CommandLine* command_line, | 238 const CommandLine* command_line, |
(...skipping 432 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
668 void ExtensionService::ReloadExtensionWithQuietFailure( | 671 void ExtensionService::ReloadExtensionWithQuietFailure( |
669 const std::string& extension_id) { | 672 const std::string& extension_id) { |
670 ReloadExtensionImpl(extension_id, false); // be_noisy | 673 ReloadExtensionImpl(extension_id, false); // be_noisy |
671 } | 674 } |
672 | 675 |
673 bool ExtensionService::UninstallExtension( | 676 bool ExtensionService::UninstallExtension( |
674 // "transient" because the process of uninstalling may cause the reference | 677 // "transient" because the process of uninstalling may cause the reference |
675 // to become invalid. Instead, use |extenson->id()|. | 678 // to become invalid. Instead, use |extenson->id()|. |
676 const std::string& transient_extension_id, | 679 const std::string& transient_extension_id, |
677 extensions::UninstallReason reason, | 680 extensions::UninstallReason reason, |
| 681 const base::Closure& deletion_done_callback, |
678 base::string16* error) { | 682 base::string16* error) { |
679 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 683 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
680 | 684 |
681 scoped_refptr<const Extension> extension = | 685 scoped_refptr<const Extension> extension = |
682 GetInstalledExtension(transient_extension_id); | 686 GetInstalledExtension(transient_extension_id); |
683 | 687 |
684 // Callers should not send us nonexistent extensions. | 688 // Callers should not send us nonexistent extensions. |
685 CHECK(extension.get()); | 689 CHECK(extension.get()); |
686 | 690 |
687 // Policy change which triggers an uninstall will always set | 691 // Policy change which triggers an uninstall will always set |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
731 if (!GetFileTaskRunner()->PostTask( | 735 if (!GetFileTaskRunner()->PostTask( |
732 FROM_HERE, | 736 FROM_HERE, |
733 base::Bind(&ExtensionService::UninstallExtensionOnFileThread, | 737 base::Bind(&ExtensionService::UninstallExtensionOnFileThread, |
734 extension->id(), | 738 extension->id(), |
735 profile_, | 739 profile_, |
736 install_directory_, | 740 install_directory_, |
737 extension->path()))) | 741 extension->path()))) |
738 NOTREACHED(); | 742 NOTREACHED(); |
739 } | 743 } |
740 | 744 |
741 extensions::DataDeleter::StartDeleting(profile_, extension.get()); | 745 extensions::DataDeleter::StartDeleting( |
| 746 profile_, extension.get(), deletion_done_callback); |
742 | 747 |
743 UntrackTerminatedExtension(extension->id()); | 748 UntrackTerminatedExtension(extension->id()); |
744 | 749 |
745 // Notify interested parties that we've uninstalled this extension. | 750 // Notify interested parties that we've uninstalled this extension. |
746 content::NotificationService::current()->Notify( | 751 content::NotificationService::current()->Notify( |
747 chrome::NOTIFICATION_EXTENSION_UNINSTALLED_DEPRECATED, | 752 chrome::NOTIFICATION_EXTENSION_UNINSTALLED_DEPRECATED, |
748 content::Source<Profile>(profile_), | 753 content::Source<Profile>(profile_), |
749 content::Details<const Extension>(extension.get())); | 754 content::Details<const Extension>(extension.get())); |
750 ExtensionRegistry::Get(profile_) | 755 ExtensionRegistry::Get(profile_) |
751 ->TriggerOnUninstalled(extension.get(), reason); | 756 ->TriggerOnUninstalled(extension.get(), reason); |
(...skipping 1575 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2327 } | 2332 } |
2328 | 2333 |
2329 void ExtensionService::OnProfileDestructionStarted() { | 2334 void ExtensionService::OnProfileDestructionStarted() { |
2330 ExtensionIdSet ids_to_unload = registry_->enabled_extensions().GetIDs(); | 2335 ExtensionIdSet ids_to_unload = registry_->enabled_extensions().GetIDs(); |
2331 for (ExtensionIdSet::iterator it = ids_to_unload.begin(); | 2336 for (ExtensionIdSet::iterator it = ids_to_unload.begin(); |
2332 it != ids_to_unload.end(); | 2337 it != ids_to_unload.end(); |
2333 ++it) { | 2338 ++it) { |
2334 UnloadExtension(*it, UnloadedExtensionInfo::REASON_PROFILE_SHUTDOWN); | 2339 UnloadExtension(*it, UnloadedExtensionInfo::REASON_PROFILE_SHUTDOWN); |
2335 } | 2340 } |
2336 } | 2341 } |
OLD | NEW |