Index: chrome/browser/plugins/chrome_content_browser_client_plugins_part.cc |
diff --git a/chrome/browser/plugins/chrome_content_browser_client_plugins_part.cc b/chrome/browser/plugins/chrome_content_browser_client_plugins_part.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..3e59bc8b7304eabc554ef243322f33adb4f5a6d8 |
--- /dev/null |
+++ b/chrome/browser/plugins/chrome_content_browser_client_plugins_part.cc |
@@ -0,0 +1,135 @@ |
+// Copyright (c) 2014 The Chromium Authors. All rights reserved. |
Lei Zhang
2014/12/04 22:59:43
ditto, no (c)
Jitu( very slow this week)
2014/12/05 05:39:31
Done.
|
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#include "chrome/browser/plugins/chrome_content_browser_client_plugins_part.h" |
+ |
+#include "chrome/browser/extensions/extension_service.h" |
+#include "chrome/browser/plugins/plugin_info_message_filter.h" |
+#include "chrome/browser/profiles/profile.h" |
+#include "chrome/browser/renderer_host/pepper/chrome_browser_pepper_host_factory.h" |
+#include "chrome/common/chrome_switches.h" |
+#include "chrome/common/chrome_version_info.h" |
+#include "chrome/common/pepper_permission_util.h" |
+#include "content/public/browser/render_process_host.h" |
+#include "extensions/browser/extension_registry.h" |
+#include "extensions/common/constants.h" |
+#include "extensions/common/permissions/permissions_data.h" |
+#include "extensions/common/permissions/socket_permission.h" |
+#include "ppapi/host/ppapi_host.h" |
+ |
+using namespace extensions; |
Lei Zhang
2014/12/04 22:59:43
Please don't do this, it's against the style guide
Jitu( very slow this week)
2014/12/05 05:39:31
Thanks
Done
|
+ |
+namespace plugins { |
+ |
+ChromeContentBrowserClientPluginsPart::ChromeContentBrowserClientPluginsPart() { |
+} |
+ |
+ChromeContentBrowserClientPluginsPart:: |
+ ~ChromeContentBrowserClientPluginsPart() { |
+} |
+ |
+void ChromeContentBrowserClientPluginsPart::RenderProcessWillLaunch( |
+ content::RenderProcessHost* host) { |
+ int id = host->GetID(); |
Lei Zhang
2014/12/04 22:59:43
You can just put this in line 36, since the variou
Jitu( very slow this week)
2014/12/05 05:39:31
Done.
|
+ Profile* profile = Profile::FromBrowserContext(host->GetBrowserContext()); |
+ host->AddFilter(new PluginInfoMessageFilter(id, profile)); |
+} |
+ |
+bool ChromeContentBrowserClientPluginsPart:: |
+ IsPluginAllowedToCallRequestOSFileHandle( |
+ content::BrowserContext* browser_context, |
+ const GURL& url, |
+ const std::set<std::string>& allowed_file_handle_origins) { |
+ Profile* profile = Profile::FromBrowserContext(browser_context); |
+ const extensions::ExtensionSet* extension_set = NULL; |
Lei Zhang
2014/12/04 22:59:43
I don't think there's any standard build configura
Jitu( very slow this week)
2014/12/05 05:39:31
So for in this function you mean to say if extensi
Lei Zhang
2014/12/05 05:45:47
Sure, and you need to look through the other funct
|
+ if (profile) { |
+ extension_set = |
+ &extensions::ExtensionRegistry::Get(profile)->enabled_extensions(); |
+ } |
+ |
+ return chrome::IsExtensionOrSharedModuleWhitelisted( |
+ url, extension_set, allowed_file_handle_origins) || |
+ chrome::IsHostAllowedByCommandLine( |
+ url, extension_set, ::switches::kAllowNaClFileHandleAPI); |
+} |
+ |
+bool ChromeContentBrowserClientPluginsPart::AllowPepperSocketAPI( |
+ content::BrowserContext* browser_context, |
+ const GURL& url, |
+ bool private_api, |
+ const content::SocketPermissionRequest* params, |
+ const std::set<std::string>& allowed_socket_origin) { |
+ 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 (chrome::IsExtensionOrSharedModuleWhitelisted(url, extension_set, |
+ allowed_socket_origin)) { |
+ 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 chrome::IsHostAllowedByCommandLine(url, extension_set, |
+ ::switches::kAllowNaClSocketAPI); |
+} |
+ |
+bool ChromeContentBrowserClientPluginsPart::IsPluginAllowedToUseDevChannelAPIs( |
+ content::BrowserContext* browser_context, |
+ const GURL& url, |
+ const std::set<std::string>& allowed_dev_channel_origins) { |
+ 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 (chrome::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; |
+} |
+ |
+void ChromeContentBrowserClientPluginsPart::DidCreatePpapiPlugin( |
+ content::BrowserPpapiHost* browser_host) { |
+ browser_host->GetPpapiHost()->AddHostFactoryFilter( |
+ scoped_ptr<ppapi::host::HostFactory>( |
+ new chrome::ChromeBrowserPepperHostFactory(browser_host))); |
+} |
+ |
+} // namespace plugins |