Commit 2fe1d332 authored by Marshall Greenblatt's avatar Marshall Greenblatt

Add Pepper Flash plugin support (issue #1586).

A system-wide installation of the Pepper Flash plugin is available from Adobe
for Windows and Mac OS X platforms as a separate download. To enable automatic
detection and loading of the system-wide installation pass the
`--enable-system-flash` command-line flag.

The Pepper Flash plugin can also be loaded by specifying the file path and
version via the `--ppapi-flash-path=<path> --ppapi-flash-version=<version>`
command-line flags. The version can be identified by viewing the
manifest.json file in the same directory as the Pepper Flash plugin library.
parent 1772ac02
......@@ -864,6 +864,7 @@
'<(DEPTH)/components/components.gyp:keyed_service_content',
'<(DEPTH)/components/components.gyp:keyed_service_core',
'<(DEPTH)/components/components.gyp:navigation_interception',
'<(DEPTH)/components/components.gyp:pdf_renderer',
'<(DEPTH)/components/components.gyp:pref_registry',
'<(DEPTH)/components/components.gyp:printing_common',
'<(DEPTH)/components/components.gyp:printing_renderer',
......@@ -878,6 +879,7 @@
'<(DEPTH)/content/content.gyp:content_renderer',
'<(DEPTH)/content/content.gyp:content_resources',
'<(DEPTH)/content/content.gyp:content_utility',
'<(DEPTH)/crypto/crypto.gyp:crypto',
'<(DEPTH)/gpu/gpu.gyp:gpu',
'<(DEPTH)/ipc/ipc.gyp:ipc',
'<(DEPTH)/media/blink/media_blink.gyp:media_blink',
......@@ -969,6 +971,11 @@
'libcef/browser/origin_whitelist_impl.cc',
'libcef/browser/origin_whitelist_impl.h',
'libcef/browser/path_util_impl.cc',
'libcef/browser/pepper/browser_pepper_host_factory.cc',
'libcef/browser/pepper/browser_pepper_host_factory.h',
'libcef/browser/pepper/pepper_flash_browser_host.cc',
'libcef/browser/pepper/pepper_flash_browser_host.h',
'libcef/browser/pepper/device_id_fetcher.cc',
'libcef/browser/print_settings_impl.cc',
'libcef/browser/print_settings_impl.h',
'libcef/browser/printing/printing_message_filter.cc',
......@@ -1096,6 +1103,10 @@
'libcef/renderer/dom_node_impl.h',
'libcef/renderer/frame_impl.cc',
'libcef/renderer/frame_impl.h',
'libcef/renderer/pepper/pepper_helper.cc',
'libcef/renderer/pepper/pepper_helper.h',
'libcef/renderer/pepper/renderer_pepper_host_factory.cc',
'libcef/renderer/pepper/renderer_pepper_host_factory.h',
'libcef/renderer/render_frame_observer.cc',
'libcef/renderer/render_frame_observer.h',
'libcef/renderer/render_message_filter.cc',
......@@ -1176,6 +1187,7 @@
'<(DEPTH)/chrome/browser/spellchecker/spelling_service_client.cc',
'<(DEPTH)/chrome/browser/spellchecker/spelling_service_client.h',
'<(DEPTH)/chrome/common/chrome_constants.cc',
'<(DEPTH)/chrome/common/chrome_constants.h',
'<(DEPTH)/chrome/common/spellcheck_common.cc',
'<(DEPTH)/chrome/common/spellcheck_common.h',
'<(DEPTH)/chrome/common/spellcheck_marker.h',
......@@ -1194,6 +1206,25 @@
'<(DEPTH)/chrome/renderer/spellchecker/spellcheck_worditerator.cc',
'<(DEPTH)/chrome/renderer/spellchecker/spellcheck_worditerator.h',
'<(DEPTH)/chrome/renderer/spellchecker/spelling_engine.h',
# Include sources for pepper flash support.
'<(DEPTH)/chrome/common/pepper_flash.cc',
'<(DEPTH)/chrome/common/pepper_flash.h',
'<(DEPTH)/chrome/common/ppapi_utils.cc',
'<(DEPTH)/chrome/common/ppapi_utils.h',
'<(DEPTH)/chrome/browser/renderer_host/pepper/pepper_flash_clipboard_message_filter.cc',
'<(DEPTH)/chrome/browser/renderer_host/pepper/pepper_flash_clipboard_message_filter.h',
'<(DEPTH)/chrome/browser/renderer_host/pepper/pepper_flash_drm_host.cc',
'<(DEPTH)/chrome/browser/renderer_host/pepper/pepper_flash_drm_host.h',
'<(DEPTH)/chrome/renderer/pepper/pepper_flash_drm_renderer_host.cc',
'<(DEPTH)/chrome/renderer/pepper/pepper_flash_drm_renderer_host.h',
'<(DEPTH)/chrome/renderer/pepper/pepper_flash_font_file_host.cc',
'<(DEPTH)/chrome/renderer/pepper/pepper_flash_font_file_host.h',
'<(DEPTH)/chrome/renderer/pepper/pepper_flash_fullscreen_host.cc',
'<(DEPTH)/chrome/renderer/pepper/pepper_flash_fullscreen_host.h',
'<(DEPTH)/chrome/renderer/pepper/pepper_flash_menu_host.cc',
'<(DEPTH)/chrome/renderer/pepper/pepper_flash_menu_host.h',
'<(DEPTH)/chrome/renderer/pepper/pepper_flash_renderer_host.cc',
'<(DEPTH)/chrome/renderer/pepper/pepper_flash_renderer_host.h',
],
'conditions': [
['OS=="win"', {
......@@ -1228,6 +1259,8 @@
'libcef/browser/render_widget_host_view_osr_mac.mm',
'libcef/browser/text_input_client_osr_mac.mm',
'libcef/browser/text_input_client_osr_mac.h',
'libcef/common/util_mac.h',
'libcef/common/util_mac.mm',
# Include sources for spell checking support.
'<(DEPTH)/chrome/browser/spellchecker/spellcheck_message_filter_mac.cc',
'<(DEPTH)/chrome/browser/spellchecker/spellcheck_message_filter_mac.h',
......@@ -1235,6 +1268,9 @@
'<(DEPTH)/chrome/browser/spellchecker/spellcheck_platform_mac.mm',
'<(DEPTH)/chrome/renderer/spellchecker/cocoa_spelling_engine_mac.cc',
'<(DEPTH)/chrome/renderer/spellchecker/cocoa_spelling_engine_mac.h',
# Include sources for pepper flash support.
'<(DEPTH)/chrome/browser/renderer_host/pepper/monitor_finder_mac.h',
'<(DEPTH)/chrome/browser/renderer_host/pepper/monitor_finder_mac.mm',
],
}],
[ 'OS=="linux" or OS=="freebsd" or OS=="openbsd"', {
......@@ -1757,4 +1793,4 @@
],
}], # OS=="win"
],
}
\ No newline at end of file
}
......@@ -2394,6 +2394,17 @@ void CefBrowserHostImpl::RequestMediaAccessPermission(
scoped_ptr<content::MediaStreamUI>());
}
bool CefBrowserHostImpl::CheckMediaAccessPermission(
content::WebContents* web_contents,
const GURL& security_origin,
content::MediaStreamType type) {
// Check media access permission without prompting the user. This is called
// when loading the Pepper Flash plugin.
const base::CommandLine* command_line =
base::CommandLine::ForCurrentProcess();
return command_line->HasSwitch(switches::kEnableMediaStream);
}
// content::WebContentsObserver methods.
// -----------------------------------------------------------------------------
......
......@@ -415,6 +415,9 @@ class CefBrowserHostImpl : public CefBrowserHost,
content::WebContents* web_contents,
const content::MediaStreamRequest& request,
const content::MediaResponseCallback& callback) override;
bool CheckMediaAccessPermission(content::WebContents* web_contents,
const GURL& security_origin,
content::MediaStreamType type) override;
// content::WebContentsObserver methods.
using content::WebContentsObserver::BeforeUnloadFired;
......
......@@ -92,6 +92,7 @@ scoped_ptr<PrefService> CefBrowserPrefStore::CreateService() {
registry->RegisterBooleanPref(prefs::kPrintingEnabled, true);
// Spell checking settings.
// Based on SpellcheckServiceFactory::RegisterProfilePrefs.
std::string spellcheck_lang =
command_line->GetSwitchValueASCII(switches::kOverrideSpellCheckLang);
if (!spellcheck_lang.empty()) {
......@@ -110,6 +111,11 @@ scoped_ptr<PrefService> CefBrowserPrefStore::CreateService() {
registry->RegisterBooleanPref(prefs::kEnableAutoSpellCorrect,
command_line->HasSwitch(switches::kEnableSpellingAutoCorrect));
// Pepper flash settings.
// Based on DeviceIDFetcher::RegisterProfilePrefs.
registry->RegisterBooleanPref(prefs::kEnableDRM, false);
registry->RegisterStringPref(prefs::kDRMSalt, "");
return factory.Create(registry.get());
}
......
......@@ -15,6 +15,7 @@
#include "libcef/browser/context.h"
#include "libcef/browser/devtools_delegate.h"
#include "libcef/browser/media_capture_devices_dispatcher.h"
#include "libcef/browser/pepper/browser_pepper_host_factory.h"
#include "libcef/browser/printing/printing_message_filter.h"
#include "libcef/browser/resource_dispatcher_host_delegate.h"
#include "libcef/browser/speech_recognition_manager_delegate.h"
......@@ -658,6 +659,10 @@ void CefContentBrowserClient::AppendExtraCommandLineSwitches(
switches::kDisableSpellChecking,
switches::kEnableSpeechInput,
switches::kEnableSpellingAutoCorrect,
switches::kEnableSystemFlash,
switches::kPpapiFlashArgs,
switches::kPpapiFlashPath,
switches::kPpapiFlashVersion,
switches::kUncaughtExceptionStackSize,
};
command_line->CopySwitchesFrom(*browser_cmd, kSwitchNames,
......@@ -665,13 +670,23 @@ void CefContentBrowserClient::AppendExtraCommandLineSwitches(
}
#if defined(OS_LINUX)
if (process_type == switches::kZygoteProcess &&
browser_cmd->HasSwitch(switches::kBrowserSubprocessPath)) {
// Force use of the sub-process executable path for the zygote process.
const base::FilePath& subprocess_path =
browser_cmd->GetSwitchValuePath(switches::kBrowserSubprocessPath);
if (!subprocess_path.empty())
command_line->SetProgram(subprocess_path);
if (process_type == switches::kZygoteProcess) {
// Propagate the following switches to the zygone command line (along with
// any associated values) if present in the browser command line.
static const char* const kSwitchNames[] = {
switches::kPpapiFlashPath,
switches::kPpapiFlashVersion,
};
command_line->CopySwitchesFrom(*browser_cmd, kSwitchNames,
arraysize(kSwitchNames));
if (browser_cmd->HasSwitch(switches::kBrowserSubprocessPath)) {
// Force use of the sub-process executable path for the zygote process.
const base::FilePath& subprocess_path =
browser_cmd->GetSwitchValuePath(switches::kBrowserSubprocessPath);
if (!subprocess_path.empty())
command_line->SetProgram(subprocess_path);
}
}
#endif // defined(OS_LINUX)
......@@ -965,6 +980,13 @@ std::string CefContentBrowserClient::GetDefaultDownloadName() {
return "download";
}
void CefContentBrowserClient::DidCreatePpapiPlugin(
content::BrowserPpapiHost* browser_host) {
browser_host->GetPpapiHost()->AddHostFactoryFilter(
scoped_ptr<ppapi::host::HostFactory>(
new CefBrowserPepperHostFactory(browser_host)));
}
content::DevToolsManagerDelegate*
CefContentBrowserClient::GetDevToolsManagerDelegate() {
return new CefDevToolsManagerDelegate();
......
......@@ -138,6 +138,7 @@ class CefContentBrowserClient : public content::ContentBrowserClient {
void BrowserURLHandlerCreated(
content::BrowserURLHandler* handler) override;
std::string GetDefaultDownloadName() override;
void DidCreatePpapiPlugin(content::BrowserPpapiHost* browser_host) override;
content::DevToolsManagerDelegate* GetDevToolsManagerDelegate()
override;
......
// 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 "libcef/browser/pepper/browser_pepper_host_factory.h"
#include "libcef/browser/pepper/pepper_flash_browser_host.h"
#include "build/build_config.h"
#include "chrome/browser/renderer_host/pepper/pepper_flash_clipboard_message_filter.h"
#include "chrome/browser/renderer_host/pepper/pepper_flash_drm_host.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;
CefBrowserPepperHostFactory::CefBrowserPepperHostFactory(
content::BrowserPpapiHost* host)
: host_(host) {}
CefBrowserPepperHostFactory::~CefBrowserPepperHostFactory() {}
scoped_ptr<ResourceHost> CefBrowserPepperHostFactory::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>();
// 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 chrome::PepperFlashClipboardMessageFilter);
return scoped_ptr<ResourceHost>(new MessageFilterHost(
host_->GetPpapiHost(), instance, resource, clipboard_filter));
}
case PpapiHostMsg_FlashDRM_Create::ID:
return scoped_ptr<ResourceHost>(
new chrome::PepperFlashDRMHost(host_, instance, resource));
}
}
return scoped_ptr<ResourceHost>();
}
// 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 CEF_LIBCEF_BROWSER_PEPPER_BROWSER_PEPPER_HOST_FACTORY_H_
#define CEF_LIBCEF_BROWSER_PEPPER_BROWSER_PEPPER_HOST_FACTORY_H_
#include "base/compiler_specific.h"
#include "ppapi/host/host_factory.h"
namespace content {
class BrowserPpapiHost;
} // namespace content
class CefBrowserPepperHostFactory : public ppapi::host::HostFactory {
public:
// Non-owning pointer to the filter must outlive this class.
explicit CefBrowserPepperHostFactory(content::BrowserPpapiHost* host);
~CefBrowserPepperHostFactory() 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(CefBrowserPepperHostFactory);
};
#endif // CEF_LIBCEF_BROWSER_PEPPER_BROWSER_PEPPER_HOST_FACTORY_H_
// 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/browser/renderer_host/pepper/device_id_fetcher.h"
#include "base/files/file_util.h"
#include "base/prefs/pref_service.h"
#include "base/strings/string_number_conversions.h"
#include "chrome/common/pref_names.h"
#if defined(OS_CHROMEOS)
#include "chromeos/cryptohome/system_salt_getter.h"
#endif
#include "components/pref_registry/pref_registry_syncable.h"
#include "components/user_prefs/user_prefs.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 "crypto/encryptor.h"
#include "crypto/random.h"
#include "crypto/sha2.h"
#include "ppapi/c/pp_errors.h"
#if defined(ENABLE_RLZ)
#include "rlz/lib/machine_id.h"
#endif
using content::BrowserPpapiHost;
using content::BrowserThread;
using content::RenderProcessHost;
namespace chrome {
namespace {
const char kDRMIdentifierFile[] = "Pepper DRM ID.0";
const uint32_t kSaltLength = 32;
void GetMachineIDAsync(
const base::Callback<void(const std::string&)>& callback) {
#if defined(OS_WIN) && defined(ENABLE_RLZ)
std::string result;
rlz_lib::GetMachineId(&result);
callback.Run(result);
#elif defined(OS_CHROMEOS)
chromeos::SystemSaltGetter::Get()->GetSystemSalt(callback);
#else
// Not implemented for other platforms.
NOTREACHED();
callback.Run(std::string());
#endif
}
} // namespace
DeviceIDFetcher::DeviceIDFetcher(int render_process_id)
: in_progress_(false), render_process_id_(render_process_id) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
}
DeviceIDFetcher::~DeviceIDFetcher() {}
bool DeviceIDFetcher::Start(const IDCallback& callback) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
if (in_progress_)
return false;
in_progress_ = true;
callback_ = callback;
BrowserThread::PostTask(
BrowserThread::UI,
FROM_HERE,
base::Bind(&DeviceIDFetcher::CheckPrefsOnUIThread, this));
return true;
}
// static
void DeviceIDFetcher::RegisterProfilePrefs(
user_prefs::PrefRegistrySyncable* prefs) {
prefs->RegisterBooleanPref(prefs::kEnableDRM,
true,
user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
prefs->RegisterStringPref(
prefs::kDRMSalt, "", user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
}
// static
base::FilePath DeviceIDFetcher::GetLegacyDeviceIDPath(
const base::FilePath& profile_path) {
return profile_path.AppendASCII(kDRMIdentifierFile);
}
void DeviceIDFetcher::CheckPrefsOnUIThread() {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
RenderProcessHost* render_process_host =
RenderProcessHost::FromID(render_process_id_);
content::BrowserContext* browser_context = NULL;
if (render_process_host)
browser_context = render_process_host->GetBrowserContext();
PrefService* prefs = NULL;
if (browser_context) {
prefs = user_prefs::UserPrefs::Get(browser_context);
DCHECK(prefs);
}
if (!browser_context || browser_context->IsOffTheRecord() ||
!prefs->GetBoolean(prefs::kEnableDRM)) {
RunCallbackOnIOThread(std::string(), PP_ERROR_NOACCESS);
return;
}
// Check if the salt pref is set. If it isn't, set it.
std::string salt = prefs->GetString(prefs::kDRMSalt);
if (salt.empty()) {
uint8_t salt_bytes[kSaltLength];
crypto::RandBytes(salt_bytes, arraysize(salt_bytes));
// Since it will be stored in a string pref, convert it to hex.
salt = base::HexEncode(salt_bytes, arraysize(salt_bytes));
prefs->SetString(prefs::kDRMSalt, salt);
}
#if defined(OS_CHROMEOS)
// Try the legacy path first for ChromeOS. We pass the new salt in as well
// in case the legacy id doesn't exist.
BrowserThread::PostBlockingPoolTask(
FROM_HERE,
base::Bind(&DeviceIDFetcher::LegacyComputeOnBlockingPool,
this,
profile->GetPath(),
salt));
#else
// Get the machine ID and call ComputeOnUIThread with salt + machine_id.
GetMachineIDAsync(
base::Bind(&DeviceIDFetcher::ComputeOnUIThread, this, salt));
#endif
}
void DeviceIDFetcher::ComputeOnUIThread(const std::string& salt,
const std::string& machine_id) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
if (machine_id.empty()) {
LOG(ERROR) << "Empty machine id";
RunCallbackOnIOThread(std::string(), PP_ERROR_FAILED);
return;
}
// Build the identifier as follows:
// SHA256(machine-id||service||SHA256(machine-id||service||salt))
std::vector<uint8> salt_bytes;
if (!base::HexStringToBytes(salt, &salt_bytes))
salt_bytes.clear();
if (salt_bytes.size() != kSaltLength) {
LOG(ERROR) << "Unexpected salt bytes length: " << salt_bytes.size();
RunCallbackOnIOThread(std::string(), PP_ERROR_FAILED);
return;
}
char id_buf[256 / 8]; // 256-bits for SHA256
std::string input = machine_id;
input.append(kDRMIdentifierFile);
input.append(salt_bytes.begin(), salt_bytes.end());
crypto::SHA256HashString(input, &id_buf, sizeof(id_buf));
std::string id = base::StringToLowerASCII(
base::HexEncode(reinterpret_cast<const void*>(id_buf), sizeof(id_buf)));
input = machine_id;
input.append(kDRMIdentifierFile);
input.append(id);
crypto::SHA256HashString(input, &id_buf, sizeof(id_buf));
id = base::StringToLowerASCII(
base::HexEncode(reinterpret_cast<const void*>(id_buf), sizeof(id_buf)));
RunCallbackOnIOThread(id, PP_OK);
}
// TODO(raymes): This is temporary code to migrate ChromeOS devices to the new
// scheme for generating device IDs. Delete this once we are sure most ChromeOS
// devices have been migrated.
void DeviceIDFetcher::LegacyComputeOnBlockingPool(
const base::FilePath& profile_path,
const std::string& salt) {
std::string id;
// First check if the legacy device ID file exists on ChromeOS. If it does, we
// should just return that.
base::FilePath id_path = GetLegacyDeviceIDPath(profile_path);
if (base::PathExists(id_path)) {
if (base::ReadFileToString(id_path, &id) && !id.empty()) {
RunCallbackOnIOThread(id, PP_OK);
return;
}
}
// If we didn't find an ID, get the machine ID and call the new code path to
// generate an ID.
BrowserThread::PostTask(
BrowserThread::UI,
FROM_HERE,
base::Bind(&GetMachineIDAsync,
base::Bind(&DeviceIDFetcher::ComputeOnUIThread, this, salt)));
}
void DeviceIDFetcher::RunCallbackOnIOThread(const std::string& id,
int32_t result) {
if (!BrowserThread::CurrentlyOn(BrowserThread::IO)) {
BrowserThread::PostTask(
BrowserThread::IO,
FROM_HERE,
base::Bind(&DeviceIDFetcher::RunCallbackOnIOThread, this, id, result));
return;
}
in_progress_ = false;
callback_.Run(id, result);
}
} // namespace chrome
// 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 "libcef/browser/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 {
// Returns true if the page identified by (|url|, |first_party_url|) is allowed
// to read cookies.
bool IsReadingCookieAllowed(const GURL& url,
const GURL& first_party_url) {
return true;
}
// Returns true if the cookie set by a page identified by |url| should be
// session only.
bool IsCookieSessionOnly(const GURL& url) {
return false;
}
} // namespace
PepperFlashBrowserHost::PepperFlashBrowserHost(BrowserPpapiHost* host,
PP_Instance instance,
PP_Resource resource)
: ResourceHost(host->GetPpapiHost(), instance, resource),
host_(host) {
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) {