|
| 1 | +// Copyright (c) 2012-2013 The CEF Python authors. All rights reserved. |
| 2 | +// License: New BSD License. |
| 3 | +// Website: http://code.google.com/p/cefpython/ |
| 4 | + |
| 5 | +#include "cefpython_app.h" |
| 6 | +#include "util.h" |
| 7 | +#include <stdio.h> |
| 8 | + |
| 9 | +void DebugLog(const char* szString) |
| 10 | +{ |
| 11 | + FILE* pFile = fopen("debug.log", "a"); |
| 12 | + fprintf(pFile, "cefpython_app: %s\n", szString); |
| 13 | + fclose(pFile); |
| 14 | +} |
| 15 | + |
| 16 | +// ----------------------------------------------------------------------------- |
| 17 | +// CefApp |
| 18 | +// ----------------------------------------------------------------------------- |
| 19 | + |
| 20 | +void CefPythonApp::OnBeforeCommandLineProcessing( |
| 21 | + const CefString& process_type, |
| 22 | + CefRefPtr<CefCommandLine> command_line) { |
| 23 | +} |
| 24 | + |
| 25 | +void CefPythonApp::OnRegisterCustomSchemes( |
| 26 | + CefRefPtr<CefSchemeRegistrar> registrar) { |
| 27 | +} |
| 28 | + |
| 29 | +CefRefPtr<CefResourceBundleHandler> CefPythonApp::GetResourceBundleHandler() { |
| 30 | + return NULL; |
| 31 | +} |
| 32 | + |
| 33 | +CefRefPtr<CefBrowserProcessHandler> CefPythonApp::GetBrowserProcessHandler() { |
| 34 | + return this; |
| 35 | +} |
| 36 | + |
| 37 | +CefRefPtr<CefRenderProcessHandler> CefPythonApp::GetRenderProcessHandler() { |
| 38 | + DebugLog("GetRenderProcessHandler() called"); |
| 39 | + return this; |
| 40 | +} |
| 41 | + |
| 42 | +// ----------------------------------------------------------------------------- |
| 43 | +// CefBrowserProcessHandler |
| 44 | +// ----------------------------------------------------------------------------- |
| 45 | + |
| 46 | +void CefPythonApp::OnContextInitialized() { |
| 47 | + REQUIRE_UI_THREAD(); |
| 48 | +} |
| 49 | + |
| 50 | +void CefPythonApp::OnBeforeChildProcessLaunch( |
| 51 | + CefRefPtr<CefCommandLine> command_line) {} |
| 52 | + |
| 53 | +void CefPythonApp::OnRenderProcessThreadCreated( |
| 54 | + CefRefPtr<CefListValue> extra_info) { |
| 55 | + REQUIRE_IO_THREAD(); |
| 56 | +} |
| 57 | + |
| 58 | +// ----------------------------------------------------------------------------- |
| 59 | +// CefRenderProcessHandler |
| 60 | +// ----------------------------------------------------------------------------- |
| 61 | + |
| 62 | +void CefPythonApp::OnRenderThreadCreated(CefRefPtr<CefListValue> extra_info) { |
| 63 | +} |
| 64 | + |
| 65 | +void CefPythonApp::OnWebKitInitialized() { |
| 66 | +} |
| 67 | + |
| 68 | +void CefPythonApp::OnBrowserCreated(CefRefPtr<CefBrowser> browser) { |
| 69 | +} |
| 70 | + |
| 71 | +void CefPythonApp::OnBrowserDestroyed(CefRefPtr<CefBrowser> browser) { |
| 72 | +} |
| 73 | + |
| 74 | +bool CefPythonApp::OnBeforeNavigation(CefRefPtr<CefBrowser> browser, |
| 75 | + CefRefPtr<CefFrame> frame, |
| 76 | + CefRefPtr<CefRequest> request, |
| 77 | + cef_navigation_type_t navigation_type, |
| 78 | + bool is_redirect) { |
| 79 | + return false; |
| 80 | +} |
| 81 | + |
| 82 | +void CefPythonApp::OnContextCreated(CefRefPtr<CefBrowser> browser, |
| 83 | + CefRefPtr<CefFrame> frame, |
| 84 | + CefRefPtr<CefV8Context> context) { |
| 85 | + DebugLog("OnContextCreated() called"); |
| 86 | + CefRefPtr<CefProcessMessage> msg = CefProcessMessage::Create( |
| 87 | + "OnContextCreated"); |
| 88 | + browser.get()->SendProcessMessage(PID_BROWSER, msg); |
| 89 | +} |
| 90 | + |
| 91 | +void CefPythonApp::OnContextReleased(CefRefPtr<CefBrowser> browser, |
| 92 | + CefRefPtr<CefFrame> frame, |
| 93 | + CefRefPtr<CefV8Context> context) { |
| 94 | +} |
| 95 | + |
| 96 | +void CefPythonApp::OnUncaughtException(CefRefPtr<CefBrowser> browser, |
| 97 | + CefRefPtr<CefFrame> frame, |
| 98 | + CefRefPtr<CefV8Context> context, |
| 99 | + CefRefPtr<CefV8Exception> exception, |
| 100 | + CefRefPtr<CefV8StackTrace> stackTrace) { |
| 101 | +} |
| 102 | + |
| 103 | +void CefPythonApp::OnFocusedNodeChanged(CefRefPtr<CefBrowser> browser, |
| 104 | + CefRefPtr<CefFrame> frame, |
| 105 | + CefRefPtr<CefDOMNode> node) { |
| 106 | +} |
| 107 | + |
| 108 | +bool CefPythonApp::OnProcessMessageReceived(CefRefPtr<CefBrowser> browser, |
| 109 | + CefProcessId source_process, |
| 110 | + CefRefPtr<CefProcessMessage> message) { |
| 111 | + return false; |
| 112 | +} |
0 commit comments