mirror of
https://bitbucket.org/chromiumembedded/cef
synced 2025-06-05 21:39:12 +02:00
Add support for printing via CefBrowserHost::Print() and JavaScript window.print() (issue #505).
git-svn-id: https://chromiumembedded.googlecode.com/svn/trunk@1479 5089003a-bbd8-11dd-ad1f-f1f9622dbc98
This commit is contained in:
@@ -8,6 +8,7 @@
|
||||
#include "libcef/browser/browser_info.h"
|
||||
#include "libcef/browser/browser_main.h"
|
||||
#include "libcef/browser/browser_message_loop.h"
|
||||
#include "libcef/browser/chrome_browser_process_stub.h"
|
||||
#include "libcef/browser/content_browser_client.h"
|
||||
#include "libcef/browser/scheme_handler.h"
|
||||
#include "libcef/browser/thread_util.h"
|
||||
@@ -19,6 +20,7 @@
|
||||
#include "base/command_line.h"
|
||||
#include "base/file_util.h"
|
||||
#include "base/synchronization/waitable_event.h"
|
||||
#include "chrome/browser/printing/print_job_manager.h"
|
||||
#include "content/public/app/content_main.h"
|
||||
#include "content/public/app/content_main_runner.h"
|
||||
#include "content/public/browser/notification_service.h"
|
||||
@@ -44,13 +46,13 @@ CefContext* g_context = NULL;
|
||||
// CefShutdown() has not been explicitly called.
|
||||
class CefForceShutdown {
|
||||
public:
|
||||
~CefForceShutdown() {
|
||||
if (g_context) {
|
||||
g_context->Shutdown();
|
||||
delete g_context;
|
||||
g_context = NULL;
|
||||
}
|
||||
}
|
||||
~CefForceShutdown() {
|
||||
if (g_context) {
|
||||
g_context->Shutdown();
|
||||
delete g_context;
|
||||
g_context = NULL;
|
||||
}
|
||||
}
|
||||
} g_force_shutdown;
|
||||
|
||||
} // namespace
|
||||
@@ -102,6 +104,8 @@ bool CefInitialize(const CefMainArgs& args,
|
||||
return false;
|
||||
}
|
||||
|
||||
g_browser_process = new ChromeBrowserProcessStub();
|
||||
|
||||
// Create the new global context object.
|
||||
g_context = new CefContext();
|
||||
|
||||
@@ -267,9 +271,13 @@ bool CefContext::Initialize(const CefMainArgs& args,
|
||||
|
||||
initialized_ = true;
|
||||
|
||||
// Continue initialization on the UI thread.
|
||||
CEF_POST_TASK(CEF_UIT,
|
||||
base::Bind(&CefContext::OnContextInitialized, base::Unretained(this)));
|
||||
if (CEF_CURRENTLY_ON_UIT()) {
|
||||
OnContextInitialized();
|
||||
} else {
|
||||
// Continue initialization on the UI thread.
|
||||
CEF_POST_TASK(CEF_UIT,
|
||||
base::Bind(&CefContext::OnContextInitialized, base::Unretained(this)));
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -329,6 +337,9 @@ void CefContext::OnContextInitialized() {
|
||||
registrar_->Add(this, content::NOTIFICATION_RENDERER_PROCESS_CLOSED,
|
||||
content::NotificationService::AllBrowserContextsAndSources());
|
||||
|
||||
// Must be created after the NotificationService.
|
||||
print_job_manager_.reset(new printing::PrintJobManager());
|
||||
|
||||
// Notify the handler.
|
||||
CefRefPtr<CefApp> app = CefContentClient::Get()->application();
|
||||
if (app.get()) {
|
||||
@@ -343,6 +354,12 @@ void CefContext::FinishShutdownOnUIThread(
|
||||
base::WaitableEvent* uithread_shutdown_event) {
|
||||
CEF_REQUIRE_UIT();
|
||||
|
||||
// Wait for the pending print jobs to finish. Don't do this later, since
|
||||
// this might cause a nested message loop to run, and we don't want pending
|
||||
// tasks to run once teardown has started.
|
||||
print_job_manager_->Shutdown();
|
||||
print_job_manager_.reset(NULL);
|
||||
|
||||
CefContentBrowserClient::Get()->DestroyAllBrowsers();
|
||||
|
||||
registrar_.reset();
|
||||
|
Reference in New Issue
Block a user