cef/tests/cefclient/renderer/client_app_renderer.cc
Marshall Greenblatt dc3aae19e8 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.
2015-09-22 12:28:46 +03:00

120 lines
4.1 KiB
C++

// Copyright (c) 2013 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 "cefclient/renderer/client_app_renderer.h"
#include "include/base/cef_logging.h"
namespace client {
ClientAppRenderer::ClientAppRenderer() {
CreateDelegates(delegates_);
}
void ClientAppRenderer::OnRenderThreadCreated(
CefRefPtr<CefListValue> extra_info) {
DelegateSet::iterator it = delegates_.begin();
for (; it != delegates_.end(); ++it)
(*it)->OnRenderThreadCreated(this, extra_info);
}
void ClientAppRenderer::OnWebKitInitialized() {
DelegateSet::iterator it = delegates_.begin();
for (; it != delegates_.end(); ++it)
(*it)->OnWebKitInitialized(this);
}
void ClientAppRenderer::OnBrowserCreated(CefRefPtr<CefBrowser> browser) {
DelegateSet::iterator it = delegates_.begin();
for (; it != delegates_.end(); ++it)
(*it)->OnBrowserCreated(this, browser);
}
void ClientAppRenderer::OnBrowserDestroyed(CefRefPtr<CefBrowser> browser) {
DelegateSet::iterator it = delegates_.begin();
for (; it != delegates_.end(); ++it)
(*it)->OnBrowserDestroyed(this, browser);
}
CefRefPtr<CefLoadHandler> ClientAppRenderer::GetLoadHandler() {
CefRefPtr<CefLoadHandler> load_handler;
DelegateSet::iterator it = delegates_.begin();
for (; it != delegates_.end() && !load_handler.get(); ++it)
load_handler = (*it)->GetLoadHandler(this);
return load_handler;
}
bool ClientAppRenderer::OnBeforeNavigation(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame,
CefRefPtr<CefRequest> request,
NavigationType navigation_type,
bool is_redirect) {
DelegateSet::iterator it = delegates_.begin();
for (; it != delegates_.end(); ++it) {
if ((*it)->OnBeforeNavigation(this, browser, frame, request,
navigation_type, is_redirect)) {
return true;
}
}
return false;
}
void ClientAppRenderer::OnContextCreated(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame,
CefRefPtr<CefV8Context> context) {
DelegateSet::iterator it = delegates_.begin();
for (; it != delegates_.end(); ++it)
(*it)->OnContextCreated(this, browser, frame, context);
}
void ClientAppRenderer::OnContextReleased(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame,
CefRefPtr<CefV8Context> context) {
DelegateSet::iterator it = delegates_.begin();
for (; it != delegates_.end(); ++it)
(*it)->OnContextReleased(this, browser, frame, context);
}
void ClientAppRenderer::OnUncaughtException(
CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame,
CefRefPtr<CefV8Context> context,
CefRefPtr<CefV8Exception> exception,
CefRefPtr<CefV8StackTrace> stackTrace) {
DelegateSet::iterator it = delegates_.begin();
for (; it != delegates_.end(); ++it) {
(*it)->OnUncaughtException(this, browser, frame, context, exception,
stackTrace);
}
}
void ClientAppRenderer::OnFocusedNodeChanged(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame,
CefRefPtr<CefDOMNode> node) {
DelegateSet::iterator it = delegates_.begin();
for (; it != delegates_.end(); ++it)
(*it)->OnFocusedNodeChanged(this, browser, frame, node);
}
bool ClientAppRenderer::OnProcessMessageReceived(
CefRefPtr<CefBrowser> browser,
CefProcessId source_process,
CefRefPtr<CefProcessMessage> message) {
DCHECK_EQ(source_process, PID_BROWSER);
bool handled = false;
DelegateSet::iterator it = delegates_.begin();
for (; it != delegates_.end() && !handled; ++it) {
handled = (*it)->OnProcessMessageReceived(this, browser, source_process,
message);
}
return handled;
}
} // namespace client