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 04:07:30 +0000
committerdpapad@chromium.org <dpapad@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-11-15 04:07:30 +0000
commit8b7d034cb32b95cd36463a23be0eee621146e150 (patch)
treeebf3da7bd9fc2ccc63364cefa7e05ae1c0679391 /printing/printing_context.cc
parent35a62d7067fd90e43945533d4f879e6f2a635958 (diff)
downloadchromium_src-8b7d034cb32b95cd36463a23be0eee621146e150.zip
chromium_src-8b7d034cb32b95cd36463a23be0eee621146e150.tar.gz
chromium_src-8b7d034cb32b95cd36463a23be0eee621146e150.tar.bz2
Revert 110035 - 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 TBR=dpapad@chromium.org Review URL: http://codereview.chromium.org/8564040 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@110040 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'printing/printing_context.cc')
-rw-r--r--printing/printing_context.cc27
1 files changed, 19 insertions, 8 deletions
diff --git a/printing/printing_context.cc b/printing/printing_context.cc
index b94e7a8..cc39e6c 100644
--- a/printing/printing_context.cc
+++ b/printing/printing_context.cc
@@ -7,7 +7,6 @@
#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 {
@@ -63,15 +62,27 @@ PrintingContext::Result PrintingContext::UpdatePrintSettings(
settings_.margin_type = static_cast<MarginType>(margin_type);
if (margin_type == CUSTOM_MARGINS) {
- printing::PageSizeMargins page_size_margins;
- getCustomMarginsFromJobSettings(job_settings, &page_size_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();
+ }
PageMargins margins_in_points;
margins_in_points.Clear();
- 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;
+ 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;
settings_.SetCustomMargins(margins_in_points);
}