Add "silent" and "print_background" option for printing.
This commit is contained in:
parent
d0c1b63064
commit
e43b3309af
10 changed files with 56 additions and 34 deletions
|
@ -672,10 +672,10 @@ bool PrintWebViewHelper::GetPrintFrame(blink::WebLocalFrame** frame) {
|
|||
return true;
|
||||
}
|
||||
|
||||
void PrintWebViewHelper::OnPrintPages() {
|
||||
void PrintWebViewHelper::OnPrintPages(bool silent, bool print_background) {
|
||||
blink::WebLocalFrame* frame;
|
||||
if (GetPrintFrame(&frame))
|
||||
Print(frame, blink::WebNode());
|
||||
Print(frame, blink::WebNode(), silent, print_background);
|
||||
}
|
||||
|
||||
void PrintWebViewHelper::GetPageSizeAndContentAreaFromPageLayout(
|
||||
|
@ -703,14 +703,6 @@ void PrintWebViewHelper::UpdateFrameMarginsCssInfo(
|
|||
ignore_css_margins_ = (margins_type != DEFAULT_MARGINS);
|
||||
}
|
||||
|
||||
bool PrintWebViewHelper::IsPrintToPdfRequested(
|
||||
const base::DictionaryValue& job_settings) {
|
||||
bool print_to_pdf = false;
|
||||
if (!job_settings.GetBoolean(kSettingPrintToPDF, &print_to_pdf))
|
||||
NOTREACHED();
|
||||
return print_to_pdf;
|
||||
}
|
||||
|
||||
void PrintWebViewHelper::OnPrintingDone(bool success) {
|
||||
notify_browser_of_print_failure_ = false;
|
||||
if (!success)
|
||||
|
@ -743,7 +735,9 @@ void PrintWebViewHelper::PrintNode(const blink::WebNode& node) {
|
|||
}
|
||||
|
||||
void PrintWebViewHelper::Print(blink::WebLocalFrame* frame,
|
||||
const blink::WebNode& node) {
|
||||
const blink::WebNode& node,
|
||||
bool silent,
|
||||
bool print_background) {
|
||||
// If still not finished with earlier print request simply ignore.
|
||||
if (prep_frame_view_)
|
||||
return;
|
||||
|
@ -763,12 +757,14 @@ void PrintWebViewHelper::Print(blink::WebLocalFrame* frame,
|
|||
}
|
||||
|
||||
// Ask the browser to show UI to retrieve the final print settings.
|
||||
if (!GetPrintSettingsFromUser(frame_ref.GetFrame(), node,
|
||||
expected_page_count)) {
|
||||
if (!silent && !GetPrintSettingsFromUser(frame_ref.GetFrame(), node,
|
||||
expected_page_count)) {
|
||||
DidFinishPrinting(OK); // Release resources and fail silently.
|
||||
return;
|
||||
}
|
||||
|
||||
print_pages_params_->params.should_print_backgrounds = print_background;
|
||||
|
||||
// Render Pages for printing.
|
||||
if (!RenderPagesForPrint(frame_ref.GetFrame(), node)) {
|
||||
LOG(ERROR) << "RenderPagesForPrint failed";
|
||||
|
|
|
@ -81,7 +81,7 @@ class PrintWebViewHelper
|
|||
bool user_initiated) OVERRIDE;
|
||||
|
||||
// Message handlers ---------------------------------------------------------
|
||||
void OnPrintPages();
|
||||
void OnPrintPages(bool silent, bool print_background);
|
||||
void OnPrintingDone(bool success);
|
||||
|
||||
// Get |page_size| and |content_area| information from
|
||||
|
@ -94,12 +94,12 @@ class PrintWebViewHelper
|
|||
// Update |ignore_css_margins_| based on settings.
|
||||
void UpdateFrameMarginsCssInfo(const base::DictionaryValue& settings);
|
||||
|
||||
// Returns true if the current destination printer is PRINT_TO_PDF.
|
||||
bool IsPrintToPdfRequested(const base::DictionaryValue& settings);
|
||||
|
||||
// Main printing code -------------------------------------------------------
|
||||
|
||||
void Print(blink::WebLocalFrame* frame, const blink::WebNode& node);
|
||||
void Print(blink::WebLocalFrame* frame,
|
||||
const blink::WebNode& node,
|
||||
bool silent = false,
|
||||
bool print_background = false);
|
||||
|
||||
// Notification when printing is done - signal tear-down/free resources.
|
||||
void DidFinishPrinting(PrintingResult result);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue