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/extension_service.h" | 5 #include "chrome/browser/extensions/extension_service.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <set> | 8 #include <set> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 888 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
899 } | 899 } |
900 return false; | 900 return false; |
901 } | 901 } |
902 | 902 |
903 // Extract the data we need for sync now, but don't actually sync until we've | 903 // Extract the data we need for sync now, but don't actually sync until we've |
904 // completed the uninstallation. | 904 // completed the uninstallation. |
905 SyncBundle* sync_bundle = GetSyncBundleForExtension(*extension); | 905 SyncBundle* sync_bundle = GetSyncBundleForExtension(*extension); |
906 | 906 |
907 SyncChange sync_change; | 907 SyncChange sync_change; |
908 if (sync_bundle) { | 908 if (sync_bundle) { |
909 ExtensionSyncData extension_sync_data(*extension, | 909 ExtensionSyncData extension_sync_data( |
910 IsExtensionEnabled(extension_id), | 910 *extension, |
911 IsIncognitoEnabled(extension_id)); | 911 IsExtensionEnabled(extension_id), |
912 IsIncognitoEnabled(extension_id), | |
913 IsNotificationsInitialSetupDone(extension_id), | |
914 IsNotificationsDisabled(extension_id)); | |
912 sync_change = extension_sync_data.GetSyncChange(SyncChange::ACTION_DELETE); | 915 sync_change = extension_sync_data.GetSyncChange(SyncChange::ACTION_DELETE); |
913 } | 916 } |
914 | 917 |
915 UMA_HISTOGRAM_ENUMERATION("Extensions.UninstallType", | 918 UMA_HISTOGRAM_ENUMERATION("Extensions.UninstallType", |
916 extension->GetType(), 100); | 919 extension->GetType(), 100); |
917 RecordPermissionMessagesHistogram( | 920 RecordPermissionMessagesHistogram( |
918 extension, "Extensions.Permissions_Uninstall"); | 921 extension, "Extensions.Permissions_Uninstall"); |
919 | 922 |
920 TemplateURLService* url_service = | 923 TemplateURLService* url_service = |
921 TemplateURLServiceFactory::GetForProfile(profile_); | 924 TemplateURLServiceFactory::GetForProfile(profile_); |
(...skipping 818 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1740 } | 1743 } |
1741 | 1744 |
1742 bool ExtensionService::SyncBundle::HasPendingExtensionId(const std::string& id) | 1745 bool ExtensionService::SyncBundle::HasPendingExtensionId(const std::string& id) |
1743 const { | 1746 const { |
1744 return pending_sync_data.find(id) != pending_sync_data.end(); | 1747 return pending_sync_data.find(id) != pending_sync_data.end(); |
1745 } | 1748 } |
1746 | 1749 |
1747 void ExtensionService::SyncExtensionChangeIfNeeded(const Extension& extension) { | 1750 void ExtensionService::SyncExtensionChangeIfNeeded(const Extension& extension) { |
1748 SyncBundle* sync_bundle = GetSyncBundleForExtension(extension); | 1751 SyncBundle* sync_bundle = GetSyncBundleForExtension(extension); |
1749 if (sync_bundle) { | 1752 if (sync_bundle) { |
1750 ExtensionSyncData extension_sync_data(extension, | 1753 ExtensionSyncData extension_sync_data( |
1751 IsExtensionEnabled(extension.id()), | 1754 extension, |
1752 IsIncognitoEnabled(extension.id())); | 1755 IsExtensionEnabled(extension.id()), |
1756 IsIncognitoEnabled(extension.id()), | |
1757 IsNotificationsInitialSetupDone(extension.id()), | |
1758 IsNotificationsDisabled(extension.id())); | |
1753 | 1759 |
1754 SyncChangeList sync_change_list(1, extension_sync_data.GetSyncChange( | 1760 SyncChangeList sync_change_list(1, extension_sync_data.GetSyncChange( |
1755 sync_bundle->HasExtensionId(extension.id()) ? | 1761 sync_bundle->HasExtensionId(extension.id()) ? |
1756 SyncChange::ACTION_UPDATE : SyncChange::ACTION_ADD)); | 1762 SyncChange::ACTION_UPDATE : SyncChange::ACTION_ADD)); |
1757 sync_bundle->sync_processor->ProcessSyncChanges( | 1763 sync_bundle->sync_processor->ProcessSyncChanges( |
1758 FROM_HERE, sync_change_list); | 1764 FROM_HERE, sync_change_list); |
1759 sync_bundle->synced_extensions.insert(extension.id()); | 1765 sync_bundle->synced_extensions.insert(extension.id()); |
1760 sync_bundle->pending_sync_data.erase(extension.id()); | 1766 sync_bundle->pending_sync_data.erase(extension.id()); |
1761 } | 1767 } |
1762 } | 1768 } |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1905 it != extensions.end(); ++it) { | 1911 it != extensions.end(); ++it) { |
1906 const Extension& extension = **it; | 1912 const Extension& extension = **it; |
1907 if (bundle.filter(extension) && | 1913 if (bundle.filter(extension) && |
1908 // If we have pending extension data for this extension, then this | 1914 // If we have pending extension data for this extension, then this |
1909 // version is out of date. We'll sync back the version we got from | 1915 // version is out of date. We'll sync back the version we got from |
1910 // sync. | 1916 // sync. |
1911 !bundle.HasPendingExtensionId(extension.id())) { | 1917 !bundle.HasPendingExtensionId(extension.id())) { |
1912 sync_data_list->push_back( | 1918 sync_data_list->push_back( |
1913 ExtensionSyncData(extension, | 1919 ExtensionSyncData(extension, |
1914 IsExtensionEnabled(extension.id()), | 1920 IsExtensionEnabled(extension.id()), |
1915 IsIncognitoEnabled(extension.id()))); | 1921 IsIncognitoEnabled(extension.id()), |
1922 IsNotificationsInitialSetupDone(extension.id()), | |
1923 IsNotificationsDisabled(extension.id()))); | |
1916 } | 1924 } |
1917 } | 1925 } |
1918 } | 1926 } |
1919 | 1927 |
1920 std::vector<ExtensionSyncData> ExtensionService::GetSyncDataList( | 1928 std::vector<ExtensionSyncData> ExtensionService::GetSyncDataList( |
1921 const SyncBundle& bundle) const { | 1929 const SyncBundle& bundle) const { |
1922 std::vector<ExtensionSyncData> extension_sync_list; | 1930 std::vector<ExtensionSyncData> extension_sync_list; |
1923 GetSyncDataListHelper(extensions_, bundle, &extension_sync_list); | 1931 GetSyncDataListHelper(extensions_, bundle, &extension_sync_list); |
1924 GetSyncDataListHelper(disabled_extensions_, bundle, &extension_sync_list); | 1932 GetSyncDataListHelper(disabled_extensions_, bundle, &extension_sync_list); |
1925 GetSyncDataListHelper(terminated_extensions_, bundle, &extension_sync_list); | 1933 GetSyncDataListHelper(terminated_extensions_, bundle, &extension_sync_list); |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2029 if (enabled_extension) { | 2037 if (enabled_extension) { |
2030 NotifyExtensionUnloaded( | 2038 NotifyExtensionUnloaded( |
2031 enabled_extension, extension_misc::UNLOAD_REASON_DISABLE); | 2039 enabled_extension, extension_misc::UNLOAD_REASON_DISABLE); |
2032 NotifyExtensionLoaded(enabled_extension); | 2040 NotifyExtensionLoaded(enabled_extension); |
2033 } | 2041 } |
2034 | 2042 |
2035 if (extension) | 2043 if (extension) |
2036 SyncExtensionChangeIfNeeded(*extension); | 2044 SyncExtensionChangeIfNeeded(*extension); |
2037 } | 2045 } |
2038 | 2046 |
2047 bool ExtensionService::IsNotificationsInitialSetupDone( | |
2048 const std::string& extension_id) const { | |
2049 return extension_prefs_->IsNotificationsInitialSetupDone(extension_id); | |
2050 } | |
2051 | |
2052 void ExtensionService::SetNotificationsInitialSetupDone( | |
2053 const std::string& extension_id, | |
2054 bool value) { | |
2055 extension_prefs_->SetNotificationsInitialSetupDone(extension_id, value); | |
asargent_no_longer_on_chrome
2011/10/27 16:52:21
nit: probably not worth writing this into the pref
Munjal (Google)
2011/10/27 18:35:05
Done.
I have one question though - is it possible
asargent_no_longer_on_chrome
2011/10/27 19:49:41
A race condition is unlikely to happen - the way t
Munjal (Google)
2011/10/27 20:01:50
Great, good to know.
| |
2056 const Extension* extension = GetInstalledExtension(extension_id); | |
2057 if (extension) | |
2058 SyncExtensionChangeIfNeeded(*extension); | |
2059 } | |
2060 | |
2061 bool ExtensionService::IsNotificationsDisabled( | |
2062 const std::string& extension_id) const { | |
2063 return extension_prefs_->IsNotificationsDisabled(extension_id); | |
2064 } | |
2065 | |
2066 void ExtensionService::SetNotificationsDisabled( | |
2067 const std::string& extension_id, | |
2068 bool value) { | |
2069 extension_prefs_->SetNotificationsDisabled(extension_id, value); | |
2070 const Extension* extension = GetInstalledExtension(extension_id); | |
2071 if (extension) | |
asargent_no_longer_on_chrome
2011/10/27 16:52:21
same thing here about bailing out if the extension
Munjal (Google)
2011/10/27 18:35:05
Done.
| |
2072 SyncExtensionChangeIfNeeded(*extension); | |
2073 } | |
2074 | |
2039 bool ExtensionService::CanCrossIncognito(const Extension* extension) { | 2075 bool ExtensionService::CanCrossIncognito(const Extension* extension) { |
2040 // We allow the extension to see events and data from another profile iff it | 2076 // We allow the extension to see events and data from another profile iff it |
2041 // uses "spanning" behavior and it has incognito access. "split" mode | 2077 // uses "spanning" behavior and it has incognito access. "split" mode |
2042 // extensions only see events for a matching profile. | 2078 // extensions only see events for a matching profile. |
2043 CHECK(extension); | 2079 CHECK(extension); |
2044 return IsIncognitoEnabled(extension->id()) && | 2080 return IsIncognitoEnabled(extension->id()) && |
2045 !extension->incognito_split_mode(); | 2081 !extension->incognito_split_mode(); |
2046 } | 2082 } |
2047 | 2083 |
2048 bool ExtensionService::CanLoadInIncognito(const Extension* extension) const { | 2084 bool ExtensionService::CanLoadInIncognito(const Extension* extension) const { |
(...skipping 977 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3026 | 3062 |
3027 ExtensionService::NaClModuleInfoList::iterator | 3063 ExtensionService::NaClModuleInfoList::iterator |
3028 ExtensionService::FindNaClModule(const GURL& url) { | 3064 ExtensionService::FindNaClModule(const GURL& url) { |
3029 for (NaClModuleInfoList::iterator iter = nacl_module_list_.begin(); | 3065 for (NaClModuleInfoList::iterator iter = nacl_module_list_.begin(); |
3030 iter != nacl_module_list_.end(); ++iter) { | 3066 iter != nacl_module_list_.end(); ++iter) { |
3031 if (iter->url == url) | 3067 if (iter->url == url) |
3032 return iter; | 3068 return iter; |
3033 } | 3069 } |
3034 return nacl_module_list_.end(); | 3070 return nacl_module_list_.end(); |
3035 } | 3071 } |
OLD | NEW |