summaryrefslogtreecommitdiffstats
path: root/printing/printing_context.cc
diff options
context:
space:
mode:
authordpapad@chromium.org <dpapad@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-11-15 03:45:36 +0000
committerdpapad@chromium.org <dpapad@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-11-15 03:45:36 +0000
commit1943d11ae0a8a306aa0da1920283c559a18b67ed (patch)
treef0b174dadec3a65b2158d2ae6445901423cebd40 /printing/printing_context.cc
parenta4a092b1dc2a8f967a6bc2c5566b7f8b7cb6b6fa (diff)
downloadchromium_src-1943d11ae0a8a306aa0da1920283c559a18b67ed.zip
chromium_src-1943d11ae0a8a306aa0da1920283c559a18b67ed.tar.gz
chromium_src-1943d11ae0a8a306aa0da1920283c559a18b67ed.tar.bz2
Print Preview: Making margin selection sticky (part 2/2)
This CL makes "Custom" margins sticky across different preview sessions but also within the same preview session. Here is a summary of all changes. - Within same preview session: So far selecting "Custom" was picking up from whatever the previous selected option was. Now, "Custom" remembers the specified margins. To test this select "Custom", do some dragging, then change to another option and back to "Custom". - Across preview sessions: Select "Custom", do some dragging, then print. Open print preview again, the last used custom margins are remembered. - There was a bunch of messages sent from JS to get various info/settings (initiator tab title, measurement system and number format, last used margin settings, default printer). I created a single message "getInitialSettings" to get all at once (they are needed before the 1st preview is is requested). BUG=102446 TEST=See bug description. Review URL: http://codereview.chromium.org/8351048 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@110035 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'printing/printing_context.cc')
-rw-r--r--printing/printing_context.cc27
1 files changed, 8 insertions, 19 deletions
diff --git a/printing/printing_context.cc b/printing/printing_context.cc
index cc39e6c..b94e7a8 100644
--- a/printing/printing_context.cc
+++ b/printing/printing_context.cc
@@ -7,6 +7,7 @@
#include "base/logging.h"
#include "base/values.h"
#include "printing/page_setup.h"
+#include "printing/page_size_margins.h"
#include "printing/print_settings_initializer.h"
namespace printing {
@@ -62,27 +63,15 @@ PrintingContext::Result PrintingContext::UpdatePrintSettings(
settings_.margin_type = static_cast<MarginType>(margin_type);
if (margin_type == CUSTOM_MARGINS) {
- double top_margin_in_points = 0;
- double bottom_margin_in_points = 0;
- double left_margin_in_points = 0;
- double right_margin_in_points = 0;
- DictionaryValue* custom_margins;
- if (!job_settings.GetDictionary(kSettingMarginsCustom, &custom_margins) ||
- !custom_margins->GetDouble(kSettingMarginTop, &top_margin_in_points) ||
- !custom_margins->GetDouble(kSettingMarginBottom,
- &bottom_margin_in_points) ||
- !custom_margins->GetDouble(kSettingMarginLeft,
- &left_margin_in_points) ||
- !custom_margins->GetDouble(kSettingMarginRight,
- &right_margin_in_points)) {
- NOTREACHED();
- }
+ printing::PageSizeMargins page_size_margins;
+ getCustomMarginsFromJobSettings(job_settings, &page_size_margins);
+
PageMargins margins_in_points;
margins_in_points.Clear();
- margins_in_points.top = top_margin_in_points;
- margins_in_points.bottom = bottom_margin_in_points;
- margins_in_points.left = left_margin_in_points;
- margins_in_points.right = right_margin_in_points;
+ margins_in_points.top = page_size_margins.margin_top;
+ margins_in_points.bottom = page_size_margins.margin_bottom;
+ margins_in_points.left = page_size_margins.margin_left;
+ margins_in_points.right = page_size_margins.margin_right;
settings_.SetCustomMargins(margins_in_points);
}