summaryrefslogtreecommitdiffstats
path: root/printing/page_size_margins.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/page_size_margins.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/page_size_margins.cc')
-rw-r--r--printing/page_size_margins.cc29
1 files changed, 29 insertions, 0 deletions
diff --git a/printing/page_size_margins.cc b/printing/page_size_margins.cc
new file mode 100644
index 0000000..05193909
--- /dev/null
+++ b/printing/page_size_margins.cc
@@ -0,0 +1,29 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "printing/page_size_margins.h"
+
+#include "base/logging.h"
+#include "base/values.h"
+#include "printing/print_job_constants.h"
+
+namespace printing {
+
+void getCustomMarginsFromJobSettings(const base::DictionaryValue& settings,
+ PageSizeMargins* page_size_margins) {
+ DictionaryValue* custom_margins;
+ if (!settings.GetDictionary(kSettingMarginsCustom, &custom_margins) ||
+ !custom_margins->GetDouble(kSettingMarginTop,
+ &page_size_margins->margin_top) ||
+ !custom_margins->GetDouble(kSettingMarginBottom,
+ &page_size_margins->margin_bottom) ||
+ !custom_margins->GetDouble(kSettingMarginLeft,
+ &page_size_margins->margin_left) ||
+ !custom_margins->GetDouble(kSettingMarginRight,
+ &page_size_margins->margin_right)) {
+ NOTREACHED();
+ }
+}
+
+} // namespace printing