// 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. // This file is shared by cefclient and cef_unittests so don't include using // a qualified path. #include "client_app.h" // NOLINT(build/include) #include #include "include/cef_cookie.h" #include "include/cef_process_message.h" #include "include/cef_task.h" #include "include/cef_v8.h" #include "util.h" // NOLINT(build/include) ClientApp::ClientApp() { } void ClientApp::OnRegisterCustomSchemes( CefRefPtr registrar) { // Default schemes that support cookies. cookieable_schemes_.push_back("http"); cookieable_schemes_.push_back("https"); RegisterCustomSchemes(registrar, cookieable_schemes_); } void ClientApp::OnContextInitialized() { CreateBrowserDelegates(browser_delegates_); // Register cookieable schemes with the global cookie manager. CefRefPtr manager = CefCookieManager::GetGlobalManager(); ASSERT(manager.get()); manager->SetSupportedSchemes(cookieable_schemes_); BrowserDelegateSet::iterator it = browser_delegates_.begin(); for (; it != browser_delegates_.end(); ++it) (*it)->OnContextInitialized(this); } void ClientApp::OnBeforeChildProcessLaunch( CefRefPtr command_line) { BrowserDelegateSet::iterator it = browser_delegates_.begin(); for (; it != browser_delegates_.end(); ++it) (*it)->OnBeforeChildProcessLaunch(this, command_line); } void ClientApp::OnRenderProcessThreadCreated( CefRefPtr extra_info) { BrowserDelegateSet::iterator it = browser_delegates_.begin(); for (; it != browser_delegates_.end(); ++it) (*it)->OnRenderProcessThreadCreated(this, extra_info); } void ClientApp::OnRenderThreadCreated(CefRefPtr extra_info) { CreateRenderDelegates(render_delegates_); RenderDelegateSet::iterator it = render_delegates_.begin(); for (; it != render_delegates_.end(); ++it) (*it)->OnRenderThreadCreated(this, extra_info); } void ClientApp::OnWebKitInitialized() { RenderDelegateSet::iterator it = render_delegates_.begin(); for (; it != render_delegates_.end(); ++it) (*it)->OnWebKitInitialized(this); } void ClientApp::OnBrowserCreated(CefRefPtr browser) { RenderDelegateSet::iterator it = render_delegates_.begin(); for (; it != render_delegates_.end(); ++it) (*it)->OnBrowserCreated(this, browser); } void ClientApp::OnBrowserDestroyed(CefRefPtr browser) { RenderDelegateSet::iterator it = render_delegates_.begin(); for (; it != render_delegates_.end(); ++it) (*it)->OnBrowserDestroyed(this, browser); } CefRefPtr ClientApp::GetLoadHandler() { CefRefPtr load_handler; RenderDelegateSet::iterator it = render_delegates_.begin(); for (; it != render_delegates_.end() && !load_handler.get(); ++it) load_handler = (*it)->GetLoadHandler(this); return load_handler; } bool ClientApp::OnBeforeNavigation(CefRefPtr browser, CefRefPtr frame, CefRefPtr request, NavigationType navigation_type, bool is_redirect) { RenderDelegateSet::iterator it = render_delegates_.begin(); for (; it != render_delegates_.end(); ++it) { if ((*it)->OnBeforeNavigation(this, browser, frame, request, navigation_type, is_redirect)) { return true; } } return false; } void ClientApp::OnContextCreated(CefRefPtr browser, CefRefPtr frame, CefRefPtr context) { RenderDelegateSet::iterator it = render_delegates_.begin(); for (; it != render_delegates_.end(); ++it) (*it)->OnContextCreated(this, browser, frame, context); } void ClientApp::OnContextReleased(CefRefPtr browser, CefRefPtr frame, CefRefPtr context) { RenderDelegateSet::iterator it = render_delegates_.begin(); for (; it != render_delegates_.end(); ++it) (*it)->OnContextReleased(this, browser, frame, context); } void ClientApp::OnUncaughtException(CefRefPtr browser, CefRefPtr frame, CefRefPtr context, CefRefPtr exception, CefRefPtr stackTrace) { RenderDelegateSet::iterator it = render_delegates_.begin(); for (; it != render_delegates_.end(); ++it) { (*it)->OnUncaughtException(this, browser, frame, context, exception, stackTrace); } } void ClientApp::OnFocusedNodeChanged(CefRefPtr browser, CefRefPtr frame, CefRefPtr node) { RenderDelegateSet::iterator it = render_delegates_.begin(); for (; it != render_delegates_.end(); ++it) (*it)->OnFocusedNodeChanged(this, browser, frame, node); } bool ClientApp::OnProcessMessageReceived( CefRefPtr browser, CefProcessId source_process, CefRefPtr message) { ASSERT(source_process == PID_BROWSER); bool handled = false; RenderDelegateSet::iterator it = render_delegates_.begin(); for (; it != render_delegates_.end() && !handled; ++it) { handled = (*it)->OnProcessMessageReceived(this, browser, source_process, message); } return handled; }