Chromium Code Reviews| Index: chrome/browser/chrome_content_browser_client.cc |
| diff --git a/chrome/browser/chrome_content_browser_client.cc b/chrome/browser/chrome_content_browser_client.cc |
| index a872ec6c9b027869d158c6dc1934f05be88253a9..a4d74ee4268506ff3934aaddbfa933a0845004ea 100644 |
| --- a/chrome/browser/chrome_content_browser_client.cc |
| +++ b/chrome/browser/chrome_content_browser_client.cc |
| @@ -45,7 +45,6 @@ |
| #include "chrome/browser/notifications/desktop_notification_service.h" |
| #include "chrome/browser/notifications/desktop_notification_service_factory.h" |
| #include "chrome/browser/platform_util.h" |
| -#include "chrome/browser/plugins/plugin_info_message_filter.h" |
| #include "chrome/browser/prerender/prerender_final_status.h" |
| #include "chrome/browser/prerender/prerender_manager.h" |
| #include "chrome/browser/prerender/prerender_manager_factory.h" |
| @@ -241,6 +240,10 @@ |
| #include "extensions/common/switches.h" |
| #endif |
| +#if defined(ENABLE_PLUGINS) |
| +#include "chrome/browser/plugins/chrome_content_browser_client_plugins_part.h" |
| +#endif |
| + |
| #if defined(ENABLE_SPELLCHECK) |
| #include "chrome/browser/spellchecker/spellcheck_message_filter.h" |
| #endif |
| @@ -276,6 +279,10 @@ using extensions::InfoMap; |
| using extensions::Manifest; |
| #endif |
| +#if defined(ENABLE_PLUGINS) |
| +using plugins::ChromeContentBrowserClientPluginsPart; |
| +#endif |
| + |
| namespace { |
| // Cached version of the locale so we can return the locale on the I/O |
| @@ -608,6 +615,8 @@ ChromeContentBrowserClient::ChromeContentBrowserClient() |
| allowed_file_handle_origins_.insert(kPredefinedAllowedFileHandleOrigins[i]); |
| for (size_t i = 0; i < arraysize(kPredefinedAllowedSocketOrigins); ++i) |
| allowed_socket_origins_.insert(kPredefinedAllowedSocketOrigins[i]); |
| + |
| + extra_parts_.push_back(new ChromeContentBrowserClientPluginsPart); |
| #endif |
| #if !defined(OS_ANDROID) |
| @@ -817,9 +826,6 @@ void ChromeContentBrowserClient::RenderProcessWillLaunch( |
| profile->GetRequestContextForRenderProcess(id); |
| host->AddFilter(new ChromeRenderMessageFilter(id, profile)); |
| -#if defined(ENABLE_PLUGINS) |
| - host->AddFilter(new PluginInfoMessageFilter(id, profile)); |
| -#endif |
| host->AddFilter(new cast::CastTransportHostFilter); |
| #if defined(ENABLE_PRINTING) |
| host->AddFilter(new printing::PrintingMessageFilter(id, profile)); |
| @@ -2332,9 +2338,7 @@ std::string ChromeContentBrowserClient::GetDefaultDownloadName() { |
| void ChromeContentBrowserClient::DidCreatePpapiPlugin( |
| content::BrowserPpapiHost* browser_host) { |
| #if defined(ENABLE_PLUGINS) |
| - browser_host->GetPpapiHost()->AddHostFactoryFilter( |
| - scoped_ptr<ppapi::host::HostFactory>( |
| - new ChromeBrowserPepperHostFactory(browser_host))); |
| + ChromeContentBrowserClientPluginsPart::DidCreatePpapiPlugin(browser_host); |
| #endif |
| } |
| @@ -2362,46 +2366,9 @@ bool ChromeContentBrowserClient::AllowPepperSocketAPI( |
| const GURL& url, |
| bool private_api, |
| const content::SocketPermissionRequest* params) { |
| -#if defined(ENABLE_EXTENSIONS) |
| - Profile* profile = Profile::FromBrowserContext(browser_context); |
| - const extensions::ExtensionSet* extension_set = NULL; |
| - if (profile) { |
| - extension_set = |
| - &extensions::ExtensionRegistry::Get(profile)->enabled_extensions(); |
| - } |
| - |
| - if (private_api) { |
| - // Access to private socket APIs is controlled by the whitelist. |
| - if (IsExtensionOrSharedModuleWhitelisted(url, extension_set, |
| - allowed_socket_origins_)) { |
| - return true; |
| - } |
| - } else { |
| - // Access to public socket APIs is controlled by extension permissions. |
| - if (url.is_valid() && url.SchemeIs(extensions::kExtensionScheme) && |
| - extension_set) { |
| - const Extension* extension = extension_set->GetByID(url.host()); |
| - if (extension) { |
| - const extensions::PermissionsData* permissions_data = |
| - extension->permissions_data(); |
| - if (params) { |
| - extensions::SocketPermission::CheckParam check_params( |
| - params->type, params->host, params->port); |
| - if (permissions_data->CheckAPIPermissionWithParam( |
| - extensions::APIPermission::kSocket, &check_params)) { |
| - return true; |
| - } |
| - } else if (permissions_data->HasAPIPermission( |
| - extensions::APIPermission::kSocket)) { |
| - return true; |
| - } |
| - } |
| - } |
| - } |
| - |
| - // Allow both public and private APIs if the command line says so. |
| - return IsHostAllowedByCommandLine(url, extension_set, |
| - switches::kAllowNaClSocketAPI); |
| +#if defined(ENABLE_PLUGINS) && defined(ENABLE_EXTENSIONS) |
| + return ChromeContentBrowserClientPluginsPart::AllowPepperSocketAPI( |
| + browser_context, url, private_api, params, allowed_socket_origins_); |
| #else |
| return false; |
| #endif |
| @@ -2596,17 +2563,10 @@ ChromeContentBrowserClient::GetDevToolsManagerDelegate() { |
| bool ChromeContentBrowserClient::IsPluginAllowedToCallRequestOSFileHandle( |
| content::BrowserContext* browser_context, |
| const GURL& url) { |
| -#if defined(ENABLE_EXTENSIONS) |
| - Profile* profile = Profile::FromBrowserContext(browser_context); |
| - const extensions::ExtensionSet* extension_set = NULL; |
| - if (profile) { |
| - extension_set = |
| - &extensions::ExtensionRegistry::Get(profile)->enabled_extensions(); |
| - } |
| - return IsExtensionOrSharedModuleWhitelisted(url, extension_set, |
| - allowed_file_handle_origins_) || |
| - IsHostAllowedByCommandLine(url, extension_set, |
| - switches::kAllowNaClFileHandleAPI); |
| +#if defined(ENABLE_PLUGINS) && defined(ENABLE_EXTENSIONS) |
| + return ChromeContentBrowserClientPluginsPart:: |
| + IsPluginAllowedToCallRequestOSFileHandle(browser_context, url, |
| + allowed_file_handle_origins_); |
| #else |
| return false; |
| #endif |
| @@ -2615,32 +2575,15 @@ bool ChromeContentBrowserClient::IsPluginAllowedToCallRequestOSFileHandle( |
| bool ChromeContentBrowserClient::IsPluginAllowedToUseDevChannelAPIs( |
| content::BrowserContext* browser_context, |
| const GURL& url) { |
| -#if defined(ENABLE_EXTENSIONS) |
| +#if defined(ENABLE_PLUGINS) && defined(ENABLE_EXTENSIONS) |
| // Allow access for tests. |
| if (CommandLine::ForCurrentProcess()->HasSwitch( |
|
Lei Zhang
2014/12/04 22:59:43
Move this into chrome_content_browser_client_plugi
Jitu( very slow this week)
2014/12/05 05:39:30
Done.
|
| switches::kEnablePepperTesting)) { |
| return true; |
| } |
| - |
| - Profile* profile = Profile::FromBrowserContext(browser_context); |
| - const extensions::ExtensionSet* extension_set = NULL; |
| - if (profile) { |
| - extension_set = |
| - &extensions::ExtensionRegistry::Get(profile)->enabled_extensions(); |
| - } |
| - |
| - // Allow access for whitelisted applications. |
| - if (IsExtensionOrSharedModuleWhitelisted(url, |
| - extension_set, |
| - allowed_dev_channel_origins_)) { |
| - return true; |
| - } |
| - |
| - chrome::VersionInfo::Channel channel = chrome::VersionInfo::GetChannel(); |
| - // Allow dev channel APIs to be used on "Canary", "Dev", and "Unknown" |
| - // releases of Chrome. Permitting "Unknown" allows these APIs to be used on |
| - // Chromium builds as well. |
| - return channel <= chrome::VersionInfo::CHANNEL_DEV; |
| + return ChromeContentBrowserClientPluginsPart:: |
| + IsPluginAllowedToUseDevChannelAPIs(browser_context, url, |
| + allowed_dev_channel_origins_); |
| #else |
| return false; |
| #endif |