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

Unified Diff: chrome/renderer/print_web_view_helper.cc

Issue 8201027: Move margin processing code to the browser process. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 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
Index: chrome/renderer/print_web_view_helper.cc
diff --git a/chrome/renderer/print_web_view_helper.cc b/chrome/renderer/print_web_view_helper.cc
index 7114a5dac9d38511fbb993cdef41e084393f8cd4..0f7bafa483799a5032b813605d3484f73978b48f 100644
--- a/chrome/renderer/print_web_view_helper.cc
+++ b/chrome/renderer/print_web_view_helper.cc
@@ -143,77 +143,6 @@ void CalculatePrintCanvasSize(const PrintMsg_Print_Params& print_params,
print_params.desired_dpi));
}
-// Get the margins option selected and set custom margins appropriately.
-void SetCustomMarginsIfSelected(const DictionaryValue& job_settings,
- PrintMsg_PrintPages_Params* settings) {
- bool default_margins_selected;
- if (!job_settings.GetBoolean(printing::kSettingDefaultMarginsSelected,
- &default_margins_selected)) {
- NOTREACHED();
- default_margins_selected = true;
- }
-
- if (default_margins_selected)
- return;
-
- DictionaryValue* custom_margins;
- if (!job_settings.GetDictionary(printing::kSettingMargins,
- &custom_margins)) {
- NOTREACHED();
- return;
- }
-
- double custom_margin_top_in_points = 0;
- double custom_margin_left_in_points = 0;
- double custom_margin_right_in_points = 0;
- double custom_margin_bottom_in_points = 0;
- if (!custom_margins->GetDouble(printing::kSettingMarginTop,
- &custom_margin_top_in_points) ||
- !custom_margins->GetDouble(printing::kSettingMarginLeft,
- &custom_margin_left_in_points) ||
- !custom_margins->GetDouble(printing::kSettingMarginRight,
- &custom_margin_right_in_points) ||
- !custom_margins->GetDouble(printing::kSettingMarginBottom,
- &custom_margin_bottom_in_points)) {
- NOTREACHED();
- return;
- }
-
- int dpi = GetDPI(&settings->params);
- double custom_margin_top_in_dots = ConvertUnitDouble(
- custom_margin_top_in_points, printing::kPointsPerInch, dpi);
- double custom_margin_left_in_dots = ConvertUnitDouble(
- custom_margin_left_in_points, printing::kPointsPerInch, dpi);
- double custom_margin_right_in_dots = ConvertUnitDouble(
- custom_margin_right_in_points, printing::kPointsPerInch, dpi);
- double custom_margin_bottom_in_dots = ConvertUnitDouble(
- custom_margin_bottom_in_points, printing::kPointsPerInch, dpi);
-
-
- if (custom_margin_left_in_dots < 0 || custom_margin_right_in_dots < 0 ||
- custom_margin_top_in_dots < 0 || custom_margin_bottom_in_dots < 0) {
- NOTREACHED();
- return;
- }
-
- if (settings->params.page_size.width() < custom_margin_left_in_dots +
- custom_margin_right_in_dots ||
- settings->params.page_size.height() < custom_margin_top_in_dots +
- custom_margin_bottom_in_dots) {
- NOTREACHED();
- return;
- }
-
- settings->params.margin_top = custom_margin_top_in_dots;
- settings->params.margin_left = custom_margin_left_in_dots;
- settings->params.printable_size.set_width(
- settings->params.page_size.width() - custom_margin_right_in_dots -
- custom_margin_left_in_dots);
- settings->params.printable_size.set_height(
- settings->params.page_size.height() - custom_margin_bottom_in_dots -
- custom_margin_top_in_dots);
-}
-
// Get the (x, y) coordinate from where printing of the current text should
// start depending on the horizontal alignment (LEFT, RIGHT, CENTER) and
// vertical alignment (TOP, BOTTOM).
@@ -1157,7 +1086,6 @@ bool PrintWebViewHelper::UpdatePrintSettings(
Send(new PrintHostMsg_DidGetDefaultPageLayout(routing_id(),
default_page_layout));
}
- SetCustomMarginsIfSelected(job_settings, &settings);
// Header/Footer: Set |header_footer_info_|.
if (settings.params.display_header_footer) {
@@ -1194,7 +1122,7 @@ bool PrintWebViewHelper::GetPrintSettingsFromUser(WebKit::WebFrame* frame,
params.cookie = print_pages_params_->params.document_cookie;
params.has_selection = frame->hasSelection();
params.expected_pages_count = expected_pages_count;
- params.use_overlays = use_browser_overlays;
+ params.margin_type = printing::DEFAULT_MARGINS;
Send(new PrintHostMsg_DidShowPrintDialog(routing_id()));

Powered by Google App Engine
This is Rietveld 408576698