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 1870 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1881 details.already_disabled = true; | 1881 details.already_disabled = true; |
1882 disabled_extensions_.Remove(extension->id()); | 1882 disabled_extensions_.Remove(extension->id()); |
1883 content::NotificationService::current()->Notify( | 1883 content::NotificationService::current()->Notify( |
1884 chrome::NOTIFICATION_EXTENSION_UNLOADED, | 1884 chrome::NOTIFICATION_EXTENSION_UNLOADED, |
1885 content::Source<Profile>(profile_), | 1885 content::Source<Profile>(profile_), |
1886 content::Details<UnloadedExtensionInfo>(&details)); | 1886 content::Details<UnloadedExtensionInfo>(&details)); |
1887 // Make sure the profile cleans up its RequestContexts when an already | 1887 // Make sure the profile cleans up its RequestContexts when an already |
1888 // disabled extension is unloaded (since they are also tracking the disabled | 1888 // disabled extension is unloaded (since they are also tracking the disabled |
1889 // extensions). | 1889 // extensions). |
1890 system_->UnregisterExtensionWithRequestContexts(extension_id, reason); | 1890 system_->UnregisterExtensionWithRequestContexts(extension_id, reason); |
1891 return; | 1891 } else { |
| 1892 // Remove the extension from our list. |
| 1893 extensions_.Remove(extension->id()); |
| 1894 NotifyExtensionUnloaded(extension.get(), reason); |
1892 } | 1895 } |
1893 | 1896 |
1894 // Remove the extension from our list. | 1897 content::NotificationService::current()->Notify( |
1895 extensions_.Remove(extension->id()); | 1898 chrome::NOTIFICATION_EXTENSION_REMOVED, |
1896 | 1899 content::Source<Profile>(profile_), |
1897 NotifyExtensionUnloaded(extension.get(), reason); | 1900 content::Details<const Extension>(extension.get())); |
1898 } | 1901 } |
1899 | 1902 |
1900 void ExtensionService::UnloadAllExtensions() { | 1903 void ExtensionService::UnloadAllExtensions() { |
1901 profile_->GetExtensionSpecialStoragePolicy()->RevokeRightsForAllExtensions(); | 1904 profile_->GetExtensionSpecialStoragePolicy()->RevokeRightsForAllExtensions(); |
1902 | 1905 |
1903 extensions_.Clear(); | 1906 extensions_.Clear(); |
1904 disabled_extensions_.Clear(); | 1907 disabled_extensions_.Clear(); |
1905 terminated_extensions_.Clear(); | 1908 terminated_extensions_.Clear(); |
1906 extension_runtime_data_.clear(); | 1909 extension_runtime_data_.clear(); |
1907 | 1910 |
(...skipping 684 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2592 | 2595 |
2593 void ExtensionService::TrackTerminatedExtension(const Extension* extension) { | 2596 void ExtensionService::TrackTerminatedExtension(const Extension* extension) { |
2594 if (!terminated_extensions_.Contains(extension->id())) | 2597 if (!terminated_extensions_.Contains(extension->id())) |
2595 terminated_extensions_.Insert(make_scoped_refptr(extension)); | 2598 terminated_extensions_.Insert(make_scoped_refptr(extension)); |
2596 | 2599 |
2597 UnloadExtension(extension->id(), extension_misc::UNLOAD_REASON_TERMINATE); | 2600 UnloadExtension(extension->id(), extension_misc::UNLOAD_REASON_TERMINATE); |
2598 } | 2601 } |
2599 | 2602 |
2600 void ExtensionService::UntrackTerminatedExtension(const std::string& id) { | 2603 void ExtensionService::UntrackTerminatedExtension(const std::string& id) { |
2601 std::string lowercase_id = StringToLowerASCII(id); | 2604 std::string lowercase_id = StringToLowerASCII(id); |
| 2605 const Extension* extension = terminated_extensions_.GetByID(lowercase_id); |
2602 terminated_extensions_.Remove(lowercase_id); | 2606 terminated_extensions_.Remove(lowercase_id); |
| 2607 if (extension) { |
| 2608 content::NotificationService::current()->Notify( |
| 2609 chrome::NOTIFICATION_EXTENSION_REMOVED, |
| 2610 content::Source<Profile>(profile_), |
| 2611 content::Details<const Extension>(extension)); |
| 2612 } |
2603 } | 2613 } |
2604 | 2614 |
2605 const Extension* ExtensionService::GetTerminatedExtension( | 2615 const Extension* ExtensionService::GetTerminatedExtension( |
2606 const std::string& id) const { | 2616 const std::string& id) const { |
2607 return GetExtensionById(id, INCLUDE_TERMINATED); | 2617 return GetExtensionById(id, INCLUDE_TERMINATED); |
2608 } | 2618 } |
2609 | 2619 |
2610 const Extension* ExtensionService::GetInstalledExtension( | 2620 const Extension* ExtensionService::GetInstalledExtension( |
2611 const std::string& id) const { | 2621 const std::string& id) const { |
2612 int include_mask = INCLUDE_ENABLED | | 2622 int include_mask = INCLUDE_ENABLED | |
(...skipping 498 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3111 } | 3121 } |
3112 | 3122 |
3113 void ExtensionService::AddUpdateObserver(extensions::UpdateObserver* observer) { | 3123 void ExtensionService::AddUpdateObserver(extensions::UpdateObserver* observer) { |
3114 update_observers_.AddObserver(observer); | 3124 update_observers_.AddObserver(observer); |
3115 } | 3125 } |
3116 | 3126 |
3117 void ExtensionService::RemoveUpdateObserver( | 3127 void ExtensionService::RemoveUpdateObserver( |
3118 extensions::UpdateObserver* observer) { | 3128 extensions::UpdateObserver* observer) { |
3119 update_observers_.RemoveObserver(observer); | 3129 update_observers_.RemoveObserver(observer); |
3120 } | 3130 } |
OLD | NEW |