Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(351)

Side by Side Diff: chrome/renderer/printing/print_web_view_helper.cc

Issue 388783003: Add support to send print preset options in one message (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix for Android trybot failure Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chrome/renderer/printing/print_web_view_helper.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/renderer/printing/print_web_view_helper.h" 5 #include "chrome/renderer/printing/print_web_view_helper.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/auto_reset.h" 9 #include "base/auto_reset.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 1007 matching lines...) Expand 10 before | Expand all | Expand 10 after
1018 Send(new PrintHostMsg_PrintPreviewInvalidPrinterSettings( 1018 Send(new PrintHostMsg_PrintPreviewInvalidPrinterSettings(
1019 routing_id(), 1019 routing_id(),
1020 print_pages_params_ ? 1020 print_pages_params_ ?
1021 print_pages_params_->params.document_cookie : 0)); 1021 print_pages_params_->params.document_cookie : 0));
1022 notify_browser_of_print_failure_ = false; // Already sent. 1022 notify_browser_of_print_failure_ = false; // Already sent.
1023 } 1023 }
1024 DidFinishPrinting(FAIL_PREVIEW); 1024 DidFinishPrinting(FAIL_PREVIEW);
1025 return; 1025 return;
1026 } 1026 }
1027 1027
1028 // If we are previewing a pdf and the print scaling is disabled, send a 1028 // Set the options from document if we are previewing a pdf and send a
1029 // message to browser. 1029 // message to browser.
1030 if (print_pages_params_->params.is_first_request && 1030 if (print_pages_params_->params.is_first_request &&
1031 !print_preview_context_.IsModifiable() && 1031 !print_preview_context_.IsModifiable()) {
1032 print_preview_context_.source_frame()->isPrintScalingDisabledForPlugin( 1032 PrintHostMsg_SetOptionsFromDocument_Params params;
1033 print_preview_context_.source_node())) { 1033 SetOptionsFromDocument(params);
1034 Send(new PrintHostMsg_PrintPreviewScalingDisabled(routing_id())); 1034 Send(new PrintHostMsg_SetOptionsFromDocument(routing_id(), params));
1035 } 1035 }
1036 1036
1037 is_print_ready_metafile_sent_ = false; 1037 is_print_ready_metafile_sent_ = false;
1038 1038
1039 // PDF printer device supports alpha blending. 1039 // PDF printer device supports alpha blending.
1040 print_pages_params_->params.supports_alpha_blend = true; 1040 print_pages_params_->params.supports_alpha_blend = true;
1041 1041
1042 bool generate_draft_pages = false; 1042 bool generate_draft_pages = false;
1043 if (!settings.GetBoolean(kSettingGenerateDraftData, 1043 if (!settings.GetBoolean(kSettingGenerateDraftData,
1044 &generate_draft_pages)) { 1044 &generate_draft_pages)) {
(...skipping 414 matching lines...) Expand 10 before | Expand all | Expand 10 after
1459 const PrintMsg_Print_Params& params = print_pages_params_->params; 1459 const PrintMsg_Print_Params& params = print_pages_params_->params;
1460 PrepareFrameAndViewForPrint prepare(params, frame, node, ignore_css_margins_); 1460 PrepareFrameAndViewForPrint prepare(params, frame, node, ignore_css_margins_);
1461 prepare.StartPrinting(); 1461 prepare.StartPrinting();
1462 1462
1463 Send(new PrintHostMsg_DidGetDocumentCookie(routing_id(), 1463 Send(new PrintHostMsg_DidGetDocumentCookie(routing_id(),
1464 params.document_cookie)); 1464 params.document_cookie));
1465 *number_of_pages = prepare.GetExpectedPageCount(); 1465 *number_of_pages = prepare.GetExpectedPageCount();
1466 return true; 1466 return true;
1467 } 1467 }
1468 1468
1469 void PrintWebViewHelper::SetOptionsFromDocument(
1470 PrintHostMsg_SetOptionsFromDocument_Params& params) {
1471 blink::WebLocalFrame* source_frame = print_preview_context_.source_frame();
1472 const blink::WebNode& source_node = print_preview_context_.source_node();
1473
1474 params.is_scaling_disabled =
1475 source_frame->isPrintScalingDisabledForPlugin(source_node);
1476 }
1477
1469 bool PrintWebViewHelper::UpdatePrintSettings( 1478 bool PrintWebViewHelper::UpdatePrintSettings(
1470 blink::WebLocalFrame* frame, 1479 blink::WebLocalFrame* frame,
1471 const blink::WebNode& node, 1480 const blink::WebNode& node,
1472 const base::DictionaryValue& passed_job_settings) { 1481 const base::DictionaryValue& passed_job_settings) {
1473 DCHECK(is_preview_enabled_); 1482 DCHECK(is_preview_enabled_);
1474 const base::DictionaryValue* job_settings = &passed_job_settings; 1483 const base::DictionaryValue* job_settings = &passed_job_settings;
1475 base::DictionaryValue modified_job_settings; 1484 base::DictionaryValue modified_job_settings;
1476 if (job_settings->empty()) { 1485 if (job_settings->empty()) {
1477 if (!print_for_preview_) 1486 if (!print_for_preview_)
1478 print_preview_context_.set_error(PREVIEW_ERROR_BAD_SETTING); 1487 print_preview_context_.set_error(PREVIEW_ERROR_BAD_SETTING);
(...skipping 543 matching lines...) Expand 10 before | Expand all | Expand 10 after
2022 } 2031 }
2023 2032
2024 void PrintWebViewHelper::PrintPreviewContext::ClearContext() { 2033 void PrintWebViewHelper::PrintPreviewContext::ClearContext() {
2025 prep_frame_view_.reset(); 2034 prep_frame_view_.reset();
2026 metafile_.reset(); 2035 metafile_.reset();
2027 pages_to_render_.clear(); 2036 pages_to_render_.clear();
2028 error_ = PREVIEW_ERROR_NONE; 2037 error_ = PREVIEW_ERROR_NONE;
2029 } 2038 }
2030 2039
2031 } // namespace printing 2040 } // namespace printing
OLDNEW
« no previous file with comments | « chrome/renderer/printing/print_web_view_helper.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698