Having problems with building or using CEF's C/C++ APIs? This forum is here to help. Please do not post bug reports or feature requests here.
by softarts » Fri Aug 26, 2016 5:35 am
the code are messy
- Code: Select all
// 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 "client_app.h"
#include "include/wrapper/cef_helpers.h"
#include <QDebug>
// Must match the value in client_handler.cc.
const char kFocusedNodeChangedMessage[] = "ClientRenderer.FocusedNodeChanged";
ClientApp::ClientApp()
{
last_node_is_editable_ = false;
}
void ClientApp::OnContextInitialized() {
CEF_REQUIRE_UI_THREAD();
}
// called in renderer process
void ClientApp::OnWebKitInitialized()
{
CefMessageRouterConfig config;
config.js_query_function = "ClientQuery";
config.js_cancel_function = "ClientQueryCancel";
render_message_router_ = CefMessageRouterRendererSide::Create(config);
}
// renderer process
void ClientApp::OnContextCreated(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame,
CefRefPtr<CefV8Context> context)
{
render_message_router_->OnContextCreated(browser, frame, context);
}
void ClientApp::OnContextReleased(CefRefPtr<CefBrowser> app,
CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame,
CefRefPtr<CefV8Context> context)
{
render_message_router_->OnContextReleased(browser, frame, context);
}
// renderer process
bool ClientApp::OnProcessMessageReceived(CefRefPtr<CefBrowser> browser,
CefProcessId source_process,
CefRefPtr<CefProcessMessage> message)
{
return render_message_router_->OnProcessMessageReceived(browser, source_process, message);
}
void ClientApp::OnBeforeCommandLineProcessing(
const CefString& process_type,
CefRefPtr<CefCommandLine> command_line)
{
command_line->AppendSwitch("disable-spell-checking");
command_line->AppendSwitch("disable-extensions");
command_line->AppendSwitch("disable-pdf-extension");
command_line->AppendSwitch("enable-direct-write");
command_line->AppendSwitch("allow-file-access-from-files");
// https://bitbucket.org/chromiumembedded/cef/issues/1680/windows-2454-crash-on-shutdown-with-multi
}
void ClientApp::OnFocusedNodeChanged(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame,
CefRefPtr<CefDOMNode> node) {
bool is_editable = (node.get() && node->IsEditable());
if (is_editable != last_node_is_editable_) {
// Notify the browser of the change in focused element type.
last_node_is_editable_ = is_editable;
CefRefPtr<CefProcessMessage> message =
CefProcessMessage::Create(kFocusedNodeChangedMessage);
message->GetArgumentList()->SetBool(0, is_editable);
browser->SendProcessMessage(PID_BROWSER, message);
}
}
-
softarts
- Techie
-
- Posts: 13
- Joined: Tue Aug 02, 2016 3:47 am
Return to Support Forum
Who is online
Users browsing this forum: No registered users and 70 guests