diff options
author | dpapad@chromium.org <dpapad@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-11-15 04:07:30 +0000 |
---|---|---|
committer | dpapad@chromium.org <dpapad@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-11-15 04:07:30 +0000 |
commit | 8b7d034cb32b95cd36463a23be0eee621146e150 (patch) | |
tree | ebf3da7bd9fc2ccc63364cefa7e05ae1c0679391 /printing | |
parent | 35a62d7067fd90e43945533d4f879e6f2a635958 (diff) | |
download | chromium_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')
-rw-r--r-- | printing/page_size_margins.cc | 29 | ||||
-rw-r--r-- | printing/page_size_margins.h | 8 | ||||
-rw-r--r-- | printing/printing.gyp | 1 | ||||
-rw-r--r-- | printing/printing_context.cc | 27 |
4 files changed, 20 insertions, 45 deletions
diff --git a/printing/page_size_margins.cc b/printing/page_size_margins.cc deleted file mode 100644 index 05193909..0000000 --- a/printing/page_size_margins.cc +++ /dev/null @@ -1,29 +0,0 @@ -// 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 diff --git a/printing/page_size_margins.h b/printing/page_size_margins.h index c1109ab..4f74c297 100644 --- a/printing/page_size_margins.h +++ b/printing/page_size_margins.h @@ -5,10 +5,6 @@ #ifndef PRINTING_PAGE_SIZE_MARGINS_H_ #define PRINTING_PAGE_SIZE_MARGINS_H_ -namespace base { -class DictionaryValue; -} - namespace printing { // Struct that holds margin and content area sizes of a page. Units are @@ -22,9 +18,7 @@ struct PageSizeMargins { double margin_left; }; -void getCustomMarginsFromJobSettings(const base::DictionaryValue& settings, - PageSizeMargins* page_size_margins); - } // namespace printing #endif // PRINTING_PAGE_SIZE_MARGINS_H_ + diff --git a/printing/printing.gyp b/printing/printing.gyp index 34e3b4e..0cb2c06 100644 --- a/printing/printing.gyp +++ b/printing/printing.gyp @@ -50,7 +50,6 @@ 'page_range.h', 'page_setup.cc', 'page_setup.h', - 'page_size_margins.cc', 'page_size_margins.h', 'pdf_metafile_cg_mac.cc', 'pdf_metafile_cg_mac.h', 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); } |