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:
Marshall Greenblatt
2013-10-23 19:30:47 +00:00
parent f248b937f9
commit bc1ea4974a
35 changed files with 1960 additions and 20 deletions

View File

@ -17,6 +17,7 @@
#include "libcef/browser/devtools_delegate.h"
#include "libcef/browser/media_capture_devices_dispatcher.h"
#include "libcef/browser/navigate_params.h"
#include "libcef/browser/printing/print_view_manager.h"
#include "libcef/browser/render_widget_host_view_osr.h"
#include "libcef/browser/request_context_impl.h"
#include "libcef/browser/scheme_handler.h"
@ -603,6 +604,18 @@ void CefBrowserHostImpl::StartDownload(const CefString& url) {
manager->DownloadUrl(params.Pass());
}
void CefBrowserHostImpl::Print() {
if (CEF_CURRENTLY_ON_UIT()) {
if (!web_contents_)
return;
printing::PrintViewManager::FromWebContents(
web_contents_.get())->PrintNow();
} else {
CEF_POST_TASK(CEF_UIT,
base::Bind(&CefBrowserHostImpl::Print, this));
}
}
void CefBrowserHostImpl::SetMouseCursorChangeDisabled(bool disabled) {
base::AutoLock lock_scope(state_lock_);
mouse_cursor_change_disabled_ = disabled;
@ -2114,6 +2127,8 @@ CefBrowserHostImpl::CefBrowserHostImpl(
CefString(), CefString(),
CefFrameHostImpl::kInvalidFrameId);
printing::PrintViewManager::CreateForWebContents(web_contents_.get());
// Make sure RenderViewCreated is called at least one time.
RenderViewCreated(web_contents->GetRenderViewHost());