ppapi flash plugin support
authordeepak1556 <hop2deep@gmail.com>
Tue, 28 Apr 2015 15:45:58 +0000 (21:15 +0530)
committerdeepak1556 <hop2deep@gmail.com>
Sun, 10 May 2015 03:52:09 +0000 (09:22 +0530)
35 files changed:
atom/app/atom_content_client.cc
atom/app/atom_content_client.h
atom/browser/atom_browser_client.cc
atom/browser/atom_browser_client.h
atom/common/options_switches.cc
atom/common/options_switches.h
atom/renderer/atom_renderer_client.cc
atom/renderer/atom_renderer_client.h
chromium_src/chrome/browser/renderer_host/pepper/chrome_browser_pepper_host_factory.cc [new file with mode: 0644]
chromium_src/chrome/browser/renderer_host/pepper/chrome_browser_pepper_host_factory.h [new file with mode: 0644]
chromium_src/chrome/browser/renderer_host/pepper/pepper_broker_message_filter.cc [new file with mode: 0644]
chromium_src/chrome/browser/renderer_host/pepper/pepper_broker_message_filter.h [new file with mode: 0644]
chromium_src/chrome/browser/renderer_host/pepper/pepper_flash_browser_host.cc [new file with mode: 0644]
chromium_src/chrome/browser/renderer_host/pepper/pepper_flash_browser_host.h [new file with mode: 0644]
chromium_src/chrome/browser/renderer_host/pepper/pepper_flash_clipboard_message_filter.cc [new file with mode: 0644]
chromium_src/chrome/browser/renderer_host/pepper/pepper_flash_clipboard_message_filter.h [new file with mode: 0644]
chromium_src/chrome/browser/renderer_host/pepper/pepper_isolated_file_system_message_filter.cc [new file with mode: 0644]
chromium_src/chrome/browser/renderer_host/pepper/pepper_isolated_file_system_message_filter.h [new file with mode: 0644]
chromium_src/chrome/renderer/pepper/chrome_renderer_pepper_host_factory.cc [new file with mode: 0644]
chromium_src/chrome/renderer/pepper/chrome_renderer_pepper_host_factory.h [new file with mode: 0644]
chromium_src/chrome/renderer/pepper/pepper_flash_drm_renderer_host.cc [new file with mode: 0644]
chromium_src/chrome/renderer/pepper/pepper_flash_drm_renderer_host.h [new file with mode: 0644]
chromium_src/chrome/renderer/pepper/pepper_flash_font_file_host.cc [new file with mode: 0644]
chromium_src/chrome/renderer/pepper/pepper_flash_font_file_host.h [new file with mode: 0644]
chromium_src/chrome/renderer/pepper/pepper_flash_fullscreen_host.cc [new file with mode: 0644]
chromium_src/chrome/renderer/pepper/pepper_flash_fullscreen_host.h [new file with mode: 0644]
chromium_src/chrome/renderer/pepper/pepper_flash_menu_host.cc [new file with mode: 0644]
chromium_src/chrome/renderer/pepper/pepper_flash_menu_host.h [new file with mode: 0644]
chromium_src/chrome/renderer/pepper/pepper_flash_renderer_host.cc [new file with mode: 0644]
chromium_src/chrome/renderer/pepper/pepper_flash_renderer_host.h [new file with mode: 0644]
chromium_src/chrome/renderer/pepper/pepper_helper.cc [new file with mode: 0644]
chromium_src/chrome/renderer/pepper/pepper_helper.h [new file with mode: 0644]
chromium_src/chrome/renderer/pepper/pepper_shared_memory_message_filter.cc [new file with mode: 0644]
chromium_src/chrome/renderer/pepper/pepper_shared_memory_message_filter.h [new file with mode: 0644]
filenames.gypi

index f4beeb5..5d97fe5 100644 (file)
@@ -8,9 +8,65 @@
 #include <vector>
 
 #include "atom/common/chrome_version.h"
+#include "atom/common/options_switches.h"
+#include "base/command_line.h"
+#include "base/strings/string_split.h"
+#include "base/strings/string_util.h"
+#include "content/public/common/content_constants.h"
+#include "content/public/common/pepper_plugin_info.h"
+#include "ppapi/shared_impl/ppapi_permissions.h"
 
 namespace atom {
 
+int32 kPepperFlashPermissions = ppapi::PERMISSION_DEV |
+                                ppapi::PERMISSION_PRIVATE |
+                                ppapi::PERMISSION_BYPASS_USER_GESTURE |
+                                ppapi::PERMISSION_FLASH;
+
+namespace {
+
+  content::PepperPluginInfo CreatePepperFlashInfo(const base::FilePath& path,
+                                                  const std::string& version) {
+    content::PepperPluginInfo plugin;
+
+    plugin.is_out_of_process = true;
+    plugin.name = content::kFlashPluginName;
+    plugin.path = path;
+    plugin.permissions = kPepperFlashPermissions;
+
+    std::vector<std::string> flash_version_numbers;
+    base::SplitString(version, '.', &flash_version_numbers);
+    if (flash_version_numbers.size() < 1)
+      flash_version_numbers.push_back("11");
+    // |SplitString()| puts in an empty string given an empty string. :(
+    else if (flash_version_numbers[0].empty())
+      flash_version_numbers[0] = "11";
+    if (flash_version_numbers.size() < 2)
+      flash_version_numbers.push_back("2");
+    if (flash_version_numbers.size() < 3)
+      flash_version_numbers.push_back("999");
+    if (flash_version_numbers.size() < 4)
+      flash_version_numbers.push_back("999");
+    // E.g., "Shockwave Flash 10.2 r154":
+    plugin.description = plugin.name + " " + flash_version_numbers[0] + "." +
+        flash_version_numbers[1] + " r" + flash_version_numbers[2];
+    plugin.version = JoinString(flash_version_numbers, '.');
+    content::WebPluginMimeType swf_mime_type(
+        content::kFlashPluginSwfMimeType,
+        content::kFlashPluginSwfExtension,
+        content::kFlashPluginSwfDescription);
+    plugin.mime_types.push_back(swf_mime_type);
+    content::WebPluginMimeType spl_mime_type(
+        content::kFlashPluginSplMimeType,
+        content::kFlashPluginSplExtension,
+        content::kFlashPluginSplDescription);
+    plugin.mime_types.push_back(spl_mime_type);
+
+    return plugin;
+  }
+
+}  // namespace
+
 AtomContentClient::AtomContentClient() {
 }
 
@@ -27,4 +83,17 @@ void AtomContentClient::AddAdditionalSchemes(
   standard_schemes->push_back("chrome-extension");
 }
 
+void AtomContentClient::AddPepperPlugins(
+  std::vector<content::PepperPluginInfo>* plugins) {
+  const base::CommandLine::StringType flash_path =
+      base::CommandLine::ForCurrentProcess()->GetSwitchValueNative(
+          switches::kPpapiFlashPath);
+  if (flash_path.empty())
+    return;
+
+  std::string flash_version;
+  plugins->push_back(
+      CreatePepperFlashInfo(base::FilePath(flash_path), flash_version));
+}
+
 }  // namespace atom
index 732ac35..279ec71 100644 (file)
@@ -23,6 +23,8 @@ class AtomContentClient : public brightray::ContentClient {
   void AddAdditionalSchemes(
       std::vector<std::string>* standard_schemes,
       std::vector<std::string>* savable_schemes) override;
+  void AddPepperPlugins(
+      std::vector<content::PepperPluginInfo>* plugins) override;
 
  private:
   DISALLOW_COPY_AND_ASSIGN(AtomContentClient);
index c897d5d..69ae0d3 100644 (file)
 #include "base/command_line.h"
 #include "base/strings/string_number_conversions.h"
 #include "chrome/browser/printing/printing_message_filter.h"
+#include "chrome/browser/renderer_host/pepper/chrome_browser_pepper_host_factory.h"
 #include "chrome/browser/speech/tts_message_filter.h"
+#include "content/public/browser/browser_ppapi_host.h"
 #include "content/public/browser/render_process_host.h"
 #include "content/public/browser/render_view_host.h"
 #include "content/public/browser/resource_dispatcher_host.h"
 #include "content/public/browser/site_instance.h"
 #include "content/public/browser/web_contents.h"
 #include "content/public/common/web_preferences.h"
+#include "ppapi/host/ppapi_host.h"
 #include "ui/base/l10n/l10n_util.h"
 
 namespace atom {
@@ -197,6 +200,13 @@ void AtomBrowserClient::AppendExtraCommandLineSwitches(
   dying_render_process_ = nullptr;
 }
 
+void AtomBrowserClient::DidCreatePpapiPlugin(
+    content::BrowserPpapiHost* browser_host) {
+  browser_host->GetPpapiHost()->AddHostFactoryFilter(
+    scoped_ptr<ppapi::host::HostFactory>(
+      new chrome::ChromeBrowserPepperHostFactory(browser_host)));
+}
+
 brightray::BrowserMainParts* AtomBrowserClient::OverrideCreateBrowserMainParts(
     const content::MainFunctionParams&) {
   v8::V8::Initialize();  // Init V8 before creating main parts.
index 629ac96..cda0bd8 100644 (file)
@@ -35,6 +35,7 @@ class AtomBrowserClient : public brightray::BrowserClient {
       content::SiteInstance** new_instance);
   void AppendExtraCommandLineSwitches(base::CommandLine* command_line,
                                       int child_process_id) override;
+  void DidCreatePpapiPlugin(content::BrowserPpapiHost* browser_host) override;
 
  private:
   brightray::BrowserMainParts* OverrideCreateBrowserMainParts(
index c479b50..37daa89 100644 (file)
@@ -63,6 +63,9 @@ const char kDirectWrite[] = "direct-write";
 // Enable plugins.
 const char kEnablePlugins[] = "enable-plugins";
 
+// Ppapi Flash path.
+const char kPpapiFlashPath[] = "ppapi-flash-path";
+
 // Instancd ID of guest WebContents.
 const char kGuestInstanceID[] = "guest-instance-id";
 
index 546c6a0..d6f8c07 100644 (file)
@@ -37,6 +37,7 @@ extern const char kEnableLargerThanScreen[];
 extern const char kDarkTheme[];
 extern const char kDirectWrite[];
 extern const char kEnablePlugins[];
+extern const char kPpapiFlashPath[];
 extern const char kGuestInstanceID[];
 extern const char kPreloadScript[];
 extern const char kTransparent[];
index cc48bc0..d90a90b 100644 (file)
@@ -11,6 +11,7 @@
 #include "atom/common/options_switches.h"
 #include "atom/renderer/atom_render_view_observer.h"
 #include "atom/renderer/guest_view_container.h"
+#include "chrome/renderer/pepper/pepper_helper.h"
 #include "chrome/renderer/printing/print_web_view_helper.h"
 #include "chrome/renderer/tts_dispatcher.h"
 #include "content/public/common/content_constants.h"
@@ -79,6 +80,11 @@ void AtomRendererClient::RenderThreadStarted() {
   content::RenderThread::Get()->AddObserver(this);
 }
 
+void AtomRendererClient::RenderFrameCreated(
+    content::RenderFrame* render_frame) {
+  new PepperHelper(render_frame);
+}
+
 void AtomRendererClient::RenderViewCreated(content::RenderView* render_view) {
   new printing::PrintWebViewHelper(render_view);
   new AtomRenderViewObserver(render_view, this);
index 4aba42c..a709612 100644 (file)
@@ -34,6 +34,7 @@ class AtomRendererClient : public content::ContentRendererClient,
 
   // content::ContentRendererClient:
   void RenderThreadStarted() override;
+  void RenderFrameCreated(content::RenderFrame*) override;
   void RenderViewCreated(content::RenderView*) override;
   blink::WebSpeechSynthesizer* OverrideSpeechSynthesizer(
       blink::WebSpeechSynthesizerClient* client) override;
diff --git a/chromium_src/chrome/browser/renderer_host/pepper/chrome_browser_pepper_host_factory.cc b/chromium_src/chrome/browser/renderer_host/pepper/chrome_browser_pepper_host_factory.cc
new file mode 100644 (file)
index 0000000..03d706f
--- /dev/null
@@ -0,0 +1,94 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/renderer_host/pepper/chrome_browser_pepper_host_factory.h"
+
+#include "build/build_config.h"
+#include "chrome/browser/renderer_host/pepper/pepper_broker_message_filter.h"
+#include "chrome/browser/renderer_host/pepper/pepper_flash_browser_host.h"
+#include "chrome/browser/renderer_host/pepper/pepper_flash_clipboard_message_filter.h"
+#include "chrome/browser/renderer_host/pepper/pepper_isolated_file_system_message_filter.h"
+#include "content/public/browser/browser_ppapi_host.h"
+#include "ppapi/host/message_filter_host.h"
+#include "ppapi/host/ppapi_host.h"
+#include "ppapi/host/resource_host.h"
+#include "ppapi/proxy/ppapi_messages.h"
+#include "ppapi/shared_impl/ppapi_permissions.h"
+
+using ppapi::host::MessageFilterHost;
+using ppapi::host::ResourceHost;
+using ppapi::host::ResourceMessageFilter;
+
+namespace chrome {
+
+ChromeBrowserPepperHostFactory::ChromeBrowserPepperHostFactory(
+    content::BrowserPpapiHost* host)
+    : host_(host) {}
+
+ChromeBrowserPepperHostFactory::~ChromeBrowserPepperHostFactory() {}
+
+scoped_ptr<ResourceHost> ChromeBrowserPepperHostFactory::CreateResourceHost(
+    ppapi::host::PpapiHost* host,
+    PP_Resource resource,
+    PP_Instance instance,
+    const IPC::Message& message) {
+  DCHECK(host == host_->GetPpapiHost());
+
+  // Make sure the plugin is giving us a valid instance for this resource.
+  if (!host_->IsValidInstance(instance))
+    return scoped_ptr<ResourceHost>();
+
+  // Private interfaces.
+  if (host_->GetPpapiHost()->permissions().HasPermission(
+          ppapi::PERMISSION_PRIVATE)) {
+    switch (message.type()) {
+      case PpapiHostMsg_Broker_Create::ID: {
+        scoped_refptr<ResourceMessageFilter> broker_filter(
+            new PepperBrokerMessageFilter(instance, host_));
+        return scoped_ptr<ResourceHost>(new MessageFilterHost(
+            host_->GetPpapiHost(), instance, resource, broker_filter));
+      }
+    }
+  }
+
+  // Flash interfaces.
+  if (host_->GetPpapiHost()->permissions().HasPermission(
+          ppapi::PERMISSION_FLASH)) {
+    switch (message.type()) {
+      case PpapiHostMsg_Flash_Create::ID:
+        return scoped_ptr<ResourceHost>(
+            new PepperFlashBrowserHost(host_, instance, resource));
+      case PpapiHostMsg_FlashClipboard_Create::ID: {
+        scoped_refptr<ResourceMessageFilter> clipboard_filter(
+            new PepperFlashClipboardMessageFilter);
+        return scoped_ptr<ResourceHost>(new MessageFilterHost(
+            host_->GetPpapiHost(), instance, resource, clipboard_filter));
+      }
+#if 0
+    case PpapiHostMsg_FlashDRM_Create::ID:
+        return scoped_ptr<ResourceHost>(
+            new PepperFlashDRMHost(host_, instance, resource));
+#endif
+    }
+  }
+
+  // Permissions for the following interfaces will be checked at the
+  // time of the corresponding instance's methods calls (because
+  // permission check can be performed only on the UI
+  // thread). Currently these interfaces are available only for
+  // whitelisted apps which may not have access to the other private
+  // interfaces.
+  if (message.type() == PpapiHostMsg_IsolatedFileSystem_Create::ID) {
+    PepperIsolatedFileSystemMessageFilter* isolated_fs_filter =
+        PepperIsolatedFileSystemMessageFilter::Create(instance, host_);
+    if (!isolated_fs_filter)
+      return scoped_ptr<ResourceHost>();
+    return scoped_ptr<ResourceHost>(
+        new MessageFilterHost(host, instance, resource, isolated_fs_filter));
+  }
+
+  return scoped_ptr<ResourceHost>();
+}
+
+}  // namespace chrome
diff --git a/chromium_src/chrome/browser/renderer_host/pepper/chrome_browser_pepper_host_factory.h b/chromium_src/chrome/browser/renderer_host/pepper/chrome_browser_pepper_host_factory.h
new file mode 100644 (file)
index 0000000..b817953
--- /dev/null
@@ -0,0 +1,38 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_RENDERER_HOST_PEPPER_CHROME_BROWSER_PEPPER_HOST_FACTORY_H_
+#define CHROME_BROWSER_RENDERER_HOST_PEPPER_CHROME_BROWSER_PEPPER_HOST_FACTORY_H_
+
+#include "base/compiler_specific.h"
+#include "ppapi/host/host_factory.h"
+
+namespace content {
+class BrowserPpapiHost;
+}  // namespace content
+
+namespace chrome {
+
+class ChromeBrowserPepperHostFactory : public ppapi::host::HostFactory {
+ public:
+  // Non-owning pointer to the filter must outlive this class.
+  explicit ChromeBrowserPepperHostFactory(content::BrowserPpapiHost* host);
+  ~ChromeBrowserPepperHostFactory() override;
+
+  scoped_ptr<ppapi::host::ResourceHost> CreateResourceHost(
+      ppapi::host::PpapiHost* host,
+      PP_Resource resource,
+      PP_Instance instance,
+      const IPC::Message& message) override;
+
+ private:
+  // Non-owning pointer.
+  content::BrowserPpapiHost* host_;
+
+  DISALLOW_COPY_AND_ASSIGN(ChromeBrowserPepperHostFactory);
+};
+
+}  // namespace chrome
+
+#endif  // CHROME_BROWSER_RENDERER_HOST_PEPPER_CHROME_BROWSER_PEPPER_HOST_FACTORY_H_
diff --git a/chromium_src/chrome/browser/renderer_host/pepper/pepper_broker_message_filter.cc b/chromium_src/chrome/browser/renderer_host/pepper/pepper_broker_message_filter.cc
new file mode 100644 (file)
index 0000000..224b55d
--- /dev/null
@@ -0,0 +1,54 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/renderer_host/pepper/pepper_broker_message_filter.h"
+
+#include <string>
+
+#include "content/public/browser/browser_ppapi_host.h"
+#include "content/public/browser/browser_thread.h"
+#include "content/public/browser/render_process_host.h"
+#include "ipc/ipc_message_macros.h"
+#include "ppapi/c/pp_errors.h"
+#include "ppapi/host/dispatch_host_message.h"
+#include "ppapi/proxy/ppapi_messages.h"
+#include "url/gurl.h"
+
+using content::BrowserPpapiHost;
+using content::BrowserThread;
+using content::RenderProcessHost;
+
+namespace chrome {
+
+PepperBrokerMessageFilter::PepperBrokerMessageFilter(PP_Instance instance,
+                                                     BrowserPpapiHost* host)
+    : document_url_(host->GetDocumentURLForInstance(instance)) {
+  int unused;
+  host->GetRenderFrameIDsForInstance(instance, &render_process_id_, &unused);
+}
+
+PepperBrokerMessageFilter::~PepperBrokerMessageFilter() {}
+
+scoped_refptr<base::TaskRunner>
+PepperBrokerMessageFilter::OverrideTaskRunnerForMessage(
+    const IPC::Message& message) {
+  return BrowserThread::GetMessageLoopProxyForThread(BrowserThread::UI);
+}
+
+int32_t PepperBrokerMessageFilter::OnResourceMessageReceived(
+    const IPC::Message& msg,
+    ppapi::host::HostMessageContext* context) {
+  PPAPI_BEGIN_MESSAGE_MAP(PepperBrokerMessageFilter, msg)
+    PPAPI_DISPATCH_HOST_RESOURCE_CALL_0(PpapiHostMsg_Broker_IsAllowed,
+                                        OnIsAllowed)
+  PPAPI_END_MESSAGE_MAP()
+  return PP_ERROR_FAILED;
+}
+
+int32_t PepperBrokerMessageFilter::OnIsAllowed(
+    ppapi::host::HostMessageContext* context) {
+  return PP_OK;
+}
+
+}  // namespace chrome
diff --git a/chromium_src/chrome/browser/renderer_host/pepper/pepper_broker_message_filter.h b/chromium_src/chrome/browser/renderer_host/pepper/pepper_broker_message_filter.h
new file mode 100644 (file)
index 0000000..44627c6
--- /dev/null
@@ -0,0 +1,51 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_RENDERER_HOST_PEPPER_PEPPER_BROKER_MESSAGE_FILTER_H_
+#define CHROME_BROWSER_RENDERER_HOST_PEPPER_PEPPER_BROKER_MESSAGE_FILTER_H_
+
+#include "base/compiler_specific.h"
+#include "ppapi/c/pp_instance.h"
+#include "ppapi/host/resource_message_filter.h"
+#include "url/gurl.h"
+
+namespace content {
+class BrowserPpapiHost;
+}
+
+namespace ppapi {
+namespace host {
+struct HostMessageContext;
+}
+}
+
+namespace chrome {
+
+// This filter handles messages for the PepperBrokerHost on the UI thread.
+class PepperBrokerMessageFilter : public ppapi::host::ResourceMessageFilter {
+ public:
+  PepperBrokerMessageFilter(PP_Instance instance,
+                            content::BrowserPpapiHost* host);
+
+ private:
+  ~PepperBrokerMessageFilter() override;
+
+  // ppapi::host::ResourceMessageFilter overrides.
+  scoped_refptr<base::TaskRunner> OverrideTaskRunnerForMessage(
+      const IPC::Message& message) override;
+  int32_t OnResourceMessageReceived(
+      const IPC::Message& msg,
+      ppapi::host::HostMessageContext* context) override;
+
+  int32_t OnIsAllowed(ppapi::host::HostMessageContext* context);
+
+  int render_process_id_;
+  GURL document_url_;
+
+  DISALLOW_COPY_AND_ASSIGN(PepperBrokerMessageFilter);
+};
+
+}  // namespace chrome
+
+#endif  // CHROME_BROWSER_RENDERER_HOST_PEPPER_PEPPER_BROKER_MESSAGE_FILTER_H_
diff --git a/chromium_src/chrome/browser/renderer_host/pepper/pepper_flash_browser_host.cc b/chromium_src/chrome/browser/renderer_host/pepper/pepper_flash_browser_host.cc
new file mode 100644 (file)
index 0000000..43179c6
--- /dev/null
@@ -0,0 +1,114 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/renderer_host/pepper/pepper_flash_browser_host.h"
+
+#include "base/time/time.h"
+#include "content/public/browser/browser_context.h"
+#include "content/public/browser/browser_ppapi_host.h"
+#include "content/public/browser/browser_thread.h"
+#include "content/public/browser/render_process_host.h"
+#include "ipc/ipc_message_macros.h"
+#include "ppapi/c/pp_errors.h"
+#include "ppapi/c/private/ppb_flash.h"
+#include "ppapi/host/dispatch_host_message.h"
+#include "ppapi/proxy/ppapi_messages.h"
+#include "ppapi/proxy/resource_message_params.h"
+#include "ppapi/shared_impl/time_conversion.h"
+#include "url/gurl.h"
+
+#if defined(OS_WIN)
+#include <windows.h>
+#elif defined(OS_MACOSX)
+#include <CoreServices/CoreServices.h>
+#endif
+
+using content::BrowserPpapiHost;
+using content::BrowserThread;
+using content::RenderProcessHost;
+
+namespace chrome {
+
+PepperFlashBrowserHost::PepperFlashBrowserHost(BrowserPpapiHost* host,
+                                               PP_Instance instance,
+                                               PP_Resource resource)
+    : ResourceHost(host->GetPpapiHost(), instance, resource),
+      host_(host),
+      weak_factory_(this) {
+  int unused;
+  host->GetRenderFrameIDsForInstance(instance, &render_process_id_, &unused);
+}
+
+PepperFlashBrowserHost::~PepperFlashBrowserHost() {}
+
+int32_t PepperFlashBrowserHost::OnResourceMessageReceived(
+    const IPC::Message& msg,
+    ppapi::host::HostMessageContext* context) {
+  PPAPI_BEGIN_MESSAGE_MAP(PepperFlashBrowserHost, msg)
+    PPAPI_DISPATCH_HOST_RESOURCE_CALL_0(PpapiHostMsg_Flash_UpdateActivity,
+                                        OnUpdateActivity)
+    PPAPI_DISPATCH_HOST_RESOURCE_CALL(PpapiHostMsg_Flash_GetLocalTimeZoneOffset,
+                                      OnGetLocalTimeZoneOffset)
+    PPAPI_DISPATCH_HOST_RESOURCE_CALL_0(
+        PpapiHostMsg_Flash_GetLocalDataRestrictions, OnGetLocalDataRestrictions)
+  PPAPI_END_MESSAGE_MAP()
+  return PP_ERROR_FAILED;
+}
+
+int32_t PepperFlashBrowserHost::OnUpdateActivity(
+    ppapi::host::HostMessageContext* host_context) {
+#if defined(OS_WIN)
+  // Reading then writing back the same value to the screensaver timeout system
+  // setting resets the countdown which prevents the screensaver from turning
+  // on "for a while". As long as the plugin pings us with this message faster
+  // than the screensaver timeout, it won't go on.
+  int value = 0;
+  if (SystemParametersInfo(SPI_GETSCREENSAVETIMEOUT, 0, &value, 0))
+    SystemParametersInfo(SPI_SETSCREENSAVETIMEOUT, value, NULL, 0);
+#elif defined(OS_MACOSX)
+// UpdateSystemActivity(OverallAct);
+#else
+// TODO(brettw) implement this for other platforms.
+#endif
+  return PP_OK;
+}
+
+int32_t PepperFlashBrowserHost::OnGetLocalTimeZoneOffset(
+    ppapi::host::HostMessageContext* host_context,
+    const base::Time& t) {
+  // The reason for this processing being in the browser process is that on
+  // Linux, the localtime calls require filesystem access prohibited by the
+  // sandbox.
+  host_context->reply_msg = PpapiPluginMsg_Flash_GetLocalTimeZoneOffsetReply(
+      ppapi::PPGetLocalTimeZoneOffset(t));
+  return PP_OK;
+}
+
+int32_t PepperFlashBrowserHost::OnGetLocalDataRestrictions(
+    ppapi::host::HostMessageContext* context) {
+  // Getting the Flash LSO settings requires using the CookieSettings which
+  // belong to the profile which lives on the UI thread. We lazily initialize
+  // |cookie_settings_| by grabbing the reference from the UI thread and then
+  // call |GetLocalDataRestrictions| with it.
+  GURL document_url = host_->GetDocumentURLForInstance(pp_instance());
+  GURL plugin_url = host_->GetPluginURLForInstance(pp_instance());
+  GetLocalDataRestrictions(context->MakeReplyMessageContext(),
+                           document_url,
+                           plugin_url);
+  return PP_OK_COMPLETIONPENDING;
+}
+
+void PepperFlashBrowserHost::GetLocalDataRestrictions(
+    ppapi::host::ReplyMessageContext reply_context,
+    const GURL& document_url,
+    const GURL& plugin_url) {
+  DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
+
+  PP_FlashLSORestrictions restrictions = PP_FLASHLSORESTRICTIONS_NONE;
+  SendReply(reply_context,
+            PpapiPluginMsg_Flash_GetLocalDataRestrictionsReply(
+                static_cast<int32_t>(restrictions)));
+}
+
+}  // namespace chrome
diff --git a/chromium_src/chrome/browser/renderer_host/pepper/pepper_flash_browser_host.h b/chromium_src/chrome/browser/renderer_host/pepper/pepper_flash_browser_host.h
new file mode 100644 (file)
index 0000000..6fb4ace
--- /dev/null
@@ -0,0 +1,60 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_RENDERER_HOST_PEPPER_PEPPER_FLASH_BROWSER_HOST_H_
+#define CHROME_BROWSER_RENDERER_HOST_PEPPER_PEPPER_FLASH_BROWSER_HOST_H_
+
+#include "base/basictypes.h"
+#include "base/memory/ref_counted.h"
+#include "base/memory/weak_ptr.h"
+#include "ppapi/host/host_message_context.h"
+#include "ppapi/host/resource_host.h"
+
+namespace base {
+class Time;
+}
+
+namespace content {
+class BrowserPpapiHost;
+class ResourceContext;
+}
+
+class GURL;
+
+namespace chrome {
+
+class PepperFlashBrowserHost : public ppapi::host::ResourceHost {
+ public:
+  PepperFlashBrowserHost(content::BrowserPpapiHost* host,
+                         PP_Instance instance,
+                         PP_Resource resource);
+  ~PepperFlashBrowserHost() override;
+
+  // ppapi::host::ResourceHost override.
+  int32_t OnResourceMessageReceived(
+      const IPC::Message& msg,
+      ppapi::host::HostMessageContext* context) override;
+
+ private:
+  int32_t OnUpdateActivity(ppapi::host::HostMessageContext* host_context);
+  int32_t OnGetLocalTimeZoneOffset(
+      ppapi::host::HostMessageContext* host_context,
+      const base::Time& t);
+  int32_t OnGetLocalDataRestrictions(ppapi::host::HostMessageContext* context);
+
+  void GetLocalDataRestrictions(ppapi::host::ReplyMessageContext reply_context,
+                                const GURL& document_url,
+                                const GURL& plugin_url);
+
+  content::BrowserPpapiHost* host_;
+  int render_process_id_;
+  // For fetching the Flash LSO settings.
+  base::WeakPtrFactory<PepperFlashBrowserHost> weak_factory_;
+
+  DISALLOW_COPY_AND_ASSIGN(PepperFlashBrowserHost);
+};
+
+}  // namespace chrome
+
+#endif  // CHROME_BROWSER_RENDERER_HOST_PEPPER_PEPPER_FLASH_BROWSER_HOST_H_
diff --git a/chromium_src/chrome/browser/renderer_host/pepper/pepper_flash_clipboard_message_filter.cc b/chromium_src/chrome/browser/renderer_host/pepper/pepper_flash_clipboard_message_filter.cc
new file mode 100644 (file)
index 0000000..4499b21
--- /dev/null
@@ -0,0 +1,376 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/renderer_host/pepper/pepper_flash_clipboard_message_filter.h"
+
+#include "base/pickle.h"
+#include "base/strings/utf_string_conversions.h"
+#include "content/public/browser/browser_thread.h"
+#include "ipc/ipc_message.h"
+#include "ipc/ipc_message_macros.h"
+#include "ppapi/c/pp_errors.h"
+#include "ppapi/c/private/ppb_flash_clipboard.h"
+#include "ppapi/host/dispatch_host_message.h"
+#include "ppapi/host/host_message_context.h"
+#include "ppapi/host/ppapi_host.h"
+#include "ppapi/proxy/ppapi_messages.h"
+#include "ppapi/proxy/resource_message_params.h"
+#include "ui/base/clipboard/scoped_clipboard_writer.h"
+
+using content::BrowserThread;
+
+namespace chrome {
+
+namespace {
+
+const size_t kMaxClipboardWriteSize = 1000000;
+
+ui::ClipboardType ConvertClipboardType(uint32_t type) {
+  switch (type) {
+    case PP_FLASH_CLIPBOARD_TYPE_STANDARD:
+      return ui::CLIPBOARD_TYPE_COPY_PASTE;
+    case PP_FLASH_CLIPBOARD_TYPE_SELECTION:
+      return ui::CLIPBOARD_TYPE_SELECTION;
+  }
+  NOTREACHED();
+  return ui::CLIPBOARD_TYPE_COPY_PASTE;
+}
+
+// Functions to pack/unpack custom data from a pickle. See the header file for
+// more detail on custom formats in Pepper.
+// TODO(raymes): Currently pepper custom formats are stored in their own
+// native format type. However we should be able to store them in the same way
+// as "Web Custom" formats are. This would allow clipboard data to be shared
+// between pepper applications and web applications. However currently web apps
+// assume all data that is placed on the clipboard is UTF16 and pepper allows
+// arbitrary data so this change would require some reworking of the chrome
+// clipboard interface for custom data.
+bool JumpToFormatInPickle(const base::string16& format, PickleIterator* iter) {
+  size_t size = 0;
+  if (!iter->ReadSizeT(&size))
+    return false;
+  for (size_t i = 0; i < size; ++i) {
+    base::string16 stored_format;
+    if (!iter->ReadString16(&stored_format))
+      return false;
+    if (stored_format == format)
+      return true;
+    int skip_length;
+    if (!iter->ReadLength(&skip_length))
+      return false;
+    if (!iter->SkipBytes(skip_length))
+      return false;
+  }
+  return false;
+}
+
+bool IsFormatAvailableInPickle(const base::string16& format,
+                               const Pickle& pickle) {
+  PickleIterator iter(pickle);
+  return JumpToFormatInPickle(format, &iter);
+}
+
+std::string ReadDataFromPickle(const base::string16& format,
+                               const Pickle& pickle) {
+  std::string result;
+  PickleIterator iter(pickle);
+  if (!JumpToFormatInPickle(format, &iter) || !iter.ReadString(&result))
+    return std::string();
+  return result;
+}
+
+bool WriteDataToPickle(const std::map<base::string16, std::string>& data,
+                       Pickle* pickle) {
+  pickle->WriteSizeT(data.size());
+  for (std::map<base::string16, std::string>::const_iterator it = data.begin();
+       it != data.end();
+       ++it) {
+    if (!pickle->WriteString16(it->first))
+      return false;
+    if (!pickle->WriteString(it->second))
+      return false;
+  }
+  return true;
+}
+
+}  // namespace
+
+PepperFlashClipboardMessageFilter::PepperFlashClipboardMessageFilter() {}
+
+PepperFlashClipboardMessageFilter::~PepperFlashClipboardMessageFilter() {}
+
+scoped_refptr<base::TaskRunner>
+PepperFlashClipboardMessageFilter::OverrideTaskRunnerForMessage(
+    const IPC::Message& msg) {
+  // Clipboard writes should always occur on the UI thread due to the
+  // restrictions of various platform APIs. In general, the clipboard is not
+  // thread-safe, so all clipboard calls should be serviced from the UI thread.
+  if (msg.type() == PpapiHostMsg_FlashClipboard_WriteData::ID)
+    return BrowserThread::GetMessageLoopProxyForThread(BrowserThread::UI);
+
+// Windows needs clipboard reads to be serviced from the IO thread because
+// these are sync IPCs which can result in deadlocks with plugins if serviced
+// from the UI thread. Note that Windows clipboard calls ARE thread-safe so it
+// is ok for reads and writes to be serviced from different threads.
+#if !defined(OS_WIN)
+  return BrowserThread::GetMessageLoopProxyForThread(BrowserThread::UI);
+#else
+  return BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO);
+#endif
+}
+
+int32_t PepperFlashClipboardMessageFilter::OnResourceMessageReceived(
+    const IPC::Message& msg,
+    ppapi::host::HostMessageContext* context) {
+  PPAPI_BEGIN_MESSAGE_MAP(PepperFlashClipboardMessageFilter, msg)
+    PPAPI_DISPATCH_HOST_RESOURCE_CALL(
+        PpapiHostMsg_FlashClipboard_RegisterCustomFormat,
+        OnMsgRegisterCustomFormat)
+    PPAPI_DISPATCH_HOST_RESOURCE_CALL(
+        PpapiHostMsg_FlashClipboard_IsFormatAvailable, OnMsgIsFormatAvailable)
+    PPAPI_DISPATCH_HOST_RESOURCE_CALL(PpapiHostMsg_FlashClipboard_ReadData,
+                                      OnMsgReadData)
+    PPAPI_DISPATCH_HOST_RESOURCE_CALL(PpapiHostMsg_FlashClipboard_WriteData,
+                                      OnMsgWriteData)
+    PPAPI_DISPATCH_HOST_RESOURCE_CALL(
+        PpapiHostMsg_FlashClipboard_GetSequenceNumber, OnMsgGetSequenceNumber)
+  PPAPI_END_MESSAGE_MAP()
+  return PP_ERROR_FAILED;
+}
+
+int32_t PepperFlashClipboardMessageFilter::OnMsgRegisterCustomFormat(
+    ppapi::host::HostMessageContext* host_context,
+    const std::string& format_name) {
+  uint32_t format = custom_formats_.RegisterFormat(format_name);
+  if (format == PP_FLASH_CLIPBOARD_FORMAT_INVALID)
+    return PP_ERROR_FAILED;
+  host_context->reply_msg =
+      PpapiPluginMsg_FlashClipboard_RegisterCustomFormatReply(format);
+  return PP_OK;
+}
+
+int32_t PepperFlashClipboardMessageFilter::OnMsgIsFormatAvailable(
+    ppapi::host::HostMessageContext* host_context,
+    uint32_t clipboard_type,
+    uint32_t format) {
+  if (clipboard_type != PP_FLASH_CLIPBOARD_TYPE_STANDARD) {
+    NOTIMPLEMENTED();
+    return PP_ERROR_FAILED;
+  }
+
+  ui::Clipboard* clipboard = ui::Clipboard::GetForCurrentThread();
+  ui::ClipboardType type = ConvertClipboardType(clipboard_type);
+  bool available = false;
+  switch (format) {
+    case PP_FLASH_CLIPBOARD_FORMAT_PLAINTEXT: {
+      bool plain = clipboard->IsFormatAvailable(
+          ui::Clipboard::GetPlainTextFormatType(), type);
+      bool plainw = clipboard->IsFormatAvailable(
+          ui::Clipboard::GetPlainTextWFormatType(), type);
+      available = plain || plainw;
+      break;
+    }
+    case PP_FLASH_CLIPBOARD_FORMAT_HTML:
+      available = clipboard->IsFormatAvailable(
+          ui::Clipboard::GetHtmlFormatType(), type);
+      break;
+    case PP_FLASH_CLIPBOARD_FORMAT_RTF:
+      available =
+          clipboard->IsFormatAvailable(ui::Clipboard::GetRtfFormatType(), type);
+      break;
+    case PP_FLASH_CLIPBOARD_FORMAT_INVALID:
+      break;
+    default:
+      if (custom_formats_.IsFormatRegistered(format)) {
+        std::string format_name = custom_formats_.GetFormatName(format);
+        std::string clipboard_data;
+        clipboard->ReadData(ui::Clipboard::GetPepperCustomDataFormatType(),
+                            &clipboard_data);
+        Pickle pickle(clipboard_data.data(), clipboard_data.size());
+        available =
+            IsFormatAvailableInPickle(base::UTF8ToUTF16(format_name), pickle);
+      }
+      break;
+  }
+
+  return available ? PP_OK : PP_ERROR_FAILED;
+}
+
+int32_t PepperFlashClipboardMessageFilter::OnMsgReadData(
+    ppapi::host::HostMessageContext* host_context,
+    uint32_t clipboard_type,
+    uint32_t format) {
+  if (clipboard_type != PP_FLASH_CLIPBOARD_TYPE_STANDARD) {
+    NOTIMPLEMENTED();
+    return PP_ERROR_FAILED;
+  }
+
+  ui::Clipboard* clipboard = ui::Clipboard::GetForCurrentThread();
+  ui::ClipboardType type = ConvertClipboardType(clipboard_type);
+  std::string clipboard_string;
+  int32_t result = PP_ERROR_FAILED;
+  switch (format) {
+    case PP_FLASH_CLIPBOARD_FORMAT_PLAINTEXT: {
+      if (clipboard->IsFormatAvailable(ui::Clipboard::GetPlainTextWFormatType(),
+                                       type)) {
+        base::string16 text;
+        clipboard->ReadText(type, &text);
+        if (!text.empty()) {
+          result = PP_OK;
+          clipboard_string = base::UTF16ToUTF8(text);
+          break;
+        }
+      }
+      // If the PlainTextW format isn't available or is empty, take the
+      // ASCII text format.
+      if (clipboard->IsFormatAvailable(ui::Clipboard::GetPlainTextFormatType(),
+                                       type)) {
+        result = PP_OK;
+        clipboard->ReadAsciiText(type, &clipboard_string);
+      }
+      break;
+    }
+    case PP_FLASH_CLIPBOARD_FORMAT_HTML: {
+      if (!clipboard->IsFormatAvailable(ui::Clipboard::GetHtmlFormatType(),
+                                        type)) {
+        break;
+      }
+
+      base::string16 html;
+      std::string url;
+      uint32 fragment_start;
+      uint32 fragment_end;
+      clipboard->ReadHTML(type, &html, &url, &fragment_start, &fragment_end);
+      result = PP_OK;
+      clipboard_string = base::UTF16ToUTF8(
+          html.substr(fragment_start, fragment_end - fragment_start));
+      break;
+    }
+    case PP_FLASH_CLIPBOARD_FORMAT_RTF: {
+      if (!clipboard->IsFormatAvailable(ui::Clipboard::GetRtfFormatType(),
+                                        type)) {
+        break;
+      }
+      result = PP_OK;
+      clipboard->ReadRTF(type, &clipboard_string);
+      break;
+    }
+    case PP_FLASH_CLIPBOARD_FORMAT_INVALID:
+      break;
+    default: {
+      if (custom_formats_.IsFormatRegistered(format)) {
+        base::string16 format_name =
+            base::UTF8ToUTF16(custom_formats_.GetFormatName(format));
+        std::string clipboard_data;
+        clipboard->ReadData(ui::Clipboard::GetPepperCustomDataFormatType(),
+                            &clipboard_data);
+        Pickle pickle(clipboard_data.data(), clipboard_data.size());
+        if (IsFormatAvailableInPickle(format_name, pickle)) {
+          result = PP_OK;
+          clipboard_string = ReadDataFromPickle(format_name, pickle);
+        }
+      }
+      break;
+    }
+  }
+
+  if (result == PP_OK) {
+    host_context->reply_msg =
+        PpapiPluginMsg_FlashClipboard_ReadDataReply(clipboard_string);
+  }
+  return result;
+}
+
+int32_t PepperFlashClipboardMessageFilter::OnMsgWriteData(
+    ppapi::host::HostMessageContext* host_context,
+    uint32_t clipboard_type,
+    const std::vector<uint32_t>& formats,
+    const std::vector<std::string>& data) {
+  if (clipboard_type != PP_FLASH_CLIPBOARD_TYPE_STANDARD) {
+    NOTIMPLEMENTED();
+    return PP_ERROR_FAILED;
+  }
+  if (formats.size() != data.size())
+    return PP_ERROR_FAILED;
+
+  ui::Clipboard* clipboard = ui::Clipboard::GetForCurrentThread();
+  ui::ClipboardType type = ConvertClipboardType(clipboard_type);
+  // If no formats are passed in clear the clipboard.
+  if (formats.size() == 0) {
+    clipboard->Clear(type);
+    return PP_OK;
+  }
+
+  ui::ScopedClipboardWriter scw(type);
+  std::map<base::string16, std::string> custom_data_map;
+  int32_t res = PP_OK;
+  for (uint32_t i = 0; i < formats.size(); ++i) {
+    if (data[i].length() > kMaxClipboardWriteSize) {
+      res = PP_ERROR_NOSPACE;
+      break;
+    }
+
+    switch (formats[i]) {
+      case PP_FLASH_CLIPBOARD_FORMAT_PLAINTEXT:
+        scw.WriteText(base::UTF8ToUTF16(data[i]));
+        break;
+      case PP_FLASH_CLIPBOARD_FORMAT_HTML:
+        scw.WriteHTML(base::UTF8ToUTF16(data[i]), std::string());
+        break;
+      case PP_FLASH_CLIPBOARD_FORMAT_RTF:
+        scw.WriteRTF(data[i]);
+        break;
+      case PP_FLASH_CLIPBOARD_FORMAT_INVALID:
+        res = PP_ERROR_BADARGUMENT;
+        break;
+      default:
+        if (custom_formats_.IsFormatRegistered(formats[i])) {
+          std::string format_name = custom_formats_.GetFormatName(formats[i]);
+          custom_data_map[base::UTF8ToUTF16(format_name)] = data[i];
+        } else {
+          // Invalid format.
+          res = PP_ERROR_BADARGUMENT;
+          break;
+        }
+    }
+
+    if (res != PP_OK)
+      break;
+  }
+
+  if (custom_data_map.size() > 0) {
+    Pickle pickle;
+    if (WriteDataToPickle(custom_data_map, &pickle)) {
+      scw.WritePickledData(pickle,
+                           ui::Clipboard::GetPepperCustomDataFormatType());
+    } else {
+      res = PP_ERROR_BADARGUMENT;
+    }
+  }
+
+  if (res != PP_OK) {
+    // Need to clear the objects so nothing is written.
+    scw.Reset();
+  }
+
+  return res;
+}
+
+int32_t PepperFlashClipboardMessageFilter::OnMsgGetSequenceNumber(
+    ppapi::host::HostMessageContext* host_context,
+    uint32_t clipboard_type) {
+  if (clipboard_type != PP_FLASH_CLIPBOARD_TYPE_STANDARD) {
+    NOTIMPLEMENTED();
+    return PP_ERROR_FAILED;
+  }
+
+  ui::Clipboard* clipboard = ui::Clipboard::GetForCurrentThread();
+  ui::ClipboardType type = ConvertClipboardType(clipboard_type);
+  int64_t sequence_number = clipboard->GetSequenceNumber(type);
+  host_context->reply_msg =
+      PpapiPluginMsg_FlashClipboard_GetSequenceNumberReply(sequence_number);
+  return PP_OK;
+}
+
+}  // namespace chrome
diff --git a/chromium_src/chrome/browser/renderer_host/pepper/pepper_flash_clipboard_message_filter.h b/chromium_src/chrome/browser/renderer_host/pepper/pepper_flash_clipboard_message_filter.h
new file mode 100644 (file)
index 0000000..ff07eb7
--- /dev/null
@@ -0,0 +1,78 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_RENDERER_HOST_PEPPER_PEPPER_FLASH_CLIPBOARD_MESSAGE_FILTER_H_
+#define CHROME_BROWSER_RENDERER_HOST_PEPPER_PEPPER_FLASH_CLIPBOARD_MESSAGE_FILTER_H_
+
+#include <string>
+#include <vector>
+
+#include "base/basictypes.h"
+#include "base/compiler_specific.h"
+#include "ppapi/host/resource_message_filter.h"
+#include "ppapi/shared_impl/flash_clipboard_format_registry.h"
+
+namespace ppapi {
+namespace host {
+struct HostMessageContext;
+}
+}
+
+namespace ui {
+class ScopedClipboardWriter;
+}
+
+namespace chrome {
+
+// Resource message filter for accessing the clipboard in Pepper. Pepper
+// supports reading/writing custom formats from the clipboard. Currently, all
+// custom formats that are read/written from the clipboard through pepper are
+// stored in a single real clipboard format (in the same way the "web custom"
+// clipboard formats are). This is done so that we don't have to have use real
+// clipboard types for each custom clipboard format which may be a limited
+// resource on a particular platform.
+class PepperFlashClipboardMessageFilter
+    : public ppapi::host::ResourceMessageFilter {
+ public:
+  PepperFlashClipboardMessageFilter();
+
+ protected:
+  // ppapi::host::ResourceMessageFilter overrides.
+  scoped_refptr<base::TaskRunner> OverrideTaskRunnerForMessage(
+      const IPC::Message& msg) override;
+  int32_t OnResourceMessageReceived(
+      const IPC::Message& msg,
+      ppapi::host::HostMessageContext* context) override;
+
+ private:
+  ~PepperFlashClipboardMessageFilter() override;
+
+  int32_t OnMsgRegisterCustomFormat(
+      ppapi::host::HostMessageContext* host_context,
+      const std::string& format_name);
+  int32_t OnMsgIsFormatAvailable(ppapi::host::HostMessageContext* host_context,
+                                 uint32_t clipboard_type,
+                                 uint32_t format);
+  int32_t OnMsgReadData(ppapi::host::HostMessageContext* host_context,
+                        uint32_t clipoard_type,
+                        uint32_t format);
+  int32_t OnMsgWriteData(ppapi::host::HostMessageContext* host_context,
+                         uint32_t clipboard_type,
+                         const std::vector<uint32_t>& formats,
+                         const std::vector<std::string>& data);
+  int32_t OnMsgGetSequenceNumber(ppapi::host::HostMessageContext* host_context,
+                                 uint32_t clipboard_type);
+
+  int32_t WriteClipboardDataItem(uint32_t format,
+                                 const std::string& data,
+                                 ui::ScopedClipboardWriter* scw);
+
+  ppapi::FlashClipboardFormatRegistry custom_formats_;
+
+  DISALLOW_COPY_AND_ASSIGN(PepperFlashClipboardMessageFilter);
+};
+
+}  // namespace chrome
+
+#endif  // CHROME_BROWSER_RENDERER_HOST_PEPPER_PEPPER_FLASH_CLIPBOARD_MESSAGE_FILTER_H_
diff --git a/chromium_src/chrome/browser/renderer_host/pepper/pepper_isolated_file_system_message_filter.cc b/chromium_src/chrome/browser/renderer_host/pepper/pepper_isolated_file_system_message_filter.cc
new file mode 100644 (file)
index 0000000..10c0790
--- /dev/null
@@ -0,0 +1,110 @@
+// Copyright 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/renderer_host/pepper/pepper_isolated_file_system_message_filter.h"
+
+#include "content/public/browser/browser_ppapi_host.h"
+#include "content/public/browser/browser_thread.h"
+#include "content/public/browser/child_process_security_policy.h"
+#include "content/public/browser/render_view_host.h"
+#include "ppapi/c/pp_errors.h"
+#include "ppapi/host/dispatch_host_message.h"
+#include "ppapi/host/host_message_context.h"
+#include "ppapi/host/ppapi_host.h"
+#include "ppapi/proxy/ppapi_messages.h"
+#include "ppapi/shared_impl/file_system_util.h"
+#include "storage/browser/fileapi/isolated_context.h"
+
+namespace chrome {
+
+// static
+PepperIsolatedFileSystemMessageFilter*
+PepperIsolatedFileSystemMessageFilter::Create(PP_Instance instance,
+                                              content::BrowserPpapiHost* host) {
+  int render_process_id;
+  int unused_render_frame_id;
+  if (!host->GetRenderFrameIDsForInstance(
+          instance, &render_process_id, &unused_render_frame_id)) {
+    return NULL;
+  }
+  return new PepperIsolatedFileSystemMessageFilter(
+      render_process_id,
+      host->GetProfileDataDirectory(),
+      host->GetDocumentURLForInstance(instance),
+      host->GetPpapiHost());
+}
+
+PepperIsolatedFileSystemMessageFilter::PepperIsolatedFileSystemMessageFilter(
+    int render_process_id,
+    const base::FilePath& profile_directory,
+    const GURL& document_url,
+    ppapi::host::PpapiHost* ppapi_host)
+    : render_process_id_(render_process_id),
+      profile_directory_(profile_directory),
+      document_url_(document_url),
+      ppapi_host_(ppapi_host) {
+}
+
+PepperIsolatedFileSystemMessageFilter::
+    ~PepperIsolatedFileSystemMessageFilter() {}
+
+scoped_refptr<base::TaskRunner>
+PepperIsolatedFileSystemMessageFilter::OverrideTaskRunnerForMessage(
+    const IPC::Message& msg) {
+  // In order to reach ExtensionSystem, we need to get ProfileManager first.
+  // ProfileManager lives in UI thread, so we need to do this in UI thread.
+  return content::BrowserThread::GetMessageLoopProxyForThread(
+      content::BrowserThread::UI);
+}
+
+int32_t PepperIsolatedFileSystemMessageFilter::OnResourceMessageReceived(
+    const IPC::Message& msg,
+    ppapi::host::HostMessageContext* context) {
+  PPAPI_BEGIN_MESSAGE_MAP(PepperIsolatedFileSystemMessageFilter, msg)
+    PPAPI_DISPATCH_HOST_RESOURCE_CALL(
+      PpapiHostMsg_IsolatedFileSystem_BrowserOpen,
+      OnOpenFileSystem)
+  PPAPI_END_MESSAGE_MAP()
+  return PP_ERROR_FAILED;
+}
+
+int32_t PepperIsolatedFileSystemMessageFilter::OnOpenFileSystem(
+    ppapi::host::HostMessageContext* context,
+    PP_IsolatedFileSystemType_Private type) {
+  switch (type) {
+    case PP_ISOLATEDFILESYSTEMTYPE_PRIVATE_INVALID:
+    case PP_ISOLATEDFILESYSTEMTYPE_PRIVATE_CRX:
+      break;
+    case PP_ISOLATEDFILESYSTEMTYPE_PRIVATE_PLUGINPRIVATE:
+      return OpenPluginPrivateFileSystem(context);
+  }
+  NOTREACHED();
+  context->reply_msg =
+      PpapiPluginMsg_IsolatedFileSystem_BrowserOpenReply(std::string());
+  return PP_ERROR_FAILED;
+}
+
+int32_t PepperIsolatedFileSystemMessageFilter::OpenPluginPrivateFileSystem(
+    ppapi::host::HostMessageContext* context) {
+  DCHECK(ppapi_host_);
+  // Only plugins with private permission can open the filesystem.
+  if (!ppapi_host_->permissions().HasPermission(ppapi::PERMISSION_PRIVATE))
+    return PP_ERROR_NOACCESS;
+
+  const std::string& root_name = ppapi::IsolatedFileSystemTypeToRootName(
+      PP_ISOLATEDFILESYSTEMTYPE_PRIVATE_PLUGINPRIVATE);
+  const std::string& fsid =
+      storage::IsolatedContext::GetInstance()->RegisterFileSystemForVirtualPath(
+          storage::kFileSystemTypePluginPrivate, root_name, base::FilePath());
+
+  // Grant full access of isolated filesystem to renderer process.
+  content::ChildProcessSecurityPolicy* policy =
+      content::ChildProcessSecurityPolicy::GetInstance();
+  policy->GrantCreateReadWriteFileSystem(render_process_id_, fsid);
+
+  context->reply_msg = PpapiPluginMsg_IsolatedFileSystem_BrowserOpenReply(fsid);
+  return PP_OK;
+}
+
+}  // namespace chrome
diff --git a/chromium_src/chrome/browser/renderer_host/pepper/pepper_isolated_file_system_message_filter.h b/chromium_src/chrome/browser/renderer_host/pepper/pepper_isolated_file_system_message_filter.h
new file mode 100644 (file)
index 0000000..6a24fea
--- /dev/null
@@ -0,0 +1,76 @@
+// Copyright 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_RENDERER_HOST_PEPPER_PEPPER_ISOLATED_FILE_SYSTEM_MESSAGE_FILTER_H_
+#define CHROME_BROWSER_RENDERER_HOST_PEPPER_PEPPER_ISOLATED_FILE_SYSTEM_MESSAGE_FILTER_H_
+
+#include <set>
+#include <string>
+
+#include "base/files/file_path.h"
+#include "ppapi/c/pp_instance.h"
+#include "ppapi/c/pp_resource.h"
+#include "ppapi/c/private/ppb_isolated_file_system_private.h"
+#include "ppapi/host/resource_host.h"
+#include "ppapi/host/resource_message_filter.h"
+#include "url/gurl.h"
+
+class Profile;
+
+namespace content {
+class BrowserPpapiHost;
+}
+
+namespace ppapi {
+namespace host {
+struct HostMessageContext;
+}  // namespace host
+}  // namespace ppapi
+
+namespace chrome {
+
+class PepperIsolatedFileSystemMessageFilter
+    : public ppapi::host::ResourceMessageFilter {
+ public:
+  static PepperIsolatedFileSystemMessageFilter* Create(
+      PP_Instance instance,
+      content::BrowserPpapiHost* host);
+
+  // ppapi::host::ResourceMessageFilter implementation.
+  scoped_refptr<base::TaskRunner> OverrideTaskRunnerForMessage(
+      const IPC::Message& msg) override;
+  int32_t OnResourceMessageReceived(
+      const IPC::Message& msg,
+      ppapi::host::HostMessageContext* context) override;
+
+ private:
+  PepperIsolatedFileSystemMessageFilter(int render_process_id,
+                                        const base::FilePath& profile_directory,
+                                        const GURL& document_url,
+                                        ppapi::host::PpapiHost* ppapi_host_);
+
+  ~PepperIsolatedFileSystemMessageFilter() override;
+
+  // Returns filesystem id of isolated filesystem if valid, or empty string
+  // otherwise.  This must run on the UI thread because ProfileManager only
+  // allows access on that thread.
+
+  int32_t OnOpenFileSystem(ppapi::host::HostMessageContext* context,
+                           PP_IsolatedFileSystemType_Private type);
+  int32_t OpenPluginPrivateFileSystem(ppapi::host::HostMessageContext* context);
+
+  const int render_process_id_;
+  // Keep a copy from original thread.
+  const base::FilePath profile_directory_;
+  const GURL document_url_;
+
+  // Not owned by this object.
+  ppapi::host::PpapiHost* ppapi_host_;
+
+  DISALLOW_COPY_AND_ASSIGN(PepperIsolatedFileSystemMessageFilter);
+};
+
+}  // namespace chrome
+
+#endif  // CHROME_BROWSER_RENDERER_HOST_PEPPER_PEPPER_ISOLATED_FILE_SYSTEM_MESSAGE_FILTER_H_
diff --git a/chromium_src/chrome/renderer/pepper/chrome_renderer_pepper_host_factory.cc b/chromium_src/chrome/renderer/pepper/chrome_renderer_pepper_host_factory.cc
new file mode 100644 (file)
index 0000000..db92669
--- /dev/null
@@ -0,0 +1,87 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/renderer/pepper/chrome_renderer_pepper_host_factory.h"
+
+#include "base/logging.h"
+#include "chrome/renderer/pepper/pepper_flash_drm_renderer_host.h"
+#include "chrome/renderer/pepper/pepper_flash_font_file_host.h"
+#include "chrome/renderer/pepper/pepper_flash_fullscreen_host.h"
+#include "chrome/renderer/pepper/pepper_flash_menu_host.h"
+#include "chrome/renderer/pepper/pepper_flash_renderer_host.h"
+#include "content/public/renderer/renderer_ppapi_host.h"
+#include "ppapi/host/ppapi_host.h"
+#include "ppapi/host/resource_host.h"
+#include "ppapi/proxy/ppapi_message_utils.h"
+#include "ppapi/proxy/ppapi_messages.h"
+#include "ppapi/shared_impl/ppapi_permissions.h"
+
+using ppapi::host::ResourceHost;
+
+ChromeRendererPepperHostFactory::ChromeRendererPepperHostFactory(
+    content::RendererPpapiHost* host)
+    : host_(host) {}
+
+ChromeRendererPepperHostFactory::~ChromeRendererPepperHostFactory() {}
+
+scoped_ptr<ResourceHost> ChromeRendererPepperHostFactory::CreateResourceHost(
+    ppapi::host::PpapiHost* host,
+    PP_Resource resource,
+    PP_Instance instance,
+    const IPC::Message& message) {
+  DCHECK_EQ(host_->GetPpapiHost(), host);
+
+  // Make sure the plugin is giving us a valid instance for this resource.
+  if (!host_->IsValidInstance(instance))
+    return scoped_ptr<ResourceHost>();
+
+  if (host_->GetPpapiHost()->permissions().HasPermission(
+          ppapi::PERMISSION_FLASH)) {
+    switch (message.type()) {
+      case PpapiHostMsg_Flash_Create::ID: {
+        return scoped_ptr<ResourceHost>(
+            new PepperFlashRendererHost(host_, instance, resource));
+      }
+      case PpapiHostMsg_FlashFullscreen_Create::ID: {
+        return scoped_ptr<ResourceHost>(
+            new PepperFlashFullscreenHost(host_, instance, resource));
+      }
+      case PpapiHostMsg_FlashMenu_Create::ID: {
+        ppapi::proxy::SerializedFlashMenu serialized_menu;
+        if (ppapi::UnpackMessage<PpapiHostMsg_FlashMenu_Create>(
+                message, &serialized_menu)) {
+          return scoped_ptr<ResourceHost>(new PepperFlashMenuHost(
+              host_, instance, resource, serialized_menu));
+        }
+        break;
+      }
+    }
+  }
+
+  // TODO(raymes): PDF also needs access to the FlashFontFileHost currently.
+  // We should either rename PPB_FlashFont_File to PPB_FontFile_Private or get
+  // rid of its use in PDF if possible.
+  if (host_->GetPpapiHost()->permissions().HasPermission(
+          ppapi::PERMISSION_FLASH) ||
+      host_->GetPpapiHost()->permissions().HasPermission(
+          ppapi::PERMISSION_PRIVATE)) {
+    switch (message.type()) {
+      case PpapiHostMsg_FlashFontFile_Create::ID: {
+        ppapi::proxy::SerializedFontDescription description;
+        PP_PrivateFontCharset charset;
+        if (ppapi::UnpackMessage<PpapiHostMsg_FlashFontFile_Create>(
+                message, &description, &charset)) {
+          return scoped_ptr<ResourceHost>(new PepperFlashFontFileHost(
+              host_, instance, resource, description, charset));
+        }
+        break;
+      }
+      case PpapiHostMsg_FlashDRM_Create::ID:
+        return scoped_ptr<ResourceHost>(
+            new PepperFlashDRMRendererHost(host_, instance, resource));
+    }
+  }
+
+  return scoped_ptr<ResourceHost>();
+}
diff --git a/chromium_src/chrome/renderer/pepper/chrome_renderer_pepper_host_factory.h b/chromium_src/chrome/renderer/pepper/chrome_renderer_pepper_host_factory.h
new file mode 100644 (file)
index 0000000..13ab285
--- /dev/null
@@ -0,0 +1,35 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_RENDERER_PEPPER_CHROME_RENDERER_PEPPER_HOST_FACTORY_H_
+#define CHROME_RENDERER_PEPPER_CHROME_RENDERER_PEPPER_HOST_FACTORY_H_
+
+#include "base/basictypes.h"
+#include "base/compiler_specific.h"
+#include "ppapi/host/host_factory.h"
+
+namespace content {
+class RendererPpapiHost;
+}
+
+class ChromeRendererPepperHostFactory : public ppapi::host::HostFactory {
+ public:
+  explicit ChromeRendererPepperHostFactory(content::RendererPpapiHost* host);
+  ~ChromeRendererPepperHostFactory() override;
+
+  // HostFactory.
+  scoped_ptr<ppapi::host::ResourceHost> CreateResourceHost(
+      ppapi::host::PpapiHost* host,
+      PP_Resource resource,
+      PP_Instance instance,
+      const IPC::Message& message) override;
+
+ private:
+  // Not owned by this object.
+  content::RendererPpapiHost* host_;
+
+  DISALLOW_COPY_AND_ASSIGN(ChromeRendererPepperHostFactory);
+};
+
+#endif  // CHROME_RENDERER_PEPPER_CHROME_RENDERER_PEPPER_HOST_FACTORY_H_
diff --git a/chromium_src/chrome/renderer/pepper/pepper_flash_drm_renderer_host.cc b/chromium_src/chrome/renderer/pepper/pepper_flash_drm_renderer_host.cc
new file mode 100644 (file)
index 0000000..2e95d23
--- /dev/null
@@ -0,0 +1,87 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/renderer/pepper/pepper_flash_drm_renderer_host.h"
+
+#include "base/files/file_path.h"
+#include "content/public/renderer/pepper_plugin_instance.h"
+#include "content/public/renderer/renderer_ppapi_host.h"
+#include "ppapi/c/pp_errors.h"
+#include "ppapi/host/dispatch_host_message.h"
+#include "ppapi/host/host_message_context.h"
+#include "ppapi/host/ppapi_host.h"
+#include "ppapi/proxy/ppapi_messages.h"
+
+// TODO(raymes): This is duplicated from pepper_flash_drm_host.cc but once
+// FileRef is refactored to the browser, it won't need to be.
+namespace {
+const char kVoucherFilename[] = "plugin.vch";
+}  // namespace
+
+PepperFlashDRMRendererHost::PepperFlashDRMRendererHost(
+    content::RendererPpapiHost* host,
+    PP_Instance instance,
+    PP_Resource resource)
+    : ResourceHost(host->GetPpapiHost(), instance, resource),
+      renderer_ppapi_host_(host),
+      weak_factory_(this) {}
+
+PepperFlashDRMRendererHost::~PepperFlashDRMRendererHost() {}
+
+int32_t PepperFlashDRMRendererHost::OnResourceMessageReceived(
+    const IPC::Message& msg,
+    ppapi::host::HostMessageContext* context) {
+  PPAPI_BEGIN_MESSAGE_MAP(PepperFlashDRMRendererHost, msg)
+    PPAPI_DISPATCH_HOST_RESOURCE_CALL_0(PpapiHostMsg_FlashDRM_GetVoucherFile,
+                                        OnGetVoucherFile)
+  PPAPI_END_MESSAGE_MAP()
+  return PP_ERROR_FAILED;
+}
+
+int32_t PepperFlashDRMRendererHost::OnGetVoucherFile(
+    ppapi::host::HostMessageContext* context) {
+  content::PepperPluginInstance* plugin_instance =
+      renderer_ppapi_host_->GetPluginInstance(pp_instance());
+  if (!plugin_instance)
+    return PP_ERROR_FAILED;
+
+  base::FilePath plugin_dir = plugin_instance->GetModulePath().DirName();
+  DCHECK(!plugin_dir.empty());
+  base::FilePath voucher_file = plugin_dir.AppendASCII(kVoucherFilename);
+
+  int renderer_pending_host_id =
+      plugin_instance->MakePendingFileRefRendererHost(voucher_file);
+  if (renderer_pending_host_id == 0)
+    return PP_ERROR_FAILED;
+
+  std::vector<IPC::Message> create_msgs;
+  create_msgs.push_back(PpapiHostMsg_FileRef_CreateForRawFS(voucher_file));
+
+  renderer_ppapi_host_->CreateBrowserResourceHosts(
+      pp_instance(),
+      create_msgs,
+      base::Bind(&PepperFlashDRMRendererHost::DidCreateFileRefHosts,
+                 weak_factory_.GetWeakPtr(),
+                 context->MakeReplyMessageContext(),
+                 voucher_file,
+                 renderer_pending_host_id));
+  return PP_OK_COMPLETIONPENDING;
+}
+
+void PepperFlashDRMRendererHost::DidCreateFileRefHosts(
+    const ppapi::host::ReplyMessageContext& reply_context,
+    const base::FilePath& external_path,
+    int renderer_pending_host_id,
+    const std::vector<int>& browser_pending_host_ids) {
+  DCHECK_EQ(1U, browser_pending_host_ids.size());
+  int browser_pending_host_id = browser_pending_host_ids[0];
+
+  ppapi::FileRefCreateInfo create_info =
+      ppapi::MakeExternalFileRefCreateInfo(external_path,
+                                           std::string(),
+                                           browser_pending_host_id,
+                                           renderer_pending_host_id);
+  host()->SendReply(reply_context,
+                    PpapiPluginMsg_FlashDRM_GetVoucherFileReply(create_info));
+}
diff --git a/chromium_src/chrome/renderer/pepper/pepper_flash_drm_renderer_host.h b/chromium_src/chrome/renderer/pepper/pepper_flash_drm_renderer_host.h
new file mode 100644 (file)
index 0000000..cc06d38
--- /dev/null
@@ -0,0 +1,51 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_RENDERER_PEPPER_PEPPER_FLASH_DRM_RENDERER_HOST_H_
+#define CHROME_RENDERER_PEPPER_PEPPER_FLASH_DRM_RENDERER_HOST_H_
+
+#include "base/basictypes.h"
+#include "base/compiler_specific.h"
+#include "base/memory/weak_ptr.h"
+#include "ppapi/host/resource_host.h"
+
+namespace base {
+class FilePath;
+}
+
+namespace content {
+class RendererPpapiHost;
+}
+
+// TODO(raymes): This is only needed until we move FileRef resources to the
+// browser. After that, get rid of this class altogether.
+class PepperFlashDRMRendererHost : public ppapi::host::ResourceHost {
+ public:
+  PepperFlashDRMRendererHost(content::RendererPpapiHost* host,
+                             PP_Instance instance,
+                             PP_Resource resource);
+  ~PepperFlashDRMRendererHost() override;
+
+  int32_t OnResourceMessageReceived(
+      const IPC::Message& msg,
+      ppapi::host::HostMessageContext* context) override;
+
+ private:
+  int32_t OnGetVoucherFile(ppapi::host::HostMessageContext* context);
+
+  void DidCreateFileRefHosts(
+      const ppapi::host::ReplyMessageContext& reply_context,
+      const base::FilePath& external_path,
+      int renderer_pending_host_id,
+      const std::vector<int>& browser_pending_host_ids);
+
+  // Non-owning pointer.
+  content::RendererPpapiHost* renderer_ppapi_host_;
+
+  base::WeakPtrFactory<PepperFlashDRMRendererHost> weak_factory_;
+
+  DISALLOW_COPY_AND_ASSIGN(PepperFlashDRMRendererHost);
+};
+
+#endif  // CHROME_RENDERER_PEPPER_PEPPER_FLASH_DRM_RENDERER_HOST_H_
diff --git a/chromium_src/chrome/renderer/pepper/pepper_flash_font_file_host.cc b/chromium_src/chrome/renderer/pepper/pepper_flash_font_file_host.cc
new file mode 100644 (file)
index 0000000..305b6ec
--- /dev/null
@@ -0,0 +1,74 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/renderer/pepper/pepper_flash_font_file_host.h"
+
+#include "build/build_config.h"
+#include "content/public/renderer/renderer_ppapi_host.h"
+#include "ppapi/c/pp_errors.h"
+#include "ppapi/host/dispatch_host_message.h"
+#include "ppapi/host/host_message_context.h"
+#include "ppapi/host/ppapi_host.h"
+#include "ppapi/proxy/ppapi_messages.h"
+#include "ppapi/proxy/serialized_structs.h"
+
+#if defined(OS_LINUX) || defined(OS_OPENBSD)
+#include "content/public/common/child_process_sandbox_support_linux.h"
+#endif
+
+PepperFlashFontFileHost::PepperFlashFontFileHost(
+    content::RendererPpapiHost* host,
+    PP_Instance instance,
+    PP_Resource resource,
+    const ppapi::proxy::SerializedFontDescription& description,
+    PP_PrivateFontCharset charset)
+    : ResourceHost(host->GetPpapiHost(), instance, resource) {
+#if defined(OS_LINUX) || defined(OS_OPENBSD)
+  fd_.reset(content::MatchFontWithFallback(
+      description.face.c_str(),
+      description.weight >= PP_BROWSERFONT_TRUSTED_WEIGHT_BOLD,
+      description.italic,
+      charset,
+      PP_BROWSERFONT_TRUSTED_FAMILY_DEFAULT));
+#endif  // defined(OS_LINUX) || defined(OS_OPENBSD)
+}
+
+PepperFlashFontFileHost::~PepperFlashFontFileHost() {}
+
+int32_t PepperFlashFontFileHost::OnResourceMessageReceived(
+    const IPC::Message& msg,
+    ppapi::host::HostMessageContext* context) {
+  PPAPI_BEGIN_MESSAGE_MAP(PepperFlashFontFileHost, msg)
+    PPAPI_DISPATCH_HOST_RESOURCE_CALL(PpapiHostMsg_FlashFontFile_GetFontTable,
+                                      OnGetFontTable)
+  PPAPI_END_MESSAGE_MAP()
+  return PP_ERROR_FAILED;
+}
+
+int32_t PepperFlashFontFileHost::OnGetFontTable(
+    ppapi::host::HostMessageContext* context,
+    uint32_t table) {
+  std::string contents;
+  int32_t result = PP_ERROR_FAILED;
+#if defined(OS_LINUX) || defined(OS_OPENBSD)
+  int fd = fd_.get();
+  if (fd != -1) {
+    size_t length = 0;
+    if (content::GetFontTable(fd, table, 0 /* offset */, NULL, &length)) {
+      contents.resize(length);
+      uint8_t* contents_ptr =
+          reinterpret_cast<uint8_t*>(const_cast<char*>(contents.c_str()));
+      if (content::GetFontTable(
+              fd, table, 0 /* offset */, contents_ptr, &length)) {
+        result = PP_OK;
+      } else {
+        contents.clear();
+      }
+    }
+  }
+#endif  // defined(OS_LINUX) || defined(OS_OPENBSD)
+
+  context->reply_msg = PpapiPluginMsg_FlashFontFile_GetFontTableReply(contents);
+  return result;
+}
diff --git a/chromium_src/chrome/renderer/pepper/pepper_flash_font_file_host.h b/chromium_src/chrome/renderer/pepper/pepper_flash_font_file_host.h
new file mode 100644 (file)
index 0000000..02bb30f
--- /dev/null
@@ -0,0 +1,52 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_RENDERER_PEPPER_PEPPER_FLASH_FONT_FILE_HOST_H_
+#define CHROME_RENDERER_PEPPER_PEPPER_FLASH_FONT_FILE_HOST_H_
+
+#include "base/basictypes.h"
+#include "base/compiler_specific.h"
+#include "ppapi/c/private/pp_private_font_charset.h"
+#include "ppapi/host/resource_host.h"
+
+#if defined(OS_LINUX) || defined(OS_OPENBSD)
+#include "base/files/scoped_file.h"
+#endif
+
+namespace content {
+class RendererPpapiHost;
+}
+
+namespace ppapi {
+namespace proxy {
+struct SerializedFontDescription;
+}
+}
+
+class PepperFlashFontFileHost : public ppapi::host::ResourceHost {
+ public:
+  PepperFlashFontFileHost(
+      content::RendererPpapiHost* host,
+      PP_Instance instance,
+      PP_Resource resource,
+      const ppapi::proxy::SerializedFontDescription& description,
+      PP_PrivateFontCharset charset);
+  ~PepperFlashFontFileHost() override;
+
+  int32_t OnResourceMessageReceived(
+      const IPC::Message& msg,
+      ppapi::host::HostMessageContext* context) override;
+
+ private:
+  int32_t OnGetFontTable(ppapi::host::HostMessageContext* context,
+                         uint32_t table);
+
+#if defined(OS_LINUX) || defined(OS_OPENBSD)
+  base::ScopedFD fd_;
+#endif
+
+  DISALLOW_COPY_AND_ASSIGN(PepperFlashFontFileHost);
+};
+
+#endif  // CHROME_RENDERER_PEPPER_PEPPER_FLASH_FONT_FILE_HOST_H_
diff --git a/chromium_src/chrome/renderer/pepper/pepper_flash_fullscreen_host.cc b/chromium_src/chrome/renderer/pepper/pepper_flash_fullscreen_host.cc
new file mode 100644 (file)
index 0000000..d590cde
--- /dev/null
@@ -0,0 +1,43 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/renderer/pepper/pepper_flash_fullscreen_host.h"
+
+#include "content/public/renderer/pepper_plugin_instance.h"
+#include "content/public/renderer/renderer_ppapi_host.h"
+#include "ppapi/c/pp_errors.h"
+#include "ppapi/host/dispatch_host_message.h"
+#include "ppapi/host/host_message_context.h"
+#include "ppapi/host/ppapi_host.h"
+#include "ppapi/proxy/ppapi_messages.h"
+
+PepperFlashFullscreenHost::PepperFlashFullscreenHost(
+    content::RendererPpapiHost* host,
+    PP_Instance instance,
+    PP_Resource resource)
+    : ResourceHost(host->GetPpapiHost(), instance, resource),
+      renderer_ppapi_host_(host) {}
+
+PepperFlashFullscreenHost::~PepperFlashFullscreenHost() {}
+
+int32_t PepperFlashFullscreenHost::OnResourceMessageReceived(
+    const IPC::Message& msg,
+    ppapi::host::HostMessageContext* context) {
+  PPAPI_BEGIN_MESSAGE_MAP(PepperFlashFullscreenHost, msg)
+    PPAPI_DISPATCH_HOST_RESOURCE_CALL(
+      PpapiHostMsg_FlashFullscreen_SetFullscreen,
+      OnSetFullscreen)
+  PPAPI_END_MESSAGE_MAP()
+  return PP_ERROR_FAILED;
+}
+
+int32_t PepperFlashFullscreenHost::OnSetFullscreen(
+    ppapi::host::HostMessageContext* context,
+    bool fullscreen) {
+  content::PepperPluginInstance* plugin_instance =
+      renderer_ppapi_host_->GetPluginInstance(pp_instance());
+  if (plugin_instance && plugin_instance->FlashSetFullscreen(fullscreen, true))
+    return PP_OK;
+  return PP_ERROR_FAILED;
+}
diff --git a/chromium_src/chrome/renderer/pepper/pepper_flash_fullscreen_host.h b/chromium_src/chrome/renderer/pepper/pepper_flash_fullscreen_host.h
new file mode 100644 (file)
index 0000000..3550ea1
--- /dev/null
@@ -0,0 +1,37 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_RENDERER_PEPPER_PEPPER_FLASH_FULLSCREEN_HOST_H_
+#define CHROME_RENDERER_PEPPER_PEPPER_FLASH_FULLSCREEN_HOST_H_
+
+#include "base/basictypes.h"
+#include "base/compiler_specific.h"
+#include "ppapi/host/resource_host.h"
+
+namespace content {
+class RendererPpapiHost;
+}
+
+class PepperFlashFullscreenHost : public ppapi::host::ResourceHost {
+ public:
+  PepperFlashFullscreenHost(content::RendererPpapiHost* host,
+                            PP_Instance instance,
+                            PP_Resource resource);
+  ~PepperFlashFullscreenHost() override;
+
+  int32_t OnResourceMessageReceived(
+      const IPC::Message& msg,
+      ppapi::host::HostMessageContext* context) override;
+
+ private:
+  int32_t OnSetFullscreen(ppapi::host::HostMessageContext* context,
+                          bool fullscreen);
+
+  // Non-owning pointer.
+  content::RendererPpapiHost* renderer_ppapi_host_;
+
+  DISALLOW_COPY_AND_ASSIGN(PepperFlashFullscreenHost);
+};
+
+#endif  // CHROME_RENDERER_PEPPER_PEPPER_FLASH_FULLSCREEN_HOST_H_
diff --git a/chromium_src/chrome/renderer/pepper/pepper_flash_menu_host.cc b/chromium_src/chrome/renderer/pepper/pepper_flash_menu_host.cc
new file mode 100644 (file)
index 0000000..3b7a438
--- /dev/null
@@ -0,0 +1,202 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/renderer/pepper/pepper_flash_menu_host.h"
+
+#include "base/strings/utf_string_conversions.h"
+#include "content/public/common/context_menu_params.h"
+#include "content/public/renderer/render_frame.h"
+#include "content/public/renderer/renderer_ppapi_host.h"
+#include "ipc/ipc_message.h"
+#include "ppapi/c/private/ppb_flash_menu.h"
+#include "ppapi/host/dispatch_host_message.h"
+#include "ppapi/host/ppapi_host.h"
+#include "ppapi/proxy/ppapi_messages.h"
+#include "ppapi/proxy/serialized_flash_menu.h"
+#include "ui/gfx/geometry/point.h"
+
+namespace {
+
+// Maximum depth of submenus allowed (e.g., 1 indicates that submenus are
+// allowed, but not sub-submenus).
+const size_t kMaxMenuDepth = 2;
+
+// Maximum number of entries in any single menu (including separators).
+const size_t kMaxMenuEntries = 50;
+
+// Maximum total number of entries in the |menu_id_map| (see below).
+// (Limit to 500 real entries; reserve the 0 action as an invalid entry.)
+const size_t kMaxMenuIdMapEntries = 501;
+
+// Converts menu data from one form to another.
+//  - |depth| is the current nested depth (call it starting with 0).
+//  - |menu_id_map| is such that |menu_id_map[output_item.action] ==
+//    input_item.id| (where |action| is what a |MenuItem| has, |id| is what a
+//    |PP_Flash_MenuItem| has).
+bool ConvertMenuData(const PP_Flash_Menu* in_menu,
+                     size_t depth,
+                     std::vector<content::MenuItem>* out_menu,
+                     std::vector<int32_t>* menu_id_map) {
+  if (depth > kMaxMenuDepth || !in_menu)
+    return false;
+
+  // Clear the output, just in case.
+  out_menu->clear();
+
+  if (!in_menu->count)
+    return true;  // Nothing else to do.
+
+  if (!in_menu->items || in_menu->count > kMaxMenuEntries)
+    return false;
+  for (uint32_t i = 0; i < in_menu->count; i++) {
+    content::MenuItem item;
+
+    PP_Flash_MenuItem_Type type = in_menu->items[i].type;
+    switch (type) {
+      case PP_FLASH_MENUITEM_TYPE_NORMAL:
+        item.type = content::MenuItem::OPTION;
+        break;
+      case PP_FLASH_MENUITEM_TYPE_CHECKBOX:
+        item.type = content::MenuItem::CHECKABLE_OPTION;
+        break;
+      case PP_FLASH_MENUITEM_TYPE_SEPARATOR:
+        item.type = content::MenuItem::SEPARATOR;
+        break;
+      case PP_FLASH_MENUITEM_TYPE_SUBMENU:
+        item.type = content::MenuItem::SUBMENU;
+        break;
+      default:
+        return false;
+    }
+    if (in_menu->items[i].name)
+      item.label = base::UTF8ToUTF16(in_menu->items[i].name);
+    if (menu_id_map->size() >= kMaxMenuIdMapEntries)
+      return false;
+    item.action = static_cast<unsigned>(menu_id_map->size());
+    // This sets |(*menu_id_map)[item.action] = in_menu->items[i].id|.
+    menu_id_map->push_back(in_menu->items[i].id);
+    item.enabled = PP_ToBool(in_menu->items[i].enabled);
+    item.checked = PP_ToBool(in_menu->items[i].checked);
+    if (type == PP_FLASH_MENUITEM_TYPE_SUBMENU) {
+      if (!ConvertMenuData(
+              in_menu->items[i].submenu, depth + 1, &item.submenu, menu_id_map))
+        return false;
+    }
+
+    out_menu->push_back(item);
+  }
+
+  return true;
+}
+
+}  // namespace
+
+PepperFlashMenuHost::PepperFlashMenuHost(
+    content::RendererPpapiHost* host,
+    PP_Instance instance,
+    PP_Resource resource,
+    const ppapi::proxy::SerializedFlashMenu& serial_menu)
+    : ppapi::host::ResourceHost(host->GetPpapiHost(), instance, resource),
+      renderer_ppapi_host_(host),
+      showing_context_menu_(false),
+      context_menu_request_id_(0),
+      has_saved_context_menu_action_(false),
+      saved_context_menu_action_(0) {
+  menu_id_map_.push_back(0);  // Reserve |menu_id_map_[0]|.
+  if (!ConvertMenuData(serial_menu.pp_menu(), 0, &menu_data_, &menu_id_map_)) {
+    menu_data_.clear();
+    menu_id_map_.clear();
+  }
+}
+
+PepperFlashMenuHost::~PepperFlashMenuHost() {
+  if (showing_context_menu_) {
+    content::RenderFrame* render_frame =
+        renderer_ppapi_host_->GetRenderFrameForInstance(pp_instance());
+    if (render_frame)
+      render_frame->CancelContextMenu(context_menu_request_id_);
+  }
+}
+
+int32_t PepperFlashMenuHost::OnResourceMessageReceived(
+    const IPC::Message& msg,
+    ppapi::host::HostMessageContext* context) {
+  PPAPI_BEGIN_MESSAGE_MAP(PepperFlashMenuHost, msg)
+    PPAPI_DISPATCH_HOST_RESOURCE_CALL(PpapiHostMsg_FlashMenu_Show,
+                                      OnHostMsgShow)
+  PPAPI_END_MESSAGE_MAP()
+  return PP_ERROR_FAILED;
+}
+
+int32_t PepperFlashMenuHost::OnHostMsgShow(
+    ppapi::host::HostMessageContext* context,
+    const PP_Point& location) {
+  // Note that all early returns must do a SendMenuReply. The sync result for
+  // this message isn't used, so to forward the error to the plugin, we need to
+  // additionally call SendMenuReply explicitly.
+  if (menu_data_.empty()) {
+    SendMenuReply(PP_ERROR_FAILED, -1);
+    return PP_ERROR_FAILED;
+  }
+  if (showing_context_menu_) {
+    SendMenuReply(PP_ERROR_INPROGRESS, -1);
+    return PP_ERROR_INPROGRESS;
+  }
+
+  content::RenderFrame* render_frame =
+      renderer_ppapi_host_->GetRenderFrameForInstance(pp_instance());
+
+  content::ContextMenuParams params;
+  params.x = location.x;
+  params.y = location.y;
+  params.custom_context.is_pepper_menu = true;
+  params.custom_context.render_widget_id =
+      renderer_ppapi_host_->GetRoutingIDForWidget(pp_instance());
+  params.custom_items = menu_data_;
+
+  // Transform the position to be in render frame's coordinates.
+  gfx::Point render_frame_pt = renderer_ppapi_host_->PluginPointToRenderFrame(
+      pp_instance(), gfx::Point(location.x, location.y));
+  params.x = render_frame_pt.x();
+  params.y = render_frame_pt.y();
+
+  showing_context_menu_ = true;
+  context_menu_request_id_ = render_frame->ShowContextMenu(this, params);
+
+  // Note: the show message is sync so this OK is for the sync reply which we
+  // don't actually use (see the comment in the resource file for this). The
+  // async message containing the context menu action will be sent in the
+  // future.
+  return PP_OK;
+}
+
+void PepperFlashMenuHost::OnMenuAction(int request_id, unsigned action) {
+  // Just save the action.
+  DCHECK(!has_saved_context_menu_action_);
+  has_saved_context_menu_action_ = true;
+  saved_context_menu_action_ = action;
+}
+
+void PepperFlashMenuHost::OnMenuClosed(int request_id) {
+  if (has_saved_context_menu_action_ &&
+      saved_context_menu_action_ < menu_id_map_.size()) {
+    SendMenuReply(PP_OK, menu_id_map_[saved_context_menu_action_]);
+    has_saved_context_menu_action_ = false;
+    saved_context_menu_action_ = 0;
+  } else {
+    SendMenuReply(PP_ERROR_USERCANCEL, -1);
+  }
+
+  showing_context_menu_ = false;
+  context_menu_request_id_ = 0;
+}
+
+void PepperFlashMenuHost::SendMenuReply(int32_t result, int action) {
+  ppapi::host::ReplyMessageContext reply_context(
+      ppapi::proxy::ResourceMessageReplyParams(pp_resource(), 0),
+      NULL,
+      MSG_ROUTING_NONE);
+  reply_context.params.set_result(result);
+  host()->SendReply(reply_context, PpapiPluginMsg_FlashMenu_ShowReply(action));
+}
diff --git a/chromium_src/chrome/renderer/pepper/pepper_flash_menu_host.h b/chromium_src/chrome/renderer/pepper/pepper_flash_menu_host.h
new file mode 100644 (file)
index 0000000..3aa730a
--- /dev/null
@@ -0,0 +1,69 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_RENDERER_PEPPER_PEPPER_FLASH_MENU_HOST_H_
+#define CHROME_RENDERER_PEPPER_PEPPER_FLASH_MENU_HOST_H_
+
+#include <vector>
+
+#include "base/compiler_specific.h"
+#include "content/public/renderer/context_menu_client.h"
+#include "ppapi/c/pp_point.h"
+#include "ppapi/host/host_message_context.h"
+#include "ppapi/host/resource_host.h"
+
+namespace content {
+class RendererPpapiHost;
+struct MenuItem;
+}
+
+namespace ppapi {
+namespace proxy {
+class SerializedFlashMenu;
+}
+}
+
+class PepperFlashMenuHost : public ppapi::host::ResourceHost,
+                            public content::ContextMenuClient {
+ public:
+  PepperFlashMenuHost(content::RendererPpapiHost* host,
+                      PP_Instance instance,
+                      PP_Resource resource,
+                      const ppapi::proxy::SerializedFlashMenu& serial_menu);
+  ~PepperFlashMenuHost() override;
+
+  int32_t OnResourceMessageReceived(
+      const IPC::Message& msg,
+      ppapi::host::HostMessageContext* context) override;
+
+ private:
+  int32_t OnHostMsgShow(ppapi::host::HostMessageContext* context,
+                        const PP_Point& location);
+
+  // ContextMenuClient implementation.
+  void OnMenuAction(int request_id, unsigned action) override;
+  void OnMenuClosed(int request_id) override;
+
+  void SendMenuReply(int32_t result, int action);
+
+  content::RendererPpapiHost* renderer_ppapi_host_;
+
+  bool showing_context_menu_;
+  int context_menu_request_id_;
+
+  std::vector<content::MenuItem> menu_data_;
+
+  // We send |MenuItem|s, which have an |unsigned| "action" field instead of
+  // an |int32_t| ID. (CONTENT also limits the range of valid values for
+  // actions.) This maps actions to IDs.
+  std::vector<int32_t> menu_id_map_;
+
+  // Used to send a single context menu "completion" upon menu close.
+  bool has_saved_context_menu_action_;
+  unsigned saved_context_menu_action_;
+
+  DISALLOW_COPY_AND_ASSIGN(PepperFlashMenuHost);
+};
+
+#endif  // CHROME_RENDERER_PEPPER_PEPPER_FLASH_MENU_HOST_H_
diff --git a/chromium_src/chrome/renderer/pepper/pepper_flash_renderer_host.cc b/chromium_src/chrome/renderer/pepper/pepper_flash_renderer_host.cc
new file mode 100644 (file)
index 0000000..fe5e28e
--- /dev/null
@@ -0,0 +1,373 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/renderer/pepper/pepper_flash_renderer_host.h"
+
+#include <map>
+#include <vector>
+
+#include "base/lazy_instance.h"
+#include "base/metrics/histogram.h"
+#include "base/strings/string_util.h"
+#include "content/public/renderer/pepper_plugin_instance.h"
+#include "content/public/renderer/render_thread.h"
+#include "content/public/renderer/renderer_ppapi_host.h"
+#include "ipc/ipc_message_macros.h"
+#include "net/http/http_util.h"
+#include "ppapi/c/pp_errors.h"
+#include "ppapi/c/trusted/ppb_browser_font_trusted.h"
+#include "ppapi/host/dispatch_host_message.h"
+#include "ppapi/proxy/host_dispatcher.h"
+#include "ppapi/proxy/ppapi_messages.h"
+#include "ppapi/proxy/resource_message_params.h"
+#include "ppapi/proxy/serialized_structs.h"
+#include "ppapi/thunk/enter.h"
+#include "ppapi/thunk/ppb_image_data_api.h"
+#include "skia/ext/platform_canvas.h"
+#include "third_party/skia/include/core/SkCanvas.h"
+#include "third_party/skia/include/core/SkMatrix.h"
+#include "third_party/skia/include/core/SkPaint.h"
+#include "third_party/skia/include/core/SkPoint.h"
+#include "third_party/skia/include/core/SkTemplates.h"
+#include "third_party/skia/include/core/SkTypeface.h"
+#include "ui/gfx/geometry/rect.h"
+#include "url/gurl.h"
+
+using ppapi::thunk::EnterResourceNoLock;
+using ppapi::thunk::PPB_ImageData_API;
+
+namespace {
+
+// Some non-simple HTTP request headers that Flash may set.
+// (Please see http://www.w3.org/TR/cors/#simple-header for the definition of
+// simple headers.)
+//
+// The list and the enum defined below are used to collect data about request
+// headers used in PPB_Flash.Navigate() calls, in order to understand the impact
+// of rejecting PPB_Flash.Navigate() requests with non-simple headers.
+//
+// TODO(yzshen): We should be able to remove the histogram recording code once
+// we get the answer.
+const char* const kRejectedHttpRequestHeaders[] = {
+    "authorization",     //
+    "cache-control",     //
+    "content-encoding",  //
+    "content-md5",       //
+    "content-type",      // If the media type is not one of those covered by the
+                         // simple header definition.
+    "expires",           //
+    "from",              //
+    "if-match",          //
+    "if-none-match",     //
+    "if-range",          //
+    "if-unmodified-since",  //
+    "pragma",               //
+    "referer"               //
+};
+
+// Please note that new entries should be added right above
+// FLASH_NAVIGATE_USAGE_ENUM_COUNT, and existing entries shouldn't be re-ordered
+// or removed, since this ordering is used in a histogram.
+enum FlashNavigateUsage {
+  // This section must be in the same order as kRejectedHttpRequestHeaders.
+  REJECT_AUTHORIZATION = 0,
+  REJECT_CACHE_CONTROL,
+  REJECT_CONTENT_ENCODING,
+  REJECT_CONTENT_MD5,
+  REJECT_CONTENT_TYPE,
+  REJECT_EXPIRES,
+  REJECT_FROM,
+  REJECT_IF_MATCH,
+  REJECT_IF_NONE_MATCH,
+  REJECT_IF_RANGE,
+  REJECT_IF_UNMODIFIED_SINCE,
+  REJECT_PRAGMA,
+  REJECT_REFERER,
+
+  // The navigate request is rejected because of headers not listed above
+  // (e.g., custom headers).
+  REJECT_OTHER_HEADERS,
+
+  // Total number of rejected navigate requests.
+  TOTAL_REJECTED_NAVIGATE_REQUESTS,
+
+  // Total number of navigate requests.
+  TOTAL_NAVIGATE_REQUESTS,
+  FLASH_NAVIGATE_USAGE_ENUM_COUNT
+};
+
+static base::LazyInstance<std::map<std::string, FlashNavigateUsage> >
+    g_rejected_headers = LAZY_INSTANCE_INITIALIZER;
+
+bool IsSimpleHeader(const std::string& lower_case_header_name,
+                    const std::string& header_value) {
+  if (lower_case_header_name == "accept" ||
+      lower_case_header_name == "accept-language" ||
+      lower_case_header_name == "content-language") {
+    return true;
+  }
+
+  if (lower_case_header_name == "content-type") {
+    std::string lower_case_mime_type;
+    std::string lower_case_charset;
+    bool had_charset = false;
+    net::HttpUtil::ParseContentType(header_value,
+                                    &lower_case_mime_type,
+                                    &lower_case_charset,
+                                    &had_charset,
+                                    NULL);
+    return lower_case_mime_type == "application/x-www-form-urlencoded" ||
+           lower_case_mime_type == "multipart/form-data" ||
+           lower_case_mime_type == "text/plain";
+  }
+
+  return false;
+}
+
+void RecordFlashNavigateUsage(FlashNavigateUsage usage) {
+  DCHECK_NE(FLASH_NAVIGATE_USAGE_ENUM_COUNT, usage);
+  UMA_HISTOGRAM_ENUMERATION(
+      "Plugin.FlashNavigateUsage", usage, FLASH_NAVIGATE_USAGE_ENUM_COUNT);
+}
+
+}  // namespace
+
+PepperFlashRendererHost::PepperFlashRendererHost(
+    content::RendererPpapiHost* host,
+    PP_Instance instance,
+    PP_Resource resource)
+    : ResourceHost(host->GetPpapiHost(), instance, resource),
+      host_(host),
+      weak_factory_(this) {}
+
+PepperFlashRendererHost::~PepperFlashRendererHost() {
+  // This object may be destroyed in the middle of a sync message. If that is
+  // the case, make sure we respond to all the pending navigate calls.
+  std::vector<ppapi::host::ReplyMessageContext>::reverse_iterator it;
+  for (it = navigate_replies_.rbegin(); it != navigate_replies_.rend(); ++it)
+    SendReply(*it, IPC::Message());
+}
+
+int32_t PepperFlashRendererHost::OnResourceMessageReceived(
+    const IPC::Message& msg,
+    ppapi::host::HostMessageContext* context) {
+  PPAPI_BEGIN_MESSAGE_MAP(PepperFlashRendererHost, msg)
+    PPAPI_DISPATCH_HOST_RESOURCE_CALL(PpapiHostMsg_Flash_GetProxyForURL,
+                                      OnGetProxyForURL)
+    PPAPI_DISPATCH_HOST_RESOURCE_CALL(PpapiHostMsg_Flash_SetInstanceAlwaysOnTop,
+                                      OnSetInstanceAlwaysOnTop)
+    PPAPI_DISPATCH_HOST_RESOURCE_CALL(PpapiHostMsg_Flash_DrawGlyphs,
+                                      OnDrawGlyphs)
+    PPAPI_DISPATCH_HOST_RESOURCE_CALL(PpapiHostMsg_Flash_Navigate, OnNavigate)
+    PPAPI_DISPATCH_HOST_RESOURCE_CALL(PpapiHostMsg_Flash_IsRectTopmost,
+                                      OnIsRectTopmost)
+  PPAPI_END_MESSAGE_MAP()
+  return PP_ERROR_FAILED;
+}
+
+int32_t PepperFlashRendererHost::OnGetProxyForURL(
+    ppapi::host::HostMessageContext* host_context,
+    const std::string& url) {
+  GURL gurl(url);
+  if (!gurl.is_valid())
+    return PP_ERROR_FAILED;
+  std::string proxy;
+  bool result = content::RenderThread::Get()->ResolveProxy(gurl, &proxy);
+  if (!result)
+    return PP_ERROR_FAILED;
+  host_context->reply_msg = PpapiPluginMsg_Flash_GetProxyForURLReply(proxy);
+  return PP_OK;
+}
+
+int32_t PepperFlashRendererHost::OnSetInstanceAlwaysOnTop(
+    ppapi::host::HostMessageContext* host_context,
+    bool on_top) {
+  content::PepperPluginInstance* plugin_instance =
+      host_->GetPluginInstance(pp_instance());
+  if (plugin_instance)
+    plugin_instance->SetAlwaysOnTop(on_top);
+  // Since no reply is sent for this message, it doesn't make sense to return an
+  // error.
+  return PP_OK;
+}
+
+int32_t PepperFlashRendererHost::OnDrawGlyphs(
+    ppapi::host::HostMessageContext* host_context,
+    ppapi::proxy::PPBFlash_DrawGlyphs_Params params) {
+  if (params.glyph_indices.size() != params.glyph_advances.size() ||
+      params.glyph_indices.empty())
+    return PP_ERROR_FAILED;
+
+  // Set up the typeface.
+  int style = SkTypeface::kNormal;
+  if (static_cast<PP_BrowserFont_Trusted_Weight>(params.font_desc.weight) >=
+      PP_BROWSERFONT_TRUSTED_WEIGHT_BOLD)
+    style |= SkTypeface::kBold;
+  if (params.font_desc.italic)
+    style |= SkTypeface::kItalic;
+  skia::RefPtr<SkTypeface> typeface = skia::AdoptRef(SkTypeface::CreateFromName(
+      params.font_desc.face.c_str(), static_cast<SkTypeface::Style>(style)));
+  if (!typeface)
+    return PP_ERROR_FAILED;
+
+  EnterResourceNoLock<PPB_ImageData_API> enter(
+      params.image_data.host_resource(), true);
+  if (enter.failed())
+    return PP_ERROR_FAILED;
+
+  // Set up the canvas.
+  PPB_ImageData_API* image = static_cast<PPB_ImageData_API*>(enter.object());
+  SkCanvas* canvas = image->GetCanvas();
+  bool needs_unmapping = false;
+  if (!canvas) {
+    needs_unmapping = true;
+    image->Map();
+    canvas = image->GetCanvas();
+    if (!canvas)
+      return PP_ERROR_FAILED;  // Failure mapping.
+  }
+
+  SkAutoCanvasRestore acr(canvas, true);
+
+  // Clip is applied in pixels before the transform.
+  SkRect clip_rect = {
+      SkIntToScalar(params.clip.point.x), SkIntToScalar(params.clip.point.y),
+      SkIntToScalar(params.clip.point.x + params.clip.size.width),
+      SkIntToScalar(params.clip.point.y + params.clip.size.height)};
+  canvas->clipRect(clip_rect);
+
+  // Convert & set the matrix.
+  SkMatrix matrix;
+  matrix.set(SkMatrix::kMScaleX, SkFloatToScalar(params.transformation[0][0]));
+  matrix.set(SkMatrix::kMSkewX, SkFloatToScalar(params.transformation[0][1]));
+  matrix.set(SkMatrix::kMTransX, SkFloatToScalar(params.transformation[0][2]));
+  matrix.set(SkMatrix::kMSkewY, SkFloatToScalar(params.transformation[1][0]));
+  matrix.set(SkMatrix::kMScaleY, SkFloatToScalar(params.transformation[1][1]));
+  matrix.set(SkMatrix::kMTransY, SkFloatToScalar(params.transformation[1][2]));
+  matrix.set(SkMatrix::kMPersp0, SkFloatToScalar(params.transformation[2][0]));
+  matrix.set(SkMatrix::kMPersp1, SkFloatToScalar(params.transformation[2][1]));
+  matrix.set(SkMatrix::kMPersp2, SkFloatToScalar(params.transformation[2][2]));
+  canvas->concat(matrix);
+
+  SkPaint paint;
+  paint.setColor(params.color);
+  paint.setTextEncoding(SkPaint::kGlyphID_TextEncoding);
+  paint.setAntiAlias(true);
+  paint.setHinting(SkPaint::kFull_Hinting);
+  paint.setTextSize(SkIntToScalar(params.font_desc.size));
+  paint.setTypeface(typeface.get());  // Takes a ref and manages lifetime.
+  if (params.allow_subpixel_aa) {
+    paint.setSubpixelText(true);
+    paint.setLCDRenderText(true);
+  }
+
+  SkScalar x = SkIntToScalar(params.position.x);
+  SkScalar y = SkIntToScalar(params.position.y);
+
+  // Build up the skia advances.
+  size_t glyph_count = params.glyph_indices.size();
+  if (glyph_count) {
+    std::vector<SkPoint> storage;
+    storage.resize(glyph_count);
+    SkPoint* sk_positions = &storage[0];
+    for (uint32_t i = 0; i < glyph_count; i++) {
+      sk_positions[i].set(x, y);
+      x += SkFloatToScalar(params.glyph_advances[i].x);
+      y += SkFloatToScalar(params.glyph_advances[i].y);
+    }
+
+    canvas->drawPosText(
+        &params.glyph_indices[0], glyph_count * 2, sk_positions, paint);
+  }
+
+  if (needs_unmapping)
+    image->Unmap();
+
+  return PP_OK;
+}
+
+// CAUTION: This code is subtle because Navigate is a sync call which may
+// cause re-entrancy or cause the instance to be destroyed. If the instance
+// is destroyed we need to ensure that we respond to all outstanding sync
+// messages so that the plugin process does not remain blocked.
+int32_t PepperFlashRendererHost::OnNavigate(
+    ppapi::host::HostMessageContext* host_context,
+    const ppapi::URLRequestInfoData& data,
+    const std::string& target,
+    bool from_user_action) {
+  // If our PepperPluginInstance is already destroyed, just return a failure.
+  content::PepperPluginInstance* plugin_instance =
+      host_->GetPluginInstance(pp_instance());
+  if (!plugin_instance)
+    return PP_ERROR_FAILED;
+
+  std::map<std::string, FlashNavigateUsage>& rejected_headers =
+      g_rejected_headers.Get();
+  if (rejected_headers.empty()) {
+    for (size_t i = 0; i < arraysize(kRejectedHttpRequestHeaders); ++i)
+      rejected_headers[kRejectedHttpRequestHeaders[i]] =
+          static_cast<FlashNavigateUsage>(i);
+  }
+
+  net::HttpUtil::HeadersIterator header_iter(
+      data.headers.begin(), data.headers.end(), "\n\r");
+  bool rejected = false;
+  while (header_iter.GetNext()) {
+    std::string lower_case_header_name =
+        base::StringToLowerASCII(header_iter.name());
+    if (!IsSimpleHeader(lower_case_header_name, header_iter.values())) {
+      rejected = true;
+
+      std::map<std::string, FlashNavigateUsage>::const_iterator iter =
+          rejected_headers.find(lower_case_header_name);
+      FlashNavigateUsage usage =
+          iter != rejected_headers.end() ? iter->second : REJECT_OTHER_HEADERS;
+      RecordFlashNavigateUsage(usage);
+    }
+  }
+
+  RecordFlashNavigateUsage(TOTAL_NAVIGATE_REQUESTS);
+  if (rejected) {
+    RecordFlashNavigateUsage(TOTAL_REJECTED_NAVIGATE_REQUESTS);
+    return PP_ERROR_NOACCESS;
+  }
+
+  // Navigate may call into Javascript (e.g. with a "javascript:" URL),
+  // or do things like navigate away from the page, either one of which will
+  // need to re-enter into the plugin. It is safe, because it is essentially
+  // equivalent to NPN_GetURL, where Flash would expect re-entrancy.
+  ppapi::proxy::HostDispatcher* host_dispatcher =
+      ppapi::proxy::HostDispatcher::GetForInstance(pp_instance());
+  host_dispatcher->set_allow_plugin_reentrancy();
+
+  // Grab a weak pointer to ourselves on the stack so we can check if we are
+  // still alive.
+  base::WeakPtr<PepperFlashRendererHost> weak_ptr = weak_factory_.GetWeakPtr();
+  // Keep track of reply contexts in case we are destroyed during a Navigate
+  // call. Even if we are destroyed, we still need to send these replies to
+  // unblock the plugin process.
+  navigate_replies_.push_back(host_context->MakeReplyMessageContext());
+  plugin_instance->Navigate(data, target.c_str(), from_user_action);
+  // This object might have been destroyed by this point. If it is destroyed
+  // the reply will be sent in the destructor. Otherwise send the reply here.
+  if (weak_ptr.get()) {
+    SendReply(navigate_replies_.back(), IPC::Message());
+    navigate_replies_.pop_back();
+  }
+
+  // Return PP_OK_COMPLETIONPENDING so that no reply is automatically sent.
+  return PP_OK_COMPLETIONPENDING;
+}
+
+int32_t PepperFlashRendererHost::OnIsRectTopmost(
+    ppapi::host::HostMessageContext* host_context,
+    const PP_Rect& rect) {
+  content::PepperPluginInstance* plugin_instance =
+      host_->GetPluginInstance(pp_instance());
+  if (plugin_instance &&
+      plugin_instance->IsRectTopmost(gfx::Rect(
+          rect.point.x, rect.point.y, rect.size.width, rect.size.height)))
+    return PP_OK;
+  return PP_ERROR_FAILED;
+}
diff --git a/chromium_src/chrome/renderer/pepper/pepper_flash_renderer_host.h b/chromium_src/chrome/renderer/pepper/pepper_flash_renderer_host.h
new file mode 100644 (file)
index 0000000..de22f46
--- /dev/null
@@ -0,0 +1,69 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_RENDERER_PEPPER_PEPPER_FLASH_RENDERER_HOST_H_
+#define CHROME_RENDERER_PEPPER_PEPPER_FLASH_RENDERER_HOST_H_
+
+#include <string>
+#include <vector>
+
+#include "base/basictypes.h"
+#include "base/memory/weak_ptr.h"
+#include "ppapi/host/host_message_context.h"
+#include "ppapi/host/resource_host.h"
+
+struct PP_Rect;
+
+namespace ppapi {
+struct URLRequestInfoData;
+}
+
+namespace ppapi {
+namespace proxy {
+struct PPBFlash_DrawGlyphs_Params;
+}
+}
+
+namespace content {
+class RendererPpapiHost;
+}
+
+class PepperFlashRendererHost : public ppapi::host::ResourceHost {
+ public:
+  PepperFlashRendererHost(content::RendererPpapiHost* host,
+                          PP_Instance instance,
+                          PP_Resource resource);
+  ~PepperFlashRendererHost() override;
+
+  // ppapi::host::ResourceHost override.
+  int32_t OnResourceMessageReceived(
+      const IPC::Message& msg,
+      ppapi::host::HostMessageContext* context) override;
+
+ private:
+  int32_t OnGetProxyForURL(ppapi::host::HostMessageContext* host_context,
+                           const std::string& url);
+  int32_t OnSetInstanceAlwaysOnTop(
+      ppapi::host::HostMessageContext* host_context,
+      bool on_top);
+  int32_t OnDrawGlyphs(ppapi::host::HostMessageContext* host_context,
+                       ppapi::proxy::PPBFlash_DrawGlyphs_Params params);
+  int32_t OnNavigate(ppapi::host::HostMessageContext* host_context,
+                     const ppapi::URLRequestInfoData& data,
+                     const std::string& target,
+                     bool from_user_action);
+  int32_t OnIsRectTopmost(ppapi::host::HostMessageContext* host_context,
+                          const PP_Rect& rect);
+
+  // A stack of ReplyMessageContexts to track Navigate() calls which have not
+  // yet been replied to.
+  std::vector<ppapi::host::ReplyMessageContext> navigate_replies_;
+
+  content::RendererPpapiHost* host_;
+  base::WeakPtrFactory<PepperFlashRendererHost> weak_factory_;
+
+  DISALLOW_COPY_AND_ASSIGN(PepperFlashRendererHost);
+};
+
+#endif  // CHROME_RENDERER_PEPPER_PEPPER_FLASH_RENDERER_HOST_H_
diff --git a/chromium_src/chrome/renderer/pepper/pepper_helper.cc b/chromium_src/chrome/renderer/pepper/pepper_helper.cc
new file mode 100644 (file)
index 0000000..a610a30
--- /dev/null
@@ -0,0 +1,26 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/renderer/pepper/pepper_helper.h"
+
+#include "chrome/renderer/pepper/chrome_renderer_pepper_host_factory.h"
+#include "chrome/renderer/pepper/pepper_shared_memory_message_filter.h"
+#include "content/public/renderer/renderer_ppapi_host.h"
+#include "ppapi/host/ppapi_host.h"
+
+PepperHelper::PepperHelper(content::RenderFrame* render_frame)
+    : RenderFrameObserver(render_frame) {}
+
+PepperHelper::~PepperHelper() {}
+
+void PepperHelper::DidCreatePepperPlugin(content::RendererPpapiHost* host) {
+  // TODO(brettw) figure out how to hook up the host factory. It needs some
+  // kind of filter-like system to allow dynamic additions.
+  host->GetPpapiHost()->AddHostFactoryFilter(
+      scoped_ptr<ppapi::host::HostFactory>(
+          new ChromeRendererPepperHostFactory(host)));
+  host->GetPpapiHost()->AddInstanceMessageFilter(
+      scoped_ptr<ppapi::host::InstanceMessageFilter>(
+          new PepperSharedMemoryMessageFilter(host)));
+}
diff --git a/chromium_src/chrome/renderer/pepper/pepper_helper.h b/chromium_src/chrome/renderer/pepper/pepper_helper.h
new file mode 100644 (file)
index 0000000..b3e850b
--- /dev/null
@@ -0,0 +1,25 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_RENDERER_PEPPER_PEPPER_HELPER_H_
+#define CHROME_RENDERER_PEPPER_PEPPER_HELPER_H_
+
+#include "base/compiler_specific.h"
+#include "content/public/renderer/render_frame_observer.h"
+
+// This class listens for Pepper creation events from the RenderFrame and
+// attaches the parts required for Chrome-specific plugin support.
+class PepperHelper : public content::RenderFrameObserver {
+ public:
+  explicit PepperHelper(content::RenderFrame* render_frame);
+  ~PepperHelper() override;
+
+  // RenderFrameObserver.
+  void DidCreatePepperPlugin(content::RendererPpapiHost* host) override;
+
+ private:
+  DISALLOW_COPY_AND_ASSIGN(PepperHelper);
+};
+
+#endif  // CHROME_RENDERER_PEPPER_PEPPER_HELPER_H_
diff --git a/chromium_src/chrome/renderer/pepper/pepper_shared_memory_message_filter.cc b/chromium_src/chrome/renderer/pepper/pepper_shared_memory_message_filter.cc
new file mode 100644 (file)
index 0000000..e01aea7
--- /dev/null
@@ -0,0 +1,72 @@
+// Copyright (c) 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/renderer/pepper/pepper_shared_memory_message_filter.h"
+
+#include "base/memory/scoped_ptr.h"
+#include "base/memory/shared_memory.h"
+#include "base/process/process_handle.h"
+#include "content/public/common/content_client.h"
+#include "content/public/renderer/pepper_plugin_instance.h"
+#include "content/public/renderer/render_thread.h"
+#include "content/public/renderer/renderer_ppapi_host.h"
+#include "ppapi/host/ppapi_host.h"
+#include "ppapi/proxy/ppapi_messages.h"
+#include "ppapi/shared_impl/var_tracker.h"
+
+PepperSharedMemoryMessageFilter::PepperSharedMemoryMessageFilter(
+    content::RendererPpapiHost* host)
+    : InstanceMessageFilter(host->GetPpapiHost()), host_(host) {}
+
+PepperSharedMemoryMessageFilter::~PepperSharedMemoryMessageFilter() {}
+
+bool PepperSharedMemoryMessageFilter::OnInstanceMessageReceived(
+    const IPC::Message& msg) {
+  bool handled = true;
+  IPC_BEGIN_MESSAGE_MAP(PepperSharedMemoryMessageFilter, msg)
+    IPC_MESSAGE_HANDLER(PpapiHostMsg_SharedMemory_CreateSharedMemory,
+                        OnHostMsgCreateSharedMemory)
+    IPC_MESSAGE_UNHANDLED(handled = false)
+  IPC_END_MESSAGE_MAP()
+  return handled;
+}
+
+bool PepperSharedMemoryMessageFilter::Send(IPC::Message* msg) {
+  return host_->GetPpapiHost()->Send(msg);
+}
+
+void PepperSharedMemoryMessageFilter::OnHostMsgCreateSharedMemory(
+    PP_Instance instance,
+    uint32_t size,
+    int* host_handle_id,
+    ppapi::proxy::SerializedHandle* plugin_handle) {
+  plugin_handle->set_null_shmem();
+  *host_handle_id = -1;
+  scoped_ptr<base::SharedMemory> shm(content::RenderThread::Get()
+                                         ->HostAllocateSharedMemoryBuffer(size)
+                                         .Pass());
+  if (!shm.get())
+    return;
+
+  base::SharedMemoryHandle host_shm_handle;
+  shm->ShareToProcess(base::GetCurrentProcessHandle(), &host_shm_handle);
+  *host_handle_id =
+      content::PepperPluginInstance::Get(instance)
+          ->GetVarTracker()
+          ->TrackSharedMemoryHandle(instance, host_shm_handle, size);
+
+  base::PlatformFile host_handle =
+#if defined(OS_WIN)
+      host_shm_handle;
+#elif defined(OS_POSIX)
+      host_shm_handle.fd;
+#else
+#error Not implemented.
+#endif
+  // We set auto_close to false since we need our file descriptor to
+  // actually be duplicated on linux. The shared memory destructor will
+  // close the original handle for us.
+  plugin_handle->set_shmem(host_->ShareHandleWithRemote(host_handle, false),
+                           size);
+}
diff --git a/chromium_src/chrome/renderer/pepper/pepper_shared_memory_message_filter.h b/chromium_src/chrome/renderer/pepper/pepper_shared_memory_message_filter.h
new file mode 100644 (file)
index 0000000..d7e0934
--- /dev/null
@@ -0,0 +1,48 @@
+// Copyright (c) 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_RENDERER_PEPPER_PEPPER_SHARED_MEMORY_MESSAGE_FILTER_H_
+#define CHROME_RENDERER_PEPPER_PEPPER_SHARED_MEMORY_MESSAGE_FILTER_H_
+
+#include "base/basictypes.h"
+#include "base/compiler_specific.h"
+#include "ppapi/c/pp_instance.h"
+#include "ppapi/host/instance_message_filter.h"
+
+namespace content {
+class RendererPpapiHost;
+}
+
+namespace ppapi {
+namespace proxy {
+class SerializedHandle;
+}
+}
+
+// Implements the backend for shared memory messages from a plugin process.
+class PepperSharedMemoryMessageFilter
+    : public ppapi::host::InstanceMessageFilter {
+ public:
+  explicit PepperSharedMemoryMessageFilter(content::RendererPpapiHost* host);
+  ~PepperSharedMemoryMessageFilter() override;
+
+  // InstanceMessageFilter:
+  bool OnInstanceMessageReceived(const IPC::Message& msg) override;
+
+  bool Send(IPC::Message* msg);
+
+ private:
+  // Message handlers.
+  void OnHostMsgCreateSharedMemory(
+      PP_Instance instance,
+      uint32_t size,
+      int* host_shm_handle_id,
+      ppapi::proxy::SerializedHandle* plugin_shm_handle);
+
+  content::RendererPpapiHost* host_;
+
+  DISALLOW_COPY_AND_ASSIGN(PepperSharedMemoryMessageFilter);
+};
+
+#endif  // CHROME_RENDERER_PEPPER_PEPPER_SHARED_MEMORY_MESSAGE_FILTER_H_
index bb1e7e5..c275af7 100644 (file)
       'chromium_src/chrome/browser/printing/printer_query.h',
       'chromium_src/chrome/browser/printing/printing_message_filter.cc',
       'chromium_src/chrome/browser/printing/printing_message_filter.h',
+      'chromium_src/chrome/browser/renderer_host/pepper/chrome_browser_pepper_host_factory.cc',
+      'chromium_src/chrome/browser/renderer_host/pepper/chrome_browser_pepper_host_factory.h',
+      'chromium_src/chrome/browser/renderer_host/pepper/pepper_broker_message_filter.cc',
+      'chromium_src/chrome/browser/renderer_host/pepper/pepper_broker_message_filter.h',
+      'chromium_src/chrome/browser/renderer_host/pepper/pepper_flash_browser_host.cc',
+      'chromium_src/chrome/browser/renderer_host/pepper/pepper_flash_browser_host.h',
+      'chromium_src/chrome/browser/renderer_host/pepper/pepper_flash_clipboard_message_filter.cc',
+      'chromium_src/chrome/browser/renderer_host/pepper/pepper_flash_clipboard_message_filter.h',
+      'chromium_src/chrome/browser/renderer_host/pepper/pepper_isolated_file_system_message_filter.cc',
+      'chromium_src/chrome/browser/renderer_host/pepper/pepper_isolated_file_system_message_filter.h',
       'chromium_src/chrome/browser/speech/tts_controller.h',
       'chromium_src/chrome/browser/speech/tts_controller_impl.cc',
       'chromium_src/chrome/browser/speech/tts_controller_impl.h',
       'chromium_src/chrome/common/tts_messages.h',
       'chromium_src/chrome/common/tts_utterance_request.cc',
       'chromium_src/chrome/common/tts_utterance_request.h',
+      'chromium_src/chrome/renderer/pepper/chrome_renderer_pepper_host_factory.cc',
+      'chromium_src/chrome/renderer/pepper/chrome_renderer_pepper_host_factory.h',
+      'chromium_src/chrome/renderer/pepper/pepper_flash_drm_renderer_host.cc',
+      'chromium_src/chrome/renderer/pepper/pepper_flash_drm_renderer_host.h',
+      'chromium_src/chrome/renderer/pepper/pepper_flash_font_file_host.cc',
+      'chromium_src/chrome/renderer/pepper/pepper_flash_font_file_host.h',
+      'chromium_src/chrome/renderer/pepper/pepper_flash_fullscreen_host.cc',
+      'chromium_src/chrome/renderer/pepper/pepper_flash_fullscreen_host.h',
+      'chromium_src/chrome/renderer/pepper/pepper_flash_menu_host.cc',
+      'chromium_src/chrome/renderer/pepper/pepper_flash_menu_host.h',
+      'chromium_src/chrome/renderer/pepper/pepper_flash_renderer_host.cc',      
+      'chromium_src/chrome/renderer/pepper/pepper_flash_renderer_host.h',
+      'chromium_src/chrome/renderer/pepper/pepper_helper.cc',
+      'chromium_src/chrome/renderer/pepper/pepper_helper.h',
+      'chromium_src/chrome/renderer/pepper/pepper_shared_memory_message_filter.cc',
+      'chromium_src/chrome/renderer/pepper/pepper_shared_memory_message_filter.h',
       'chromium_src/chrome/renderer/printing/print_web_view_helper.cc',
       'chromium_src/chrome/renderer/printing/print_web_view_helper_linux.cc',
       'chromium_src/chrome/renderer/printing/print_web_view_helper_mac.mm',