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

Unified Diff: chrome/renderer/print_web_view_helper.cc

Issue 8261005: More options for the types of margins to add. (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 e651d3613f88b3a6990d7914151dc92a55e36986..afbb26233462518a91df5ae53561993c90bca1e4 100644
--- a/chrome/renderer/print_web_view_helper.cc
+++ b/chrome/renderer/print_web_view_helper.cc
@@ -164,37 +164,36 @@ void SetMarginsForPDF(PrintMsg_Print_Params* settings) {
// 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)) {
+ int margin_type = printing::DEFAULT_MARGINS;
+ if (!job_settings.GetInteger(printing::kSettingMarginsType, &margin_type)) {
NOTREACHED();
- default_margins_selected = true;
}
- if (default_margins_selected)
+ if (margin_type == printing::DEFAULT_MARGINS)
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;
+ if (margin_type == printing::CUSTOM_MARGINS) {
+ DictionaryValue* custom_margins;
+ if (!job_settings.GetDictionary(printing::kSettingMarginsCustom,
+ &custom_margins)) {
+ NOTREACHED();
+ return;
+ }
+ 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);
« no previous file with comments | « chrome/browser/resources/print_preview/print_preview.js ('k') | chrome/renderer/print_web_view_helper_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698