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 65b0a7762efee86ab154f52097c6d0684b945620..b440d06de703265e29dd9f13123f37b80950fa16 100644 |
| --- a/chrome/browser/chrome_content_browser_client.cc |
| +++ b/chrome/browser/chrome_content_browser_client.cc |
| @@ -46,7 +46,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" |
| @@ -239,6 +238,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 |
| @@ -280,46 +283,6 @@ namespace { |
| // thread. |
| base::LazyInstance<std::string> g_io_thread_application_locale; |
| -#if defined(ENABLE_PLUGINS) |
| -// TODO(teravest): Add renderer-side API-specific checking for these APIs so |
| -// that blanket permission isn't granted to all dev channel APIs for these. |
| -// http://crbug.com/386743 |
| -const char* const kPredefinedAllowedDevChannelOrigins[] = { |
| - "6EAED1924DB611B6EEF2A664BD077BE7EAD33B8F", // see crbug.com/383937 |
| - "4EB74897CB187C7633357C2FE832E0AD6A44883A" // see crbug.com/383937 |
| -}; |
| - |
| -const char* const kPredefinedAllowedFileHandleOrigins[] = { |
| - "6EAED1924DB611B6EEF2A664BD077BE7EAD33B8F", // see crbug.com/234789 |
| - "4EB74897CB187C7633357C2FE832E0AD6A44883A" // see crbug.com/234789 |
| -}; |
| - |
| -const char* const kPredefinedAllowedSocketOrigins[] = { |
| - "okddffdblfhhnmhodogpojmfkjmhinfp", // Test SSH Client |
| - "pnhechapfaindjhompbnflcldabbghjo", // HTerm App (SSH Client) |
| - "bglhmjfplikpjnfoegeomebmfnkjomhe", // see crbug.com/122126 |
| - "gbchcmhmhahfdphkhkmpfmihenigjmpp", // Chrome Remote Desktop |
| - "kgngmbheleoaphbjbaiobfdepmghbfah", // Pre-release Chrome Remote Desktop |
| - "odkaodonbgfohohmklejpjiejmcipmib", // Dogfood Chrome Remote Desktop |
| - "ojoimpklfciegopdfgeenehpalipignm", // Chromoting canary |
| - "cbkkbcmdlboombapidmoeolnmdacpkch", // see crbug.com/129089 |
| - "hhnbmknkdabfoieppbbljkhkfjcmcbjh", // see crbug.com/134099 |
| - "mablfbjkhmhkmefkjjacnbaikjkipphg", // see crbug.com/134099 |
| - "pdeelgamlgannhelgoegilelnnojegoh", // see crbug.com/134099 |
| - "cabapfdbkniadpollkckdnedaanlciaj", // see crbug.com/134099 |
| - "mapljbgnjledlpdmlchihnmeclmefbba", // see crbug.com/134099 |
| - "ghbfeebgmiidnnmeobbbaiamklmpbpii", // see crbug.com/134099 |
| - "jdfhpkjeckflbbleddjlpimecpbjdeep", // see crbug.com/142514 |
| - "iabmpiboiopbgfabjmgeedhcmjenhbla", // see crbug.com/165080 |
| - "B7CF8A292249681AF81771650BA4CEEAF19A4560", // see crbug.com/165080 |
| - "6EAED1924DB611B6EEF2A664BD077BE7EAD33B8F", // see crbug.com/234789 |
| - "4EB74897CB187C7633357C2FE832E0AD6A44883A", // see crbug.com/234789 |
| - "7525AF4F66763A70A883C4700529F647B470E4D2", // see crbug.com/238084 |
| - "0B549507088E1564D672F7942EB87CA4DAD73972", // see crbug.com/238084 |
| - "864288364E239573E777D3E0E36864E590E95C74" // see crbug.com/238084 |
| -}; |
| -#endif |
| - |
| // Returns a copy of the given url with its host set to given host and path set |
| // to given path. Other parts of the url will be the same. |
| GURL ReplaceURLHostAndPath(const GURL& url, |
| @@ -596,12 +559,7 @@ ChromeContentBrowserClient::ChromeContentBrowserClient() |
| : prerender_tracker_(NULL), |
| weak_factory_(this) { |
| #if defined(ENABLE_PLUGINS) |
| - for (size_t i = 0; i < arraysize(kPredefinedAllowedDevChannelOrigins); ++i) |
| - allowed_dev_channel_origins_.insert(kPredefinedAllowedDevChannelOrigins[i]); |
| - for (size_t i = 0; i < arraysize(kPredefinedAllowedFileHandleOrigins); ++i) |
| - allowed_file_handle_origins_.insert(kPredefinedAllowedFileHandleOrigins[i]); |
| - for (size_t i = 0; i < arraysize(kPredefinedAllowedSocketOrigins); ++i) |
| - allowed_socket_origins_.insert(kPredefinedAllowedSocketOrigins[i]); |
| + plugin_parts_ = new plugins::ChromeContentBrowserClientPluginsPart; |
| #endif |
| #if !defined(OS_ANDROID) |
| @@ -618,6 +576,11 @@ ChromeContentBrowserClient::~ChromeContentBrowserClient() { |
| for (int i = static_cast<int>(extra_parts_.size()) - 1; i >= 0; --i) |
| delete extra_parts_[i]; |
| extra_parts_.clear(); |
| + |
| +#if defined(ENABLE_PLUGINS) |
| + if (plugin_parts_) |
| + delete plugin_parts_; |
| +#endif |
| } |
| // static |
| @@ -810,7 +773,7 @@ void ChromeContentBrowserClient::RenderProcessWillLaunch( |
| host->AddFilter(new ChromeRenderMessageFilter(id, profile)); |
| #if defined(ENABLE_PLUGINS) |
| - host->AddFilter(new PluginInfoMessageFilter(id, profile)); |
| + plugin_parts_->RenderProcessWillLaunch(host); |
|
Lei Zhang
2014/11/18 03:14:46
The goal is to get rid of the ifdefs in this file,
|
| #endif |
| host->AddFilter(new cast::CastTransportHostFilter); |
| #if defined(ENABLE_PRINTING) |
| @@ -2307,49 +2270,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) { |
| - const ExtensionService* ext_service = |
| - extensions::ExtensionSystem::Get(profile)->extension_service(); |
| - if (ext_service) { |
| - extension_set = ext_service->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) |
| + return plugin_parts_->AllowPepperSocketAPI( |
| + browser_context, url, private_api, params); |
| #else |
| return false; |
| #endif |
| @@ -2526,20 +2449,9 @@ 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) { |
| - const ExtensionService* ext_service = |
| - extensions::ExtensionSystem::Get(profile)->extension_service(); |
| - if (ext_service) { |
| - extension_set = ext_service->extensions(); |
| - } |
| - } |
| - return IsExtensionOrSharedModuleWhitelisted(url, extension_set, |
| - allowed_file_handle_origins_) || |
| - IsHostAllowedByCommandLine(url, extension_set, |
| - switches::kAllowNaClFileHandleAPI); |
| +#if defined(ENABLE_PLUGINS) |
| + return plugin_parts_->IsPluginAllowedToCallRequestOSFileHandle( |
| + browser_context, url); |
| #else |
| return false; |
| #endif |
| @@ -2548,35 +2460,14 @@ bool ChromeContentBrowserClient::IsPluginAllowedToCallRequestOSFileHandle( |
| bool ChromeContentBrowserClient::IsPluginAllowedToUseDevChannelAPIs( |
| content::BrowserContext* browser_context, |
| const GURL& url) { |
| -#if defined(ENABLE_EXTENSIONS) |
| +#if defined(ENABLE_PLUGINS) |
| // Allow access for tests. |
| if (CommandLine::ForCurrentProcess()->HasSwitch( |
| switches::kEnablePepperTesting)) { |
| return true; |
| } |
| - |
| - Profile* profile = Profile::FromBrowserContext(browser_context); |
| - const extensions::ExtensionSet* extension_set = NULL; |
| - if (profile) { |
| - const ExtensionService* ext_service = |
| - extensions::ExtensionSystem::Get(profile)->extension_service(); |
| - if (ext_service) { |
| - extension_set = ext_service->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 plugin_parts_->IsPluginAllowedToUseDevChannelAPIs(browser_context, |
| + url); |
| #else |
| return false; |
| #endif |