mirror of
https://bitbucket.org/chromiumembedded/cef
synced 2025-06-05 21:39:12 +02:00
Add plugin placeholder and policy support (issue #1708)
- Default plugin loading policy can be specified using the new `--plugin-policy=[allow|block|detect]` command-line flag. - Move CefRequestHandler::OnBeforePluginLoad to CefRequestContextHandler and add a new policy argument that supports different actions (allow, block, detect, disable) on a per-plugin-instance basis. - Add CefContextMenuHandler::RunContextMenu for providing a custom context menu implementation. - Add CefResourceBundleHandler::GetDataResourceForScale for returning scaled resources (issue #1272). - Add CefResourceBundle for retrieving resources from the resource bundle (*.pak) files loaded by CEF during startup or via the CefResourceBundleHandler. - Linux: Fix Debug build IO access warning with CefGetMimeType. - cef_unittests: Move the refcounting implementation from TestHandler to subclasses in order to support interface inheritance from subclasses.
This commit is contained in:
@@ -163,6 +163,11 @@ IPC_MESSAGE_ROUTED1(CefMsg_Response,
|
||||
IPC_MESSAGE_ROUTED1(CefMsg_ResponseAck,
|
||||
int /* request_id */)
|
||||
|
||||
// Tells the render frame to load all blocked plugins with the given identifier.
|
||||
// Based on ChromeViewMsg_LoadBlockedPlugins.
|
||||
IPC_MESSAGE_ROUTED1(CefViewMsg_LoadBlockedPlugins,
|
||||
std::string /* identifier */)
|
||||
|
||||
// Sent on process startup to indicate whether this process is running in
|
||||
// incognito mode. Based on ChromeViewMsg_SetIsIncognitoProcess.
|
||||
IPC_MESSAGE_CONTROL1(CefProcessMsg_SetIsIncognitoProcess,
|
||||
|
@@ -116,4 +116,14 @@ const char kWidevineCdmPath[] = "widevine-cdm-path";
|
||||
// Widevine CDM version.
|
||||
const char kWidevineCdmVersion[] = "widevine-cdm-version";
|
||||
|
||||
// Default plugin policy action.
|
||||
const char kPluginPolicy[] = "plugin-policy";
|
||||
// Allow the content. This is the default value.
|
||||
const char kPluginPolicy_Allow[] = "allow";
|
||||
// Allow important content and block unimportant content based on heuristics.
|
||||
// The user can manually load blocked content.
|
||||
const char kPluginPolicy_Detect[] = "detect";
|
||||
// Block the content. The user can manually load blocked content.
|
||||
const char kPluginPolicy_Block[] = "block";
|
||||
|
||||
} // namespace switches
|
||||
|
@@ -48,6 +48,10 @@ extern const char kEnableNPAPI[];
|
||||
extern const char kEnableWidevineCdm[];
|
||||
extern const char kWidevineCdmPath[];
|
||||
extern const char kWidevineCdmVersion[];
|
||||
extern const char kPluginPolicy[];
|
||||
extern const char kPluginPolicy_Allow[];
|
||||
extern const char kPluginPolicy_Detect[];
|
||||
extern const char kPluginPolicy_Block[];
|
||||
|
||||
} // namespace switches
|
||||
|
||||
|
@@ -433,8 +433,15 @@ bool CefContentClient::GetRawDataResource(int resource_id,
|
||||
if (handler.get()) {
|
||||
void* data = NULL;
|
||||
size_t data_size = 0;
|
||||
if (handler->GetDataResource(resource_id, data, data_size))
|
||||
if (scale_factor != ui::SCALE_FACTOR_NONE) {
|
||||
if (handler->GetDataResourceForScale(
|
||||
resource_id, static_cast<cef_scale_factor_t>(scale_factor), data,
|
||||
data_size)) {
|
||||
*value = base::StringPiece(static_cast<char*>(data), data_size);
|
||||
}
|
||||
} else if (handler->GetDataResource(resource_id, data, data_size)) {
|
||||
*value = base::StringPiece(static_cast<char*>(data), data_size);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -27,10 +27,12 @@
|
||||
#include "chrome/common/chrome_paths.h"
|
||||
#include "chrome/common/chrome_switches.h"
|
||||
#include "chrome/common/widevine_cdm_constants.h"
|
||||
#include "components/content_settings/core/common/content_settings_pattern.h"
|
||||
#include "content/public/browser/browser_main_runner.h"
|
||||
#include "content/public/browser/render_process_host.h"
|
||||
#include "content/public/common/content_switches.h"
|
||||
#include "content/public/common/main_function_params.h"
|
||||
#include "extensions/common/constants.h"
|
||||
#include "pdf/pdf.h"
|
||||
#include "ui/base/layout.h"
|
||||
#include "ui/base/resource/resource_bundle.h"
|
||||
@@ -483,6 +485,9 @@ bool CefMainDelegate::BasicStartupComplete(int* exit_code) {
|
||||
|
||||
logging::InitLogging(log_settings);
|
||||
|
||||
ContentSettingsPattern::SetNonWildcardDomainNonPortScheme(
|
||||
extensions::kExtensionScheme);
|
||||
|
||||
content::SetContentClient(&content_client_);
|
||||
|
||||
return false;
|
||||
|
@@ -8,6 +8,7 @@
|
||||
#include "libcef/renderer/webkit_glue.h"
|
||||
|
||||
#include "base/base64.h"
|
||||
#include "base/threading/thread_restrictions.h"
|
||||
#include "net/base/escape.h"
|
||||
#include "net/base/mime_util.h"
|
||||
#include "third_party/WebKit/public/platform/WebString.h"
|
||||
@@ -76,6 +77,10 @@ bool CefCreateURL(const CefURLParts& parts,
|
||||
}
|
||||
|
||||
CefString CefGetMimeType(const CefString& extension) {
|
||||
// Requests should not block on the disk! On POSIX this goes to disk.
|
||||
// http://code.google.com/p/chromium/issues/detail?id=59849
|
||||
base::ThreadRestrictions::ScopedAllowIO allow_io;
|
||||
|
||||
std::string mime_type;
|
||||
net::GetMimeTypeFromExtension(extension, &mime_type);
|
||||
return mime_type;
|
||||
|
47
libcef/common/resource_bundle_impl.cc
Normal file
47
libcef/common/resource_bundle_impl.cc
Normal file
@@ -0,0 +1,47 @@
|
||||
// Copyright (c) 2015 The Chromium Embedded Framework 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/common/resource_bundle_impl.h"
|
||||
|
||||
#include "ui/base/resource/resource_bundle.h"
|
||||
|
||||
CefResourceBundleImpl::CefResourceBundleImpl() {
|
||||
}
|
||||
|
||||
CefString CefResourceBundleImpl::GetLocalizedString(int string_id) {
|
||||
if (!ui::ResourceBundle::HasSharedInstance())
|
||||
return CefString();
|
||||
|
||||
return ui::ResourceBundle::GetSharedInstance().GetLocalizedString(string_id);
|
||||
}
|
||||
|
||||
bool CefResourceBundleImpl::GetDataResource(int resource_id,
|
||||
void*& data,
|
||||
size_t& data_size) {
|
||||
return GetDataResourceForScale(resource_id, SCALE_FACTOR_NONE, data,
|
||||
data_size);
|
||||
}
|
||||
|
||||
bool CefResourceBundleImpl::GetDataResourceForScale(int resource_id,
|
||||
ScaleFactor scale_factor,
|
||||
void*& data,
|
||||
size_t& data_size) {
|
||||
if (!ui::ResourceBundle::HasSharedInstance())
|
||||
return false;
|
||||
|
||||
const base::StringPiece& result =
|
||||
ui::ResourceBundle::GetSharedInstance().GetRawDataResourceForScale(
|
||||
resource_id, static_cast<ui::ScaleFactor>(scale_factor));
|
||||
if (result.empty())
|
||||
return false;
|
||||
|
||||
data = const_cast<char*>(result.data());
|
||||
data_size = result.size();
|
||||
return true;
|
||||
}
|
||||
|
||||
// static
|
||||
CefRefPtr<CefResourceBundle> CefResourceBundle::GetGlobal() {
|
||||
return new CefResourceBundleImpl();
|
||||
}
|
31
libcef/common/resource_bundle_impl.h
Normal file
31
libcef/common/resource_bundle_impl.h
Normal file
@@ -0,0 +1,31 @@
|
||||
// Copyright (c) 2015 The Chromium Embedded Framework 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_COMMON_RESOURCE_BUNDLE_IMPL_H_
|
||||
#define CEF_LIBCEF_COMMON_RESOURCE_BUNDLE_IMPL_H_
|
||||
#pragma once
|
||||
|
||||
|
||||
#include "include/cef_resource_bundle.h"
|
||||
|
||||
class CefResourceBundleImpl : public CefResourceBundle {
|
||||
public:
|
||||
CefResourceBundleImpl();
|
||||
|
||||
// CefResourceBundle methods.
|
||||
CefString GetLocalizedString(int string_id) override;
|
||||
bool GetDataResource(int resource_id,
|
||||
void*& data,
|
||||
size_t& data_size) override;
|
||||
bool GetDataResourceForScale(int resource_id,
|
||||
ScaleFactor scale_factor,
|
||||
void*& data,
|
||||
size_t& data_size) override;
|
||||
|
||||
private:
|
||||
IMPLEMENT_REFCOUNTING(CefResourceBundleImpl);
|
||||
DISALLOW_COPY_AND_ASSIGN(CefResourceBundleImpl);
|
||||
};
|
||||
|
||||
#endif // CEF_LIBCEF_COMMON_RESOURCE_BUNDLE_IMPL_H_
|
Reference in New Issue
Block a user