| 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 |
| 11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
| 12 #include "base/bind.h" | 12 #include "base/bind.h" |
| 13 #include "base/callback.h" | 13 #include "base/callback.h" |
| 14 #include "base/command_line.h" | 14 #include "base/command_line.h" |
| 15 #include "base/file_util.h" | 15 #include "base/file_util.h" |
| 16 #include "base/logging.h" | 16 #include "base/logging.h" |
| 17 #include "base/metrics/histogram.h" | 17 #include "base/metrics/histogram.h" |
| 18 #include "base/path_service.h" | |
| 19 #include "base/prefs/pref_service.h" | 18 #include "base/prefs/pref_service.h" |
| 20 #include "base/stl_util.h" | 19 #include "base/stl_util.h" |
| 21 #include "base/string_util.h" | 20 #include "base/string_util.h" |
| 22 #include "base/stringprintf.h" | 21 #include "base/stringprintf.h" |
| 23 #include "base/strings/string_number_conversions.h" | 22 #include "base/strings/string_number_conversions.h" |
| 24 #include "base/threading/sequenced_worker_pool.h" | 23 #include "base/threading/sequenced_worker_pool.h" |
| 25 #include "base/threading/thread_restrictions.h" | 24 #include "base/threading/thread_restrictions.h" |
| 26 #include "base/time.h" | 25 #include "base/time.h" |
| 27 #include "base/utf_string_conversions.h" | 26 #include "base/utf_string_conversions.h" |
| 28 #include "base/values.h" | 27 #include "base/values.h" |
| (...skipping 28 matching lines...) Expand all Loading... |
| 57 #include "chrome/browser/extensions/installed_loader.h" | 56 #include "chrome/browser/extensions/installed_loader.h" |
| 58 #include "chrome/browser/extensions/lazy_background_task_queue.h" | 57 #include "chrome/browser/extensions/lazy_background_task_queue.h" |
| 59 #include "chrome/browser/extensions/management_policy.h" | 58 #include "chrome/browser/extensions/management_policy.h" |
| 60 #include "chrome/browser/extensions/pending_extension_manager.h" | 59 #include "chrome/browser/extensions/pending_extension_manager.h" |
| 61 #include "chrome/browser/extensions/permissions_updater.h" | 60 #include "chrome/browser/extensions/permissions_updater.h" |
| 62 #include "chrome/browser/extensions/platform_app_launcher.h" | 61 #include "chrome/browser/extensions/platform_app_launcher.h" |
| 63 #include "chrome/browser/extensions/shell_window_registry.h" | 62 #include "chrome/browser/extensions/shell_window_registry.h" |
| 64 #include "chrome/browser/extensions/unpacked_installer.h" | 63 #include "chrome/browser/extensions/unpacked_installer.h" |
| 65 #include "chrome/browser/extensions/update_observer.h" | 64 #include "chrome/browser/extensions/update_observer.h" |
| 66 #include "chrome/browser/extensions/updater/extension_updater.h" | 65 #include "chrome/browser/extensions/updater/extension_updater.h" |
| 67 #include "chrome/browser/plugins/chrome_plugin_service_filter.h" | |
| 68 #include "chrome/browser/profiles/profile.h" | 66 #include "chrome/browser/profiles/profile.h" |
| 69 #include "chrome/browser/profiles/profile_manager.h" | 67 #include "chrome/browser/profiles/profile_manager.h" |
| 70 #include "chrome/browser/themes/theme_service.h" | 68 #include "chrome/browser/themes/theme_service.h" |
| 71 #include "chrome/browser/themes/theme_service_factory.h" | 69 #include "chrome/browser/themes/theme_service_factory.h" |
| 72 #include "chrome/browser/ui/webui/favicon_source.h" | 70 #include "chrome/browser/ui/webui/favicon_source.h" |
| 73 #include "chrome/browser/ui/webui/ntp/thumbnail_source.h" | 71 #include "chrome/browser/ui/webui/ntp/thumbnail_source.h" |
| 74 #include "chrome/browser/ui/webui/theme_source.h" | 72 #include "chrome/browser/ui/webui/theme_source.h" |
| 75 #include "chrome/common/child_process_logging.h" | 73 #include "chrome/common/child_process_logging.h" |
| 76 #include "chrome/common/chrome_notification_types.h" | 74 #include "chrome/common/chrome_notification_types.h" |
| 77 #include "chrome/common/chrome_paths.h" | |
| 78 #include "chrome/common/chrome_switches.h" | 75 #include "chrome/common/chrome_switches.h" |
| 79 #include "chrome/common/chrome_version_info.h" | 76 #include "chrome/common/chrome_version_info.h" |
| 80 #include "chrome/common/extensions/api/plugins/plugins_handler.h" | |
| 81 #include "chrome/common/extensions/background_info.h" | 77 #include "chrome/common/extensions/background_info.h" |
| 82 #include "chrome/common/extensions/extension.h" | 78 #include "chrome/common/extensions/extension.h" |
| 83 #include "chrome/common/extensions/extension_file_util.h" | 79 #include "chrome/common/extensions/extension_file_util.h" |
| 84 #include "chrome/common/extensions/extension_manifest_constants.h" | 80 #include "chrome/common/extensions/extension_manifest_constants.h" |
| 85 #include "chrome/common/extensions/extension_messages.h" | 81 #include "chrome/common/extensions/extension_messages.h" |
| 86 #include "chrome/common/extensions/feature_switch.h" | 82 #include "chrome/common/extensions/feature_switch.h" |
| 87 #include "chrome/common/extensions/features/feature.h" | 83 #include "chrome/common/extensions/features/feature.h" |
| 88 #include "chrome/common/extensions/incognito_handler.h" | 84 #include "chrome/common/extensions/incognito_handler.h" |
| 89 #include "chrome/common/extensions/manifest.h" | 85 #include "chrome/common/extensions/manifest.h" |
| 90 #include "chrome/common/extensions/manifest_handlers/app_isolation_info.h" | 86 #include "chrome/common/extensions/manifest_handlers/app_isolation_info.h" |
| 91 #include "chrome/common/extensions/manifest_url_handler.h" | 87 #include "chrome/common/extensions/manifest_url_handler.h" |
| 92 #include "chrome/common/extensions/permissions/permissions_data.h" | 88 #include "chrome/common/extensions/permissions/permissions_data.h" |
| 93 #include "chrome/common/pref_names.h" | 89 #include "chrome/common/pref_names.h" |
| 94 #include "chrome/common/startup_metric_utils.h" | 90 #include "chrome/common/startup_metric_utils.h" |
| 95 #include "chrome/common/url_constants.h" | 91 #include "chrome/common/url_constants.h" |
| 96 #include "content/public/browser/browser_thread.h" | 92 #include "content/public/browser/browser_thread.h" |
| 97 #include "content/public/browser/devtools_agent_host.h" | 93 #include "content/public/browser/devtools_agent_host.h" |
| 98 #include "content/public/browser/notification_service.h" | 94 #include "content/public/browser/notification_service.h" |
| 99 #include "content/public/browser/notification_types.h" | 95 #include "content/public/browser/notification_types.h" |
| 100 #include "content/public/browser/plugin_service.h" | |
| 101 #include "content/public/browser/render_process_host.h" | 96 #include "content/public/browser/render_process_host.h" |
| 102 #include "content/public/browser/site_instance.h" | 97 #include "content/public/browser/site_instance.h" |
| 103 #include "content/public/browser/storage_partition.h" | 98 #include "content/public/browser/storage_partition.h" |
| 104 #include "content/public/browser/url_data_source.h" | 99 #include "content/public/browser/url_data_source.h" |
| 105 #include "content/public/common/pepper_plugin_info.h" | |
| 106 #include "extensions/common/constants.h" | 100 #include "extensions/common/constants.h" |
| 107 #include "extensions/common/error_utils.h" | 101 #include "extensions/common/error_utils.h" |
| 108 #include "googleurl/src/gurl.h" | 102 #include "googleurl/src/gurl.h" |
| 109 #include "grit/generated_resources.h" | 103 #include "grit/generated_resources.h" |
| 110 #include "net/base/registry_controlled_domains/registry_controlled_domain.h" | 104 #include "net/base/registry_controlled_domains/registry_controlled_domain.h" |
| 111 #include "sync/api/sync_change.h" | 105 #include "sync/api/sync_change.h" |
| 112 #include "sync/api/sync_error_factory.h" | 106 #include "sync/api/sync_error_factory.h" |
| 113 #include "webkit/browser/database/database_tracker.h" | 107 #include "webkit/browser/database/database_tracker.h" |
| 114 #include "webkit/browser/database/database_util.h" | 108 #include "webkit/browser/database/database_util.h" |
| 115 | 109 |
| 116 #if defined(OS_CHROMEOS) | 110 #if defined(OS_CHROMEOS) |
| 117 #include "chrome/browser/chromeos/extensions/install_limiter.h" | 111 #include "chrome/browser/chromeos/extensions/install_limiter.h" |
| 118 #include "webkit/browser/fileapi/file_system_context.h" | 112 #include "webkit/browser/fileapi/file_system_context.h" |
| 119 #include "webkit/browser/fileapi/file_system_mount_point_provider.h" | 113 #include "webkit/browser/fileapi/file_system_mount_point_provider.h" |
| 120 #endif | 114 #endif |
| 121 | 115 |
| 122 using content::BrowserContext; | 116 using content::BrowserContext; |
| 123 using content::BrowserThread; | 117 using content::BrowserThread; |
| 124 using content::DevToolsAgentHost; | 118 using content::DevToolsAgentHost; |
| 125 using content::PluginService; | |
| 126 using extensions::CrxInstaller; | 119 using extensions::CrxInstaller; |
| 127 using extensions::Extension; | 120 using extensions::Extension; |
| 128 using extensions::ExtensionIdSet; | 121 using extensions::ExtensionIdSet; |
| 129 using extensions::ExtensionInfo; | 122 using extensions::ExtensionInfo; |
| 130 using extensions::FeatureSwitch; | 123 using extensions::FeatureSwitch; |
| 131 using extensions::Manifest; | 124 using extensions::Manifest; |
| 132 using extensions::PermissionMessage; | 125 using extensions::PermissionMessage; |
| 133 using extensions::PermissionMessages; | 126 using extensions::PermissionMessages; |
| 134 using extensions::PermissionSet; | 127 using extensions::PermissionSet; |
| 135 using extensions::UnloadedExtensionInfo; | 128 using extensions::UnloadedExtensionInfo; |
| (...skipping 14 matching lines...) Expand all Loading... |
| 150 | 143 |
| 151 // Prompt the user this many times before considering an extension acknowledged. | 144 // Prompt the user this many times before considering an extension acknowledged. |
| 152 static const int kMaxExtensionAcknowledgePromptCount = 3; | 145 static const int kMaxExtensionAcknowledgePromptCount = 3; |
| 153 | 146 |
| 154 // Wait this many seconds after an extensions becomes idle before updating it. | 147 // Wait this many seconds after an extensions becomes idle before updating it. |
| 155 static const int kUpdateIdleDelay = 5; | 148 static const int kUpdateIdleDelay = 5; |
| 156 | 149 |
| 157 // Wait this many seconds before trying to garbage collect extensions again. | 150 // Wait this many seconds before trying to garbage collect extensions again. |
| 158 static const int kGarbageCollectRetryDelay = 30; | 151 static const int kGarbageCollectRetryDelay = 30; |
| 159 | 152 |
| 160 const char* kNaClPluginMimeType = "application/x-nacl"; | |
| 161 | |
| 162 static bool IsSyncableExtension(const Extension& extension) { | 153 static bool IsSyncableExtension(const Extension& extension) { |
| 163 return extension.GetSyncType() == Extension::SYNC_TYPE_EXTENSION; | 154 return extension.GetSyncType() == Extension::SYNC_TYPE_EXTENSION; |
| 164 } | 155 } |
| 165 | 156 |
| 166 static bool IsSyncableApp(const Extension& extension) { | 157 static bool IsSyncableApp(const Extension& extension) { |
| 167 return extension.GetSyncType() == Extension::SYNC_TYPE_APP; | 158 return extension.GetSyncType() == Extension::SYNC_TYPE_APP; |
| 168 } | 159 } |
| 169 | 160 |
| 170 } // namespace | 161 } // namespace |
| 171 | 162 |
| 172 ExtensionService::ExtensionRuntimeData::ExtensionRuntimeData() | 163 ExtensionService::ExtensionRuntimeData::ExtensionRuntimeData() |
| 173 : background_page_ready(false), | 164 : background_page_ready(false), |
| 174 being_upgraded(false), | 165 being_upgraded(false), |
| 175 has_used_webrequest(false) { | 166 has_used_webrequest(false) { |
| 176 } | 167 } |
| 177 | 168 |
| 178 ExtensionService::ExtensionRuntimeData::~ExtensionRuntimeData() { | 169 ExtensionService::ExtensionRuntimeData::~ExtensionRuntimeData() { |
| 179 } | 170 } |
| 180 | 171 |
| 181 ExtensionService::NaClModuleInfo::NaClModuleInfo() { | |
| 182 } | |
| 183 | |
| 184 ExtensionService::NaClModuleInfo::~NaClModuleInfo() { | |
| 185 } | |
| 186 | |
| 187 // ExtensionService. | 172 // ExtensionService. |
| 188 | 173 |
| 189 const char ExtensionService::kLocalAppSettingsDirectoryName[] = | 174 const char ExtensionService::kLocalAppSettingsDirectoryName[] = |
| 190 "Local App Settings"; | 175 "Local App Settings"; |
| 191 const char ExtensionService::kLocalExtensionSettingsDirectoryName[] = | 176 const char ExtensionService::kLocalExtensionSettingsDirectoryName[] = |
| 192 "Local Extension Settings"; | 177 "Local Extension Settings"; |
| 193 const char ExtensionService::kSyncAppSettingsDirectoryName[] = | 178 const char ExtensionService::kSyncAppSettingsDirectoryName[] = |
| 194 "Sync App Settings"; | 179 "Sync App Settings"; |
| 195 const char ExtensionService::kSyncExtensionSettingsDirectoryName[] = | 180 const char ExtensionService::kSyncExtensionSettingsDirectoryName[] = |
| 196 "Sync Extension Settings"; | 181 "Sync Extension Settings"; |
| (...skipping 886 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1083 content::URLDataSource::Add(profile_, theme_source); | 1068 content::URLDataSource::Add(profile_, theme_source); |
| 1084 } | 1069 } |
| 1085 #endif | 1070 #endif |
| 1086 | 1071 |
| 1087 // Same for chrome://thumb/ resources. | 1072 // Same for chrome://thumb/ resources. |
| 1088 if (extensions::PermissionsData::HasHostPermission( | 1073 if (extensions::PermissionsData::HasHostPermission( |
| 1089 extension, GURL(chrome::kChromeUIThumbnailURL))) { | 1074 extension, GURL(chrome::kChromeUIThumbnailURL))) { |
| 1090 ThumbnailSource* thumbnail_source = new ThumbnailSource(profile_); | 1075 ThumbnailSource* thumbnail_source = new ThumbnailSource(profile_); |
| 1091 content::URLDataSource::Add(profile_, thumbnail_source); | 1076 content::URLDataSource::Add(profile_, thumbnail_source); |
| 1092 } | 1077 } |
| 1093 | |
| 1094 #if defined(ENABLE_PLUGINS) | |
| 1095 // TODO(mpcomplete): This ends up affecting all profiles. See crbug.com/80757. | |
| 1096 bool plugins_changed = false; | |
| 1097 if (extensions::PluginInfo::HasPlugins(extension)) { | |
| 1098 const extensions::PluginInfo::PluginVector* plugins = | |
| 1099 extensions::PluginInfo::GetPlugins(extension); | |
| 1100 CHECK(plugins); | |
| 1101 plugins_changed = true; | |
| 1102 for (extensions::PluginInfo::PluginVector::const_iterator plugin = | |
| 1103 plugins->begin(); | |
| 1104 plugin != plugins->end(); ++plugin) { | |
| 1105 PluginService::GetInstance()->RefreshPlugins(); | |
| 1106 PluginService::GetInstance()->AddExtraPluginPath(plugin->path); | |
| 1107 ChromePluginServiceFilter* filter = | |
| 1108 ChromePluginServiceFilter::GetInstance(); | |
| 1109 if (plugin->is_public) { | |
| 1110 filter->RestrictPluginToProfileAndOrigin( | |
| 1111 plugin->path, profile_, GURL()); | |
| 1112 } else { | |
| 1113 filter->RestrictPluginToProfileAndOrigin( | |
| 1114 plugin->path, profile_, extension->url()); | |
| 1115 } | |
| 1116 } | |
| 1117 } | |
| 1118 | |
| 1119 bool nacl_modules_changed = false; | |
| 1120 for (size_t i = 0; i < extension->nacl_modules().size(); ++i) { | |
| 1121 const Extension::NaClModuleInfo& module = extension->nacl_modules()[i]; | |
| 1122 RegisterNaClModule(module.url, module.mime_type); | |
| 1123 nacl_modules_changed = true; | |
| 1124 } | |
| 1125 | |
| 1126 if (nacl_modules_changed) | |
| 1127 UpdatePluginListWithNaClModules(); | |
| 1128 | |
| 1129 if (plugins_changed || nacl_modules_changed) | |
| 1130 PluginService::GetInstance()->PurgePluginListCache(profile_, false); | |
| 1131 #endif // defined(ENABLE_PLUGINS) | |
| 1132 } | 1078 } |
| 1133 | 1079 |
| 1134 void ExtensionService::NotifyExtensionUnloaded( | 1080 void ExtensionService::NotifyExtensionUnloaded( |
| 1135 const Extension* extension, | 1081 const Extension* extension, |
| 1136 extension_misc::UnloadedExtensionReason reason) { | 1082 extension_misc::UnloadedExtensionReason reason) { |
| 1137 UnloadedExtensionInfo details(extension, reason); | 1083 UnloadedExtensionInfo details(extension, reason); |
| 1138 content::NotificationService::current()->Notify( | 1084 content::NotificationService::current()->Notify( |
| 1139 chrome::NOTIFICATION_EXTENSION_UNLOADED, | 1085 chrome::NOTIFICATION_EXTENSION_UNLOADED, |
| 1140 content::Source<Profile>(profile_), | 1086 content::Source<Profile>(profile_), |
| 1141 content::Details<UnloadedExtensionInfo>(&details)); | 1087 content::Details<UnloadedExtensionInfo>(&details)); |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1173 fileapi::FileSystemContext* filesystem_context = | 1119 fileapi::FileSystemContext* filesystem_context = |
| 1174 BrowserContext::GetStoragePartitionForSite(profile_, site)-> | 1120 BrowserContext::GetStoragePartitionForSite(profile_, site)-> |
| 1175 GetFileSystemContext(); | 1121 GetFileSystemContext(); |
| 1176 if (filesystem_context && filesystem_context->external_provider()) { | 1122 if (filesystem_context && filesystem_context->external_provider()) { |
| 1177 filesystem_context->external_provider()-> | 1123 filesystem_context->external_provider()-> |
| 1178 RevokeAccessForExtension(extension->id()); | 1124 RevokeAccessForExtension(extension->id()); |
| 1179 } | 1125 } |
| 1180 #endif | 1126 #endif |
| 1181 | 1127 |
| 1182 UpdateActiveExtensionsInCrashReporter(); | 1128 UpdateActiveExtensionsInCrashReporter(); |
| 1183 | |
| 1184 #if defined(ENABLE_PLUGINS) | |
| 1185 bool plugins_changed = false; | |
| 1186 if (extensions::PluginInfo::HasPlugins(extension)) { | |
| 1187 const extensions::PluginInfo::PluginVector* plugins = | |
| 1188 extensions::PluginInfo::GetPlugins(extension); | |
| 1189 plugins_changed = true; | |
| 1190 for (extensions::PluginInfo::PluginVector::const_iterator plugin = | |
| 1191 plugins->begin(); | |
| 1192 plugin != plugins->end(); ++plugin) { | |
| 1193 PluginService::GetInstance()->ForcePluginShutdown(plugin->path); | |
| 1194 PluginService::GetInstance()->RefreshPlugins(); | |
| 1195 PluginService::GetInstance()->RemoveExtraPluginPath(plugin->path); | |
| 1196 ChromePluginServiceFilter::GetInstance()->UnrestrictPlugin(plugin->path); | |
| 1197 } | |
| 1198 } | |
| 1199 | |
| 1200 bool nacl_modules_changed = false; | |
| 1201 for (size_t i = 0; i < extension->nacl_modules().size(); ++i) { | |
| 1202 const Extension::NaClModuleInfo& module = extension->nacl_modules()[i]; | |
| 1203 UnregisterNaClModule(module.url); | |
| 1204 nacl_modules_changed = true; | |
| 1205 } | |
| 1206 | |
| 1207 if (nacl_modules_changed) | |
| 1208 UpdatePluginListWithNaClModules(); | |
| 1209 | |
| 1210 if (plugins_changed || nacl_modules_changed) | |
| 1211 PluginService::GetInstance()->PurgePluginListCache(profile_, false); | |
| 1212 #endif // defined(ENABLE_PLUGINS) | |
| 1213 } | 1129 } |
| 1214 | 1130 |
| 1215 Profile* ExtensionService::profile() { | 1131 Profile* ExtensionService::profile() { |
| 1216 return profile_; | 1132 return profile_; |
| 1217 } | 1133 } |
| 1218 | 1134 |
| 1219 extensions::ExtensionPrefs* ExtensionService::extension_prefs() { | 1135 extensions::ExtensionPrefs* ExtensionService::extension_prefs() { |
| 1220 return extension_prefs_; | 1136 return extension_prefs_; |
| 1221 } | 1137 } |
| 1222 | 1138 |
| (...skipping 1590 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2813 extension_runtime_data_.find(extension->id()); | 2729 extension_runtime_data_.find(extension->id()); |
| 2814 return it == extension_runtime_data_.end() ? false : | 2730 return it == extension_runtime_data_.end() ? false : |
| 2815 it->second.has_used_webrequest; | 2731 it->second.has_used_webrequest; |
| 2816 } | 2732 } |
| 2817 | 2733 |
| 2818 void ExtensionService::SetHasUsedWebRequest(const Extension* extension, | 2734 void ExtensionService::SetHasUsedWebRequest(const Extension* extension, |
| 2819 bool value) { | 2735 bool value) { |
| 2820 extension_runtime_data_[extension->id()].has_used_webrequest = value; | 2736 extension_runtime_data_[extension->id()].has_used_webrequest = value; |
| 2821 } | 2737 } |
| 2822 | 2738 |
| 2823 void ExtensionService::RegisterNaClModule(const GURL& url, | |
| 2824 const std::string& mime_type) { | |
| 2825 NaClModuleInfo info; | |
| 2826 info.url = url; | |
| 2827 info.mime_type = mime_type; | |
| 2828 | |
| 2829 DCHECK(FindNaClModule(url) == nacl_module_list_.end()); | |
| 2830 nacl_module_list_.push_front(info); | |
| 2831 } | |
| 2832 | |
| 2833 void ExtensionService::UnregisterNaClModule(const GURL& url) { | |
| 2834 NaClModuleInfoList::iterator iter = FindNaClModule(url); | |
| 2835 DCHECK(iter != nacl_module_list_.end()); | |
| 2836 nacl_module_list_.erase(iter); | |
| 2837 } | |
| 2838 | |
| 2839 void ExtensionService::UpdatePluginListWithNaClModules() { | |
| 2840 // An extension has been added which has a nacl_module component, which means | |
| 2841 // there is a MIME type that module wants to handle, so we need to add that | |
| 2842 // MIME type to plugins which handle NaCl modules in order to allow the | |
| 2843 // individual modules to handle these types. | |
| 2844 base::FilePath path; | |
| 2845 if (!PathService::Get(chrome::FILE_NACL_PLUGIN, &path)) | |
| 2846 return; | |
| 2847 const content::PepperPluginInfo* pepper_info = | |
| 2848 PluginService::GetInstance()->GetRegisteredPpapiPluginInfo(path); | |
| 2849 if (!pepper_info) | |
| 2850 return; | |
| 2851 | |
| 2852 std::vector<webkit::WebPluginMimeType>::const_iterator mime_iter; | |
| 2853 // Check each MIME type the plugins handle for the NaCl MIME type. | |
| 2854 for (mime_iter = pepper_info->mime_types.begin(); | |
| 2855 mime_iter != pepper_info->mime_types.end(); ++mime_iter) { | |
| 2856 if (mime_iter->mime_type == kNaClPluginMimeType) { | |
| 2857 // This plugin handles "application/x-nacl". | |
| 2858 | |
| 2859 PluginService::GetInstance()-> | |
| 2860 UnregisterInternalPlugin(pepper_info->path); | |
| 2861 | |
| 2862 webkit::WebPluginInfo info = pepper_info->ToWebPluginInfo(); | |
| 2863 | |
| 2864 for (ExtensionService::NaClModuleInfoList::const_iterator iter = | |
| 2865 nacl_module_list_.begin(); | |
| 2866 iter != nacl_module_list_.end(); ++iter) { | |
| 2867 // Add the MIME type specified in the extension to this NaCl plugin, | |
| 2868 // With an extra "nacl" argument to specify the location of the NaCl | |
| 2869 // manifest file. | |
| 2870 webkit::WebPluginMimeType mime_type_info; | |
| 2871 mime_type_info.mime_type = iter->mime_type; | |
| 2872 mime_type_info.additional_param_names.push_back(UTF8ToUTF16("nacl")); | |
| 2873 mime_type_info.additional_param_values.push_back( | |
| 2874 UTF8ToUTF16(iter->url.spec())); | |
| 2875 info.mime_types.push_back(mime_type_info); | |
| 2876 } | |
| 2877 | |
| 2878 PluginService::GetInstance()->RefreshPlugins(); | |
| 2879 PluginService::GetInstance()->RegisterInternalPlugin(info, true); | |
| 2880 // This plugin has been modified, no need to check the rest of its | |
| 2881 // types, but continue checking other plugins. | |
| 2882 break; | |
| 2883 } | |
| 2884 } | |
| 2885 } | |
| 2886 | |
| 2887 ExtensionService::NaClModuleInfoList::iterator | |
| 2888 ExtensionService::FindNaClModule(const GURL& url) { | |
| 2889 for (NaClModuleInfoList::iterator iter = nacl_module_list_.begin(); | |
| 2890 iter != nacl_module_list_.end(); ++iter) { | |
| 2891 if (iter->url == url) | |
| 2892 return iter; | |
| 2893 } | |
| 2894 return nacl_module_list_.end(); | |
| 2895 } | |
| 2896 | |
| 2897 void ExtensionService::DoPostLoadTasks(const Extension* extension) { | 2739 void ExtensionService::DoPostLoadTasks(const Extension* extension) { |
| 2898 std::map<std::string, int>::iterator it = | 2740 std::map<std::string, int>::iterator it = |
| 2899 on_load_events_.find(extension->id()); | 2741 on_load_events_.find(extension->id()); |
| 2900 if (it == on_load_events_.end()) | 2742 if (it == on_load_events_.end()) |
| 2901 return; | 2743 return; |
| 2902 | 2744 |
| 2903 int events_to_fire = it->second; | 2745 int events_to_fire = it->second; |
| 2904 extensions::LazyBackgroundTaskQueue* queue = | 2746 extensions::LazyBackgroundTaskQueue* queue = |
| 2905 system_->lazy_background_task_queue(); | 2747 system_->lazy_background_task_queue(); |
| 2906 if (queue->ShouldEnqueueTask(profile(), extension)) { | 2748 if (queue->ShouldEnqueueTask(profile(), extension)) { |
| (...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3106 } | 2948 } |
| 3107 | 2949 |
| 3108 void ExtensionService::AddUpdateObserver(extensions::UpdateObserver* observer) { | 2950 void ExtensionService::AddUpdateObserver(extensions::UpdateObserver* observer) { |
| 3109 update_observers_.AddObserver(observer); | 2951 update_observers_.AddObserver(observer); |
| 3110 } | 2952 } |
| 3111 | 2953 |
| 3112 void ExtensionService::RemoveUpdateObserver( | 2954 void ExtensionService::RemoveUpdateObserver( |
| 3113 extensions::UpdateObserver* observer) { | 2955 extensions::UpdateObserver* observer) { |
| 3114 update_observers_.RemoveObserver(observer); | 2956 update_observers_.RemoveObserver(observer); |
| 3115 } | 2957 } |
| OLD | NEW |