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:
Marshall Greenblatt
2015-09-09 16:05:39 +02:00
parent 846107b291
commit dc3aae19e8
114 changed files with 4007 additions and 559 deletions

View File

@@ -15,6 +15,32 @@
namespace client {
namespace {
class ClientRequestContextHandler : public CefRequestContextHandler {
public:
ClientRequestContextHandler() {}
bool OnBeforePluginLoad(const CefString& mime_type,
const CefString& plugin_url,
const CefString& top_origin_url,
CefRefPtr<CefWebPluginInfo> plugin_info,
PluginPolicy* plugin_policy) OVERRIDE {
// Always allow the PDF plugin to load.
if (*plugin_policy != PLUGIN_POLICY_ALLOW &&
mime_type == "application/pdf") {
*plugin_policy = PLUGIN_POLICY_ALLOW;
return true;
}
return false;
}
private:
IMPLEMENT_REFCOUNTING(ClientRequestContextHandler);
};
} // namespace
RootWindowManager::RootWindowManager(bool terminate_when_all_windows_closed)
: terminate_when_all_windows_closed_(terminate_when_all_windows_closed) {
CefRefPtr<CefCommandLine> command_line =
@@ -128,11 +154,17 @@ CefRefPtr<CefRequestContext> RootWindowManager::GetRequestContext(
CefString(&settings.cache_path) = ss.str();
}
return CefRequestContext::CreateContext(settings, NULL);
return CefRequestContext::CreateContext(settings,
new ClientRequestContextHandler);
}
// All browsers will share the global request context.
return NULL;
if (!shared_request_context_.get()) {
shared_request_context_ =
CefRequestContext::CreateContext(CefRequestContext::GetGlobalContext(),
new ClientRequestContextHandler);
}
return shared_request_context_;
}
void RootWindowManager::OnTest(RootWindow* root_window, int test_id) {