summaryrefslogtreecommitdiffstats
path: root/content
diff options
context:
space:
mode:
authoryzshen@chromium.org <yzshen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-05-27 07:18:46 +0000
committeryzshen@chromium.org <yzshen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-05-27 07:18:46 +0000
commit1a559448088694cd4dc077c7a14436942fda5061 (patch)
treec539c7259f878cf6c43bbbbc2515eaa46b0f4f45 /content
parent3f84377fbfae99a755a20f8a9a5390526cec9ce1 (diff)
downloadchromium_src-1a559448088694cd4dc077c7a14436942fda5061.zip
chromium_src-1a559448088694cd4dc077c7a14436942fda5061.tar.gz
chromium_src-1a559448088694cd4dc077c7a14436942fda5061.tar.bz2
Pepper Flash settings integration: implement "deauthorize content licenses".
A few notes about PepperFlashSettingsManager: - It doesn't re-establish a channel for each request. It might seem unnecessary at this point. But that is needed for implementing content settings (camera/mic and peer networking), which requires more interactions with the broker process. - Similarly, the support of multiple in-flight requests isn't very useful for deauthorizing content licenses, but that is useful for content settings, e.g., sending multiple GetPermissionSettings requests for different setting types. BUG=112190 TEST=None Review URL: https://chromiumcodereview.appspot.com/10391173 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@139210 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content')
-rw-r--r--content/browser/pepper_flash_settings_helper_impl.cc71
-rw-r--r--content/browser/pepper_flash_settings_helper_impl.h44
-rw-r--r--content/browser/renderer_host/pepper_file_message_filter.cc3
-rw-r--r--content/content_browser.gypi3
-rw-r--r--content/ppapi_plugin/broker_process_dispatcher.cc42
-rw-r--r--content/ppapi_plugin/broker_process_dispatcher.h4
-rw-r--r--content/public/browser/pepper_flash_settings_helper.h43
-rw-r--r--content/public/common/content_constants.cc2
-rw-r--r--content/public/common/content_constants.h3
9 files changed, 207 insertions, 8 deletions
diff --git a/content/browser/pepper_flash_settings_helper_impl.cc b/content/browser/pepper_flash_settings_helper_impl.cc
new file mode 100644
index 0000000..2f9e698
--- /dev/null
+++ b/content/browser/pepper_flash_settings_helper_impl.cc
@@ -0,0 +1,71 @@
+// 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 "content/browser/pepper_flash_settings_helper_impl.h"
+
+#include "base/file_path.h"
+#include "content/browser/plugin_service_impl.h"
+#include "content/public/browser/browser_thread.h"
+#include "ipc/ipc_channel_handle.h"
+
+namespace content {
+
+// static
+scoped_refptr<PepperFlashSettingsHelper> PepperFlashSettingsHelper::Create() {
+ return new PepperFlashSettingsHelperImpl();
+}
+
+PepperFlashSettingsHelperImpl::PepperFlashSettingsHelperImpl() {
+}
+
+PepperFlashSettingsHelperImpl::~PepperFlashSettingsHelperImpl() {
+}
+
+void PepperFlashSettingsHelperImpl::OpenChannelToBroker(
+ const FilePath& path,
+ const OpenChannelCallback& callback) {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
+
+ if (callback.is_null())
+ return;
+ if (!callback_.is_null())
+ callback.Run(false, IPC::ChannelHandle());
+
+ // Balanced in OnPpapiChannelOpened(). We need to keep this object around
+ // until then.
+ AddRef();
+
+ callback_ = callback;
+ PluginServiceImpl* plugin_service = PluginServiceImpl::GetInstance();
+ plugin_service->OpenChannelToPpapiBroker(path, this);
+}
+
+void PepperFlashSettingsHelperImpl::GetPpapiChannelInfo(
+ base::ProcessHandle* renderer_handle,
+ int* renderer_id) {
+ *renderer_handle = base::kNullProcessHandle;
+ *renderer_id = 0;
+}
+
+void PepperFlashSettingsHelperImpl::OnPpapiChannelOpened(
+ const IPC::ChannelHandle& channel_handle,
+ int /* plugin_child_id */) {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
+ DCHECK(!callback_.is_null());
+
+ if (!channel_handle.name.empty())
+ callback_.Run(true, channel_handle);
+ else
+ callback_.Run(false, IPC::ChannelHandle());
+
+ callback_.Reset();
+ // Balance the AddRef() call in Initialize().
+ Release();
+}
+
+bool PepperFlashSettingsHelperImpl::OffTheRecord() {
+ return false;
+}
+
+} // namespace content
diff --git a/content/browser/pepper_flash_settings_helper_impl.h b/content/browser/pepper_flash_settings_helper_impl.h
new file mode 100644
index 0000000..bfecc00
--- /dev/null
+++ b/content/browser/pepper_flash_settings_helper_impl.h
@@ -0,0 +1,44 @@
+// 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 CONTENT_BROWSER_PEPPER_FLASH_SETTINGS_HELPER_IMPL_H_
+#define CONTENT_BROWSER_PEPPER_FLASH_SETTINGS_HELPER_IMPL_H_
+#pragma once
+
+#include "base/basictypes.h"
+#include "base/compiler_specific.h"
+#include "content/browser/ppapi_plugin_process_host.h"
+#include "content/public/browser/pepper_flash_settings_helper.h"
+
+namespace content {
+
+class CONTENT_EXPORT PepperFlashSettingsHelperImpl
+ : public PepperFlashSettingsHelper,
+ public PpapiPluginProcessHost::BrokerClient {
+ public:
+ PepperFlashSettingsHelperImpl();
+
+ // PepperFlashSettingsHelper implementation.
+ virtual void OpenChannelToBroker(
+ const FilePath& path,
+ const OpenChannelCallback& callback) OVERRIDE;
+
+ // PpapiPluginProcessHost::BrokerClient implementation.
+ virtual void GetPpapiChannelInfo(base::ProcessHandle* renderer_handle,
+ int* renderer_id) OVERRIDE;
+ virtual void OnPpapiChannelOpened(const IPC::ChannelHandle& channel_handle,
+ int plugin_child_id) OVERRIDE;
+ virtual bool OffTheRecord() OVERRIDE;
+
+ protected:
+ virtual ~PepperFlashSettingsHelperImpl();
+
+ private:
+ OpenChannelCallback callback_;
+ DISALLOW_COPY_AND_ASSIGN(PepperFlashSettingsHelperImpl);
+};
+
+} // namespace content
+
+#endif // CONTENT_BROWSER_PEPPER_FLASH_SETTINGS_HELPER_IMPL_H_
diff --git a/content/browser/renderer_host/pepper_file_message_filter.cc b/content/browser/renderer_host/pepper_file_message_filter.cc
index 10b3430..e8b3a92 100644
--- a/content/browser/renderer_host/pepper_file_message_filter.cc
+++ b/content/browser/renderer_host/pepper_file_message_filter.cc
@@ -14,6 +14,7 @@
#include "content/common/pepper_file_messages.h"
#include "content/public/browser/browser_context.h"
#include "content/public/browser/browser_thread.h"
+#include "content/public/common/content_constants.h"
#include "ipc/ipc_platform_file.h"
#include "webkit/plugins/ppapi/file_path.h"
@@ -72,7 +73,7 @@ void PepperFileMessageFilter::OnDestruct() const {
// static
FilePath PepperFileMessageFilter::GetDataDirName(const FilePath& profile_path) {
- return profile_path.Append(FILE_PATH_LITERAL("Pepper Data"));
+ return profile_path.Append(content::kPepperDataDirname);
}
PepperFileMessageFilter::~PepperFileMessageFilter() {
diff --git a/content/content_browser.gypi b/content/content_browser.gypi
index d64bd05..02bdcf7 100644
--- a/content/content_browser.gypi
+++ b/content/content_browser.gypi
@@ -105,6 +105,7 @@
'public/browser/notification_types.h',
'public/browser/page_navigator.cc',
'public/browser/page_navigator.h',
+ 'public/browser/pepper_flash_settings_helper.h',
'public/browser/plugin_data_remover.h',
'public/browser/plugin_service_filter.h',
'public/browser/plugin_service.h',
@@ -429,6 +430,8 @@
'browser/net/view_http_cache_job_factory.h',
'browser/notification_service_impl.cc',
'browser/notification_service_impl.h',
+ 'browser/pepper_flash_settings_helper_impl.cc',
+ 'browser/pepper_flash_settings_helper_impl.h',
'browser/plugin_data_remover_impl.cc',
'browser/plugin_data_remover_impl.h',
'browser/plugin_loader_posix.cc',
diff --git a/content/ppapi_plugin/broker_process_dispatcher.cc b/content/ppapi_plugin/broker_process_dispatcher.cc
index 6d5ffa8..7844639 100644
--- a/content/ppapi_plugin/broker_process_dispatcher.cc
+++ b/content/ppapi_plugin/broker_process_dispatcher.cc
@@ -8,6 +8,7 @@
#include "base/bind_helpers.h"
#include "base/utf_string_conversions.h"
#include "content/common/child_process.h"
+#include "ppapi/c/pp_bool.h"
#include "ppapi/c/private/ppp_flash_browser_operations.h"
#include "ppapi/proxy/ppapi_messages.h"
@@ -16,6 +17,15 @@ namespace {
// How long we wait before releasing the broker process.
const int kBrokerReleaseTimeSeconds = 30;
+std::string ConvertPluginDataPath(const FilePath& plugin_data_path) {
+ // The string is always 8-bit, convert on Windows.
+#if defined(OS_WIN)
+ return WideToUTF8(plugin_data_path.value());
+#else
+ return plugin_data_path.value();
+#endif
+}
+
} // namespace
BrokerProcessDispatcher::BrokerProcessDispatcher(
@@ -43,6 +53,8 @@ BrokerProcessDispatcher::~BrokerProcessDispatcher() {
bool BrokerProcessDispatcher::OnMessageReceived(const IPC::Message& msg) {
IPC_BEGIN_MESSAGE_MAP(BrokerProcessDispatcher, msg)
IPC_MESSAGE_HANDLER(PpapiMsg_ClearSiteData, OnMsgClearSiteData)
+ IPC_MESSAGE_HANDLER(PpapiMsg_DeauthorizeContentLicenses,
+ OnMsgDeauthorizeContentLicenses)
IPC_MESSAGE_UNHANDLED(return BrokerSideDispatcher::OnMessageReceived(msg))
IPC_END_MESSAGE_MAP()
return true;
@@ -57,6 +69,13 @@ void BrokerProcessDispatcher::OnMsgClearSiteData(
ClearSiteData(plugin_data_path, site, flags, max_age)));
}
+void BrokerProcessDispatcher::OnMsgDeauthorizeContentLicenses(
+ uint32 request_id,
+ const FilePath& plugin_data_path) {
+ Send(new PpapiHostMsg_DeauthorizeContentLicensesResult(
+ request_id, DeauthorizeContentLicenses(plugin_data_path)));
+}
+
bool BrokerProcessDispatcher::ClearSiteData(const FilePath& plugin_data_path,
const std::string& site,
uint64 flags,
@@ -69,16 +88,25 @@ bool BrokerProcessDispatcher::ClearSiteData(const FilePath& plugin_data_path,
if (!browser_interface)
return false;
- // The string is always 8-bit, convert on Windows.
-#if defined(OS_WIN)
- std::string data_str = WideToUTF8(plugin_data_path.value());
-#else
- std::string data_str = plugin_data_path.value();
-#endif
-
+ std::string data_str = ConvertPluginDataPath(plugin_data_path);
browser_interface->ClearSiteData(data_str.c_str(),
site.empty() ? NULL : site.c_str(),
flags, max_age);
return true;
}
+bool BrokerProcessDispatcher::DeauthorizeContentLicenses(
+ const FilePath& plugin_data_path) {
+ if (!get_plugin_interface_)
+ return false;
+ const PPP_Flash_BrowserOperations_1_1* browser_interface =
+ static_cast<const PPP_Flash_BrowserOperations_1_1*>(
+ get_plugin_interface_(PPP_FLASH_BROWSEROPERATIONS_INTERFACE_1_1));
+ if (!browser_interface)
+ return false;
+
+ std::string data_str = ConvertPluginDataPath(plugin_data_path);
+ return PP_ToBool(browser_interface->DeauthorizeContentLicenses(
+ data_str.c_str()));
+}
+
diff --git a/content/ppapi_plugin/broker_process_dispatcher.h b/content/ppapi_plugin/broker_process_dispatcher.h
index abf1124..b33a4e8 100644
--- a/content/ppapi_plugin/broker_process_dispatcher.h
+++ b/content/ppapi_plugin/broker_process_dispatcher.h
@@ -27,11 +27,15 @@ class BrokerProcessDispatcher : public ppapi::proxy::BrokerSideDispatcher {
uint64 flags,
uint64 max_age);
+ void OnMsgDeauthorizeContentLicenses(uint32 request_id,
+ const FilePath& plugin_data_path);
+
// Requests that the plugin clear data, returning true on success.
bool ClearSiteData(const FilePath& plugin_data_path,
const std::string& site,
uint64 flags,
uint64 max_age);
+ bool DeauthorizeContentLicenses(const FilePath& plugin_data_path);
PP_GetInterface_Func get_plugin_interface_;
diff --git a/content/public/browser/pepper_flash_settings_helper.h b/content/public/browser/pepper_flash_settings_helper.h
new file mode 100644
index 0000000..e01002b7
--- /dev/null
+++ b/content/public/browser/pepper_flash_settings_helper.h
@@ -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.
+
+#ifndef CONTENT_PUBLIC_BROWSER_PEPPER_FLASH_SETTINGS_HELPER_H_
+#define CONTENT_PUBLIC_BROWSER_PEPPER_FLASH_SETTINGS_HELPER_H_
+#pragma once
+
+#include "base/callback.h"
+#include "base/memory/ref_counted.h"
+#include "content/common/content_export.h"
+
+class FilePath;
+
+namespace IPC {
+struct ChannelHandle;
+}
+
+namespace content {
+
+// This class should only be used on the IO thread.
+class CONTENT_EXPORT PepperFlashSettingsHelper
+ : public base::RefCounted<PepperFlashSettingsHelper> {
+ public:
+ static scoped_refptr<PepperFlashSettingsHelper> Create();
+
+ // Called when OpenChannelToBroker() is completed.
+ // |success| indicates whether the channel is successfully opened to the
+ // broker. On error, |channel_handle| is set to IPC::ChannelHandle().
+ typedef base::Callback<void(bool /* success */,
+ const IPC::ChannelHandle& /* channel_handle */)>
+ OpenChannelCallback;
+ virtual void OpenChannelToBroker(const FilePath& path,
+ const OpenChannelCallback& callback) = 0;
+
+ protected:
+ friend class base::RefCounted<PepperFlashSettingsHelper>;
+ virtual ~PepperFlashSettingsHelper() {}
+};
+
+} // namespace content
+
+#endif // CONTENT_PUBLIC_BROWSER_PEPPER_FLASH_SETTINGS_HELPER_H_
diff --git a/content/public/common/content_constants.cc b/content/public/common/content_constants.cc
index b0e3b58..94536cc 100644
--- a/content/public/common/content_constants.cc
+++ b/content/public/common/content_constants.cc
@@ -7,6 +7,8 @@ namespace content {
const FilePath::CharType kAppCacheDirname[] =
FILE_PATH_LITERAL("Application Cache");
+const FilePath::CharType kPepperDataDirname[] =
+ FILE_PATH_LITERAL("Pepper Data");
// This number used to be limited to 32 in the past (see b/535234).
const size_t kMaxRendererProcessCount = 82;
diff --git a/content/public/common/content_constants.h b/content/public/common/content_constants.h
index 0df8b8b..e6a1124 100644
--- a/content/public/common/content_constants.h
+++ b/content/public/common/content_constants.h
@@ -18,6 +18,9 @@ namespace content {
// The name of the directory under BrowserContext::GetPath where the AppCache is
// put.
CONTENT_EXPORT extern const FilePath::CharType kAppCacheDirname[];
+// The name of the directory under BrowserContext::GetPath where Pepper plugin
+// data is put.
+CONTENT_EXPORT extern const FilePath::CharType kPepperDataDirname[];
CONTENT_EXPORT extern const size_t kMaxRendererProcessCount;