| 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/basictypes.h" | 10 #include "base/basictypes.h" |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 #include "chrome/common/extensions/extension_constants.h" | 80 #include "chrome/common/extensions/extension_constants.h" |
| 81 #include "chrome/common/extensions/extension_error_utils.h" | 81 #include "chrome/common/extensions/extension_error_utils.h" |
| 82 #include "chrome/common/extensions/extension_file_util.h" | 82 #include "chrome/common/extensions/extension_file_util.h" |
| 83 #include "chrome/common/extensions/extension_messages.h" | 83 #include "chrome/common/extensions/extension_messages.h" |
| 84 #include "chrome/common/extensions/extension_resource.h" | 84 #include "chrome/common/extensions/extension_resource.h" |
| 85 #include "chrome/common/pref_names.h" | 85 #include "chrome/common/pref_names.h" |
| 86 #include "chrome/common/url_constants.h" | 86 #include "chrome/common/url_constants.h" |
| 87 #include "content/browser/debugger/devtools_manager.h" | 87 #include "content/browser/debugger/devtools_manager.h" |
| 88 #include "content/browser/plugin_process_host.h" | 88 #include "content/browser/plugin_process_host.h" |
| 89 #include "content/browser/plugin_service.h" | 89 #include "content/browser/plugin_service.h" |
| 90 #include "content/browser/renderer_host/render_process_host.h" | |
| 91 #include "content/browser/user_metrics.h" | 90 #include "content/browser/user_metrics.h" |
| 92 #include "content/common/pepper_plugin_registry.h" | 91 #include "content/common/pepper_plugin_registry.h" |
| 93 #include "content/public/browser/browser_thread.h" | 92 #include "content/public/browser/browser_thread.h" |
| 94 #include "content/public/browser/notification_service.h" | 93 #include "content/public/browser/notification_service.h" |
| 95 #include "content/public/browser/notification_types.h" | 94 #include "content/public/browser/notification_types.h" |
| 95 #include "content/public/browser/render_process_host.h" |
| 96 #include "googleurl/src/gurl.h" | 96 #include "googleurl/src/gurl.h" |
| 97 #include "net/base/registry_controlled_domain.h" | 97 #include "net/base/registry_controlled_domain.h" |
| 98 #include "webkit/database/database_tracker.h" | 98 #include "webkit/database/database_tracker.h" |
| 99 #include "webkit/database/database_util.h" | 99 #include "webkit/database/database_util.h" |
| 100 | 100 |
| 101 #if defined(OS_CHROMEOS) | 101 #if defined(OS_CHROMEOS) |
| 102 #include "chrome/browser/chromeos/cros/cros_library.h" | 102 #include "chrome/browser/chromeos/cros/cros_library.h" |
| 103 #include "chrome/browser/chromeos/extensions/file_browser_event_router.h" | 103 #include "chrome/browser/chromeos/extensions/file_browser_event_router.h" |
| 104 #include "chrome/browser/chromeos/extensions/input_method_event_router.h" | 104 #include "chrome/browser/chromeos/extensions/input_method_event_router.h" |
| 105 #include "chrome/browser/chromeos/extensions/media_player_event_router.h" | 105 #include "chrome/browser/chromeos/extensions/media_player_event_router.h" |
| (...skipping 803 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 909 profile_->RegisterExtensionWithRequestContexts(extension); | 909 profile_->RegisterExtensionWithRequestContexts(extension); |
| 910 | 910 |
| 911 // Tell subsystems that use the EXTENSION_LOADED notification about the new | 911 // Tell subsystems that use the EXTENSION_LOADED notification about the new |
| 912 // extension. | 912 // extension. |
| 913 content::NotificationService::current()->Notify( | 913 content::NotificationService::current()->Notify( |
| 914 chrome::NOTIFICATION_EXTENSION_LOADED, | 914 chrome::NOTIFICATION_EXTENSION_LOADED, |
| 915 content::Source<Profile>(profile_), | 915 content::Source<Profile>(profile_), |
| 916 content::Details<const Extension>(extension)); | 916 content::Details<const Extension>(extension)); |
| 917 | 917 |
| 918 // Tell renderers about the new extension. | 918 // Tell renderers about the new extension. |
| 919 for (RenderProcessHost::iterator i(RenderProcessHost::AllHostsIterator()); | 919 for (content::RenderProcessHost::iterator i( |
| 920 content::RenderProcessHost::AllHostsIterator()); |
| 920 !i.IsAtEnd(); i.Advance()) { | 921 !i.IsAtEnd(); i.Advance()) { |
| 921 RenderProcessHost* host = i.GetCurrentValue(); | 922 content::RenderProcessHost* host = i.GetCurrentValue(); |
| 922 Profile* host_profile = | 923 Profile* host_profile = |
| 923 Profile::FromBrowserContext(host->browser_context()); | 924 Profile::FromBrowserContext(host->GetBrowserContext()); |
| 924 if (host_profile->GetOriginalProfile() == profile_->GetOriginalProfile()) { | 925 if (host_profile->GetOriginalProfile() == profile_->GetOriginalProfile()) { |
| 925 std::vector<ExtensionMsg_Loaded_Params> loaded_extensions( | 926 std::vector<ExtensionMsg_Loaded_Params> loaded_extensions( |
| 926 1, ExtensionMsg_Loaded_Params(extension)); | 927 1, ExtensionMsg_Loaded_Params(extension)); |
| 927 host->Send( | 928 host->Send( |
| 928 new ExtensionMsg_Loaded(loaded_extensions)); | 929 new ExtensionMsg_Loaded(loaded_extensions)); |
| 929 } | 930 } |
| 930 } | 931 } |
| 931 | 932 |
| 932 // Tell a random-ass collection of other subsystems about the new extension. | 933 // Tell a random-ass collection of other subsystems about the new extension. |
| 933 // TODO(aa): What should we do with all this goop? Can it move into the | 934 // TODO(aa): What should we do with all this goop? Can it move into the |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1029 | 1030 |
| 1030 void ExtensionService::NotifyExtensionUnloaded( | 1031 void ExtensionService::NotifyExtensionUnloaded( |
| 1031 const Extension* extension, | 1032 const Extension* extension, |
| 1032 extension_misc::UnloadedExtensionReason reason) { | 1033 extension_misc::UnloadedExtensionReason reason) { |
| 1033 UnloadedExtensionInfo details(extension, reason); | 1034 UnloadedExtensionInfo details(extension, reason); |
| 1034 content::NotificationService::current()->Notify( | 1035 content::NotificationService::current()->Notify( |
| 1035 chrome::NOTIFICATION_EXTENSION_UNLOADED, | 1036 chrome::NOTIFICATION_EXTENSION_UNLOADED, |
| 1036 content::Source<Profile>(profile_), | 1037 content::Source<Profile>(profile_), |
| 1037 content::Details<UnloadedExtensionInfo>(&details)); | 1038 content::Details<UnloadedExtensionInfo>(&details)); |
| 1038 | 1039 |
| 1039 for (RenderProcessHost::iterator i(RenderProcessHost::AllHostsIterator()); | 1040 for (content::RenderProcessHost::iterator i( |
| 1041 content::RenderProcessHost::AllHostsIterator()); |
| 1040 !i.IsAtEnd(); i.Advance()) { | 1042 !i.IsAtEnd(); i.Advance()) { |
| 1041 RenderProcessHost* host = i.GetCurrentValue(); | 1043 content::RenderProcessHost* host = i.GetCurrentValue(); |
| 1042 Profile* host_profile = | 1044 Profile* host_profile = |
| 1043 Profile::FromBrowserContext(host->browser_context()); | 1045 Profile::FromBrowserContext(host->GetBrowserContext()); |
| 1044 if (host_profile->GetOriginalProfile() == profile_->GetOriginalProfile()) | 1046 if (host_profile->GetOriginalProfile() == profile_->GetOriginalProfile()) |
| 1045 host->Send(new ExtensionMsg_Unloaded(extension->id())); | 1047 host->Send(new ExtensionMsg_Unloaded(extension->id())); |
| 1046 } | 1048 } |
| 1047 | 1049 |
| 1048 profile_->UnregisterExtensionWithRequestContexts(extension->id(), reason); | 1050 profile_->UnregisterExtensionWithRequestContexts(extension->id(), reason); |
| 1049 profile_->GetExtensionSpecialStoragePolicy()-> | 1051 profile_->GetExtensionSpecialStoragePolicy()-> |
| 1050 RevokeRightsForExtension(extension); | 1052 RevokeRightsForExtension(extension); |
| 1051 | 1053 |
| 1052 ExtensionWebUI::UnregisterChromeURLOverrides( | 1054 ExtensionWebUI::UnregisterChromeURLOverrides( |
| 1053 profile_, extension->GetChromeURLOverrides()); | 1055 profile_, extension->GetChromeURLOverrides()); |
| (...skipping 1255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2309 // access to the Extension and ExtensionHost. | 2311 // access to the Extension and ExtensionHost. |
| 2310 MessageLoop::current()->PostTask( | 2312 MessageLoop::current()->PostTask( |
| 2311 FROM_HERE, | 2313 FROM_HERE, |
| 2312 base::Bind( | 2314 base::Bind( |
| 2313 &ExtensionService::TrackTerminatedExtension, | 2315 &ExtensionService::TrackTerminatedExtension, |
| 2314 AsWeakPtr(), | 2316 AsWeakPtr(), |
| 2315 host->extension())); | 2317 host->extension())); |
| 2316 break; | 2318 break; |
| 2317 } | 2319 } |
| 2318 case content::NOTIFICATION_RENDERER_PROCESS_CREATED: { | 2320 case content::NOTIFICATION_RENDERER_PROCESS_CREATED: { |
| 2319 RenderProcessHost* process = | 2321 content::RenderProcessHost* process = |
| 2320 content::Source<RenderProcessHost>(source).ptr(); | 2322 content::Source<content::RenderProcessHost>(source).ptr(); |
| 2321 Profile* host_profile = | 2323 Profile* host_profile = |
| 2322 Profile::FromBrowserContext(process->browser_context()); | 2324 Profile::FromBrowserContext(process->GetBrowserContext()); |
| 2323 if (!profile_->IsSameProfile(host_profile->GetOriginalProfile())) | 2325 if (!profile_->IsSameProfile(host_profile->GetOriginalProfile())) |
| 2324 break; | 2326 break; |
| 2325 | 2327 |
| 2326 // Valid extension function names, used to setup bindings in renderer. | 2328 // Valid extension function names, used to setup bindings in renderer. |
| 2327 std::vector<std::string> function_names; | 2329 std::vector<std::string> function_names; |
| 2328 ExtensionFunctionDispatcher::GetAllFunctionNames(&function_names); | 2330 ExtensionFunctionDispatcher::GetAllFunctionNames(&function_names); |
| 2329 process->Send(new ExtensionMsg_SetFunctionNames(function_names)); | 2331 process->Send(new ExtensionMsg_SetFunctionNames(function_names)); |
| 2330 | 2332 |
| 2331 // Scripting whitelist. This is modified by tests and must be communicated | 2333 // Scripting whitelist. This is modified by tests and must be communicated |
| 2332 // to renderers. | 2334 // to renderers. |
| 2333 process->Send(new ExtensionMsg_SetScriptingWhitelist( | 2335 process->Send(new ExtensionMsg_SetScriptingWhitelist( |
| 2334 *Extension::GetScriptingWhitelist())); | 2336 *Extension::GetScriptingWhitelist())); |
| 2335 | 2337 |
| 2336 // Loaded extensions. | 2338 // Loaded extensions. |
| 2337 std::vector<ExtensionMsg_Loaded_Params> loaded_extensions; | 2339 std::vector<ExtensionMsg_Loaded_Params> loaded_extensions; |
| 2338 for (size_t i = 0; i < extensions_.size(); ++i) { | 2340 for (size_t i = 0; i < extensions_.size(); ++i) { |
| 2339 loaded_extensions.push_back( | 2341 loaded_extensions.push_back( |
| 2340 ExtensionMsg_Loaded_Params(extensions_[i])); | 2342 ExtensionMsg_Loaded_Params(extensions_[i])); |
| 2341 } | 2343 } |
| 2342 process->Send(new ExtensionMsg_Loaded(loaded_extensions)); | 2344 process->Send(new ExtensionMsg_Loaded(loaded_extensions)); |
| 2343 break; | 2345 break; |
| 2344 } | 2346 } |
| 2345 case content::NOTIFICATION_RENDERER_PROCESS_TERMINATED: { | 2347 case content::NOTIFICATION_RENDERER_PROCESS_TERMINATED: { |
| 2346 RenderProcessHost* process = | 2348 content::RenderProcessHost* process = |
| 2347 content::Source<RenderProcessHost>(source).ptr(); | 2349 content::Source<content::RenderProcessHost>(source).ptr(); |
| 2348 Profile* host_profile = | 2350 Profile* host_profile = |
| 2349 Profile::FromBrowserContext(process->browser_context()); | 2351 Profile::FromBrowserContext(process->GetBrowserContext()); |
| 2350 if (!profile_->IsSameProfile(host_profile->GetOriginalProfile())) | 2352 if (!profile_->IsSameProfile(host_profile->GetOriginalProfile())) |
| 2351 break; | 2353 break; |
| 2352 | 2354 |
| 2353 installed_app_hosts_.erase(process->id()); | 2355 installed_app_hosts_.erase(process->GetID()); |
| 2354 | 2356 |
| 2355 process_map_.Remove(process->id()); | 2357 process_map_.Remove(process->GetID()); |
| 2356 BrowserThread::PostTask( | 2358 BrowserThread::PostTask( |
| 2357 BrowserThread::IO, FROM_HERE, | 2359 BrowserThread::IO, FROM_HERE, |
| 2358 base::Bind(&ExtensionInfoMap::UnregisterAllExtensionsInProcess, | 2360 base::Bind(&ExtensionInfoMap::UnregisterAllExtensionsInProcess, |
| 2359 profile_->GetExtensionInfoMap(), | 2361 profile_->GetExtensionInfoMap(), |
| 2360 process->id())); | 2362 process->GetID())); |
| 2361 break; | 2363 break; |
| 2362 } | 2364 } |
| 2363 case chrome::NOTIFICATION_PREF_CHANGED: { | 2365 case chrome::NOTIFICATION_PREF_CHANGED: { |
| 2364 std::string* pref_name = content::Details<std::string>(details).ptr(); | 2366 std::string* pref_name = content::Details<std::string>(details).ptr(); |
| 2365 if (*pref_name == prefs::kExtensionInstallAllowList || | 2367 if (*pref_name == prefs::kExtensionInstallAllowList || |
| 2366 *pref_name == prefs::kExtensionInstallDenyList) { | 2368 *pref_name == prefs::kExtensionInstallDenyList) { |
| 2367 CheckAdminBlacklist(); | 2369 CheckAdminBlacklist(); |
| 2368 } else { | 2370 } else { |
| 2369 NOTREACHED() << "Unexpected preference name."; | 2371 NOTREACHED() << "Unexpected preference name."; |
| 2370 } | 2372 } |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2502 | 2504 |
| 2503 ExtensionService::NaClModuleInfoList::iterator | 2505 ExtensionService::NaClModuleInfoList::iterator |
| 2504 ExtensionService::FindNaClModule(const GURL& url) { | 2506 ExtensionService::FindNaClModule(const GURL& url) { |
| 2505 for (NaClModuleInfoList::iterator iter = nacl_module_list_.begin(); | 2507 for (NaClModuleInfoList::iterator iter = nacl_module_list_.begin(); |
| 2506 iter != nacl_module_list_.end(); ++iter) { | 2508 iter != nacl_module_list_.end(); ++iter) { |
| 2507 if (iter->url == url) | 2509 if (iter->url == url) |
| 2508 return iter; | 2510 return iter; |
| 2509 } | 2511 } |
| 2510 return nacl_module_list_.end(); | 2512 return nacl_module_list_.end(); |
| 2511 } | 2513 } |
| OLD | NEW |