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

Unified Diff: chrome/renderer/printing/print_web_view_helper.cc

Issue 26558003: Removed old_print_pages_params_ (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 2 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/renderer/printing/print_web_view_helper.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/renderer/printing/print_web_view_helper.cc
diff --git a/chrome/renderer/printing/print_web_view_helper.cc b/chrome/renderer/printing/print_web_view_helper.cc
index 918a317d40146e6dabc3ed0d90c55daef696d2d7..668c5b1b2d4d2b05654259219ae1031021b19673 100644
--- a/chrome/renderer/printing/print_web_view_helper.cc
+++ b/chrome/renderer/printing/print_web_view_helper.cc
@@ -55,9 +55,9 @@ namespace {
enum PrintPreviewHelperEvents {
PREVIEW_EVENT_REQUESTED,
- PREVIEW_EVENT_CACHE_HIT,
+ PREVIEW_EVENT_CACHE_HIT, // Unused
PREVIEW_EVENT_CREATE_DOCUMENT,
- PREVIEW_EVENT_NEW_SETTINGS,
+ PREVIEW_EVENT_NEW_SETTINGS, // Unused
PREVIEW_EVENT_MAX,
};
@@ -94,41 +94,6 @@ bool PrintMsg_Print_Params_IsValid(const PrintMsg_Print_Params& params) {
params.dpi && (params.margin_top >= 0) && (params.margin_left >= 0);
}
-bool PageLayoutIsEqual(const PrintMsg_PrintPages_Params& oldParams,
- const PrintMsg_PrintPages_Params& newParams) {
- return oldParams.params.content_size == newParams.params.content_size &&
- oldParams.params.printable_area == newParams.params.printable_area &&
- oldParams.params.page_size == newParams.params.page_size &&
- oldParams.params.margin_top == newParams.params.margin_top &&
- oldParams.params.margin_left == newParams.params.margin_left &&
- oldParams.params.desired_dpi == newParams.params.desired_dpi &&
- oldParams.params.dpi == newParams.params.dpi;
-}
-
-bool PrintMsg_Print_Params_IsEqual(
- const PrintMsg_PrintPages_Params& oldParams,
- const PrintMsg_PrintPages_Params& newParams) {
- return PageLayoutIsEqual(oldParams, newParams) &&
- oldParams.params.max_shrink == newParams.params.max_shrink &&
- oldParams.params.min_shrink == newParams.params.min_shrink &&
- oldParams.params.selection_only == newParams.params.selection_only &&
- oldParams.params.supports_alpha_blend ==
- newParams.params.supports_alpha_blend &&
- oldParams.pages.size() == newParams.pages.size() &&
- oldParams.params.print_to_pdf == newParams.params.print_to_pdf &&
- oldParams.params.print_scaling_option ==
- newParams.params.print_scaling_option &&
- oldParams.params.display_header_footer ==
- newParams.params.display_header_footer &&
- oldParams.params.date == newParams.params.date &&
- oldParams.params.title == newParams.params.title &&
- oldParams.params.url == newParams.params.url &&
- std::equal(oldParams.pages.begin(), oldParams.pages.end(),
- newParams.pages.begin()) &&
- oldParams.params.should_print_backgrounds ==
- newParams.params.should_print_backgrounds;
-}
-
PrintMsg_Print_Params GetCssPrintParams(
WebKit::WebFrame* frame,
int page_index,
@@ -984,28 +949,6 @@ void PrintWebViewHelper::OnPrintPreview(const base::DictionaryValue& settings) {
return;
}
- if (!print_pages_params_->params.is_first_request &&
- old_print_pages_params_.get() &&
- PrintMsg_Print_Params_IsEqual(*old_print_pages_params_,
- *print_pages_params_)) {
- UMA_HISTOGRAM_ENUMERATION("PrintPreview.PreviewEvent",
- PREVIEW_EVENT_CACHE_HIT, PREVIEW_EVENT_MAX);
- PrintHostMsg_DidPreviewDocument_Params preview_params;
- preview_params.reuse_existing_data = true;
- preview_params.data_size = 0;
- preview_params.document_cookie =
- print_pages_params_->params.document_cookie;
- preview_params.expected_pages_count =
- print_preview_context_.total_page_count();
- preview_params.modifiable = print_preview_context_.IsModifiable();
- preview_params.preview_request_id =
- print_pages_params_->params.preview_request_id;
-
- Send(new PrintHostMsg_MetafileReadyForPrinting(routing_id(),
- preview_params));
- return;
- }
-
// If we are previewing a pdf and the print scaling is disabled, send a
// message to browser.
if (print_pages_params_->params.is_first_request &&
@@ -1015,8 +958,6 @@ void PrintWebViewHelper::OnPrintPreview(const base::DictionaryValue& settings) {
Send(new PrintHostMsg_PrintPreviewScalingDisabled(routing_id()));
}
- // Always clear |old_print_pages_params_| before rendering the pages.
- old_print_pages_params_.reset();
is_print_ready_metafile_sent_ = false;
// PDF printer device supports alpha blending.
@@ -1087,27 +1028,22 @@ bool PrintWebViewHelper::CreatePreviewDocument() {
print_params, ignore_css_margins_, NULL,
&default_page_layout);
- if (!old_print_pages_params_.get() ||
- !PageLayoutIsEqual(*old_print_pages_params_, *print_pages_params_)) {
- UMA_HISTOGRAM_ENUMERATION("PrintPreview.PreviewEvent",
- PREVIEW_EVENT_NEW_SETTINGS, PREVIEW_EVENT_MAX);
- bool has_page_size_style = PrintingFrameHasPageSizeStyle(
- print_preview_context_.prepared_frame(),
- print_preview_context_.total_page_count());
- int dpi = GetDPI(&print_params);
+ bool has_page_size_style = PrintingFrameHasPageSizeStyle(
+ print_preview_context_.prepared_frame(),
+ print_preview_context_.total_page_count());
+ int dpi = GetDPI(&print_params);
- gfx::Rect printable_area_in_points(
- ConvertUnit(print_params.printable_area.x(), dpi, kPointsPerInch),
- ConvertUnit(print_params.printable_area.y(), dpi, kPointsPerInch),
- ConvertUnit(print_params.printable_area.width(), dpi, kPointsPerInch),
- ConvertUnit(print_params.printable_area.height(), dpi, kPointsPerInch));
+ gfx::Rect printable_area_in_points(
+ ConvertUnit(print_params.printable_area.x(), dpi, kPointsPerInch),
+ ConvertUnit(print_params.printable_area.y(), dpi, kPointsPerInch),
+ ConvertUnit(print_params.printable_area.width(), dpi, kPointsPerInch),
+ ConvertUnit(print_params.printable_area.height(), dpi, kPointsPerInch));
- // Margins: Send default page layout to browser process.
- Send(new PrintHostMsg_DidGetDefaultPageLayout(routing_id(),
- default_page_layout,
- printable_area_in_points,
- has_page_size_style));
- }
+ // Margins: Send default page layout to browser process.
+ Send(new PrintHostMsg_DidGetDefaultPageLayout(routing_id(),
+ default_page_layout,
+ printable_area_in_points,
+ has_page_size_style));
PrintHostMsg_DidGetPreviewPageCount_Params params;
params.page_count = print_preview_context_.total_page_count();
@@ -1278,7 +1214,6 @@ void PrintWebViewHelper::Print(WebKit::WebFrame* frame,
}
void PrintWebViewHelper::DidFinishPrinting(PrintingResult result) {
- bool store_print_pages_params = true;
switch (result) {
case OK:
break;
@@ -1296,7 +1231,6 @@ void PrintWebViewHelper::DidFinishPrinting(PrintingResult result) {
case FAIL_PREVIEW:
DCHECK(is_preview_enabled_);
- store_print_pages_params = false;
int cookie = print_pages_params_.get() ?
print_pages_params_->params.document_cookie : 0;
if (notify_browser_of_print_failure_) {
@@ -1308,16 +1242,8 @@ void PrintWebViewHelper::DidFinishPrinting(PrintingResult result) {
print_preview_context_.Failed(notify_browser_of_print_failure_);
break;
}
-
prep_frame_view_.reset();
-
- if (store_print_pages_params) {
- old_print_pages_params_.reset(print_pages_params_.release());
- } else {
- print_pages_params_.reset();
- old_print_pages_params_.reset();
- }
-
+ print_pages_params_.reset();
notify_browser_of_print_failure_ = true;
}
@@ -1704,7 +1630,6 @@ void PrintWebViewHelper::ShowScriptedPrintPreview() {
void PrintWebViewHelper::RequestPrintPreview(PrintPreviewRequestType type) {
const bool is_modifiable = print_preview_context_.IsModifiable();
const bool has_selection = print_preview_context_.HasSelection();
- old_print_pages_params_.reset();
PrintHostMsg_RequestPrintPreview_Params params;
params.is_modifiable = is_modifiable;
params.has_selection = has_selection;
« 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