diff options
author | alekseys@chromium.org <alekseys@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-06-12 08:08:06 +0000 |
---|---|---|
committer | alekseys@chromium.org <alekseys@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-06-12 08:08:06 +0000 |
commit | 72ddef972e6a0976a94ad215d692735612a20ab8 (patch) | |
tree | 48129999b44be953d570c3bb9bfe7a9b4ec780f5 /printing | |
parent | d60aa1c68a6280f0ea253f64c795f816e852cf87 (diff) | |
download | chromium_src-72ddef972e6a0976a94ad215d692735612a20ab8.zip chromium_src-72ddef972e6a0976a94ad215d692735612a20ab8.tar.gz chromium_src-72ddef972e6a0976a94ad215d692735612a20ab8.tar.bz2 |
Changes in printer settings:
* add vendor id and custom display name to media selection
* propagate selected media size in PrintSettings Related
Сhanges in JS:
* Use media custom diaply name received from the native layer
* Make sure media size selection is propagated to the native layer
BUG=239879
NOTRY=true
Review URL: https://codereview.chromium.org/325313003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@276578 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'printing')
-rw-r--r-- | printing/print_job_constants.cc | 3 | ||||
-rw-r--r-- | printing/print_job_constants.h | 1 | ||||
-rw-r--r-- | printing/print_settings.cc | 1 | ||||
-rw-r--r-- | printing/print_settings.h | 26 | ||||
-rw-r--r-- | printing/print_settings_initializer.cc | 19 | ||||
-rw-r--r-- | printing/printing_context.cc | 20 |
6 files changed, 57 insertions, 13 deletions
diff --git a/printing/print_job_constants.cc b/printing/print_job_constants.cc index 832f700..8ac5db4 100644 --- a/printing/print_job_constants.cc +++ b/printing/print_job_constants.cc @@ -86,6 +86,9 @@ const char kSettingMediaSizeHeightMicrons[] = "height_microns"; // Key that specifies the requested media width in microns. const char kSettingMediaSizeWidthMicrons[] = "width_microns"; +// Key that specifies the requested media platform specific vendor id. +const char kSettingMediaSizeVendorId[] = "vendor_id"; + // Key that specifies the bottom margin of the page. const char kSettingMarginBottom[] = "marginBottom"; diff --git a/printing/print_job_constants.h b/printing/print_job_constants.h index 2deca79..257cba6 100644 --- a/printing/print_job_constants.h +++ b/printing/print_job_constants.h @@ -35,6 +35,7 @@ PRINTING_EXPORT extern const char kSettingLandscape[]; PRINTING_EXPORT extern const char kSettingMediaSize[]; PRINTING_EXPORT extern const char kSettingMediaSizeHeightMicrons[]; PRINTING_EXPORT extern const char kSettingMediaSizeWidthMicrons[]; +PRINTING_EXPORT extern const char kSettingMediaSizeVendorId[]; PRINTING_EXPORT extern const char kSettingMarginBottom[]; PRINTING_EXPORT extern const char kSettingMarginLeft[]; PRINTING_EXPORT extern const char kSettingMarginRight[]; diff --git a/printing/print_settings.cc b/printing/print_settings.cc index f2dc425..b1c50c9 100644 --- a/printing/print_settings.cc +++ b/printing/print_settings.cc @@ -128,6 +128,7 @@ void PrintSettings::Clear() { url_ = base::string16(); display_header_footer_ = false; device_name_.clear(); + requested_media_ = RequestedMedia(); page_setup_device_units_.Clear(); dpi_ = 0; landscape_ = false; diff --git a/printing/print_settings.h b/printing/print_settings.h index b18d860..b942189 100644 --- a/printing/print_settings.h +++ b/printing/print_settings.h @@ -29,6 +29,19 @@ PRINTING_EXPORT void GetColorModelForMode(int color_mode, // OS-independent print settings. class PRINTING_EXPORT PrintSettings { public: + // Media properties requested by the user. Default instance represents + // default media selection. + struct RequestedMedia { + // Size of the media, in microns. + gfx::Size size_microns; + // Platform specific id to map it back to the particular media. + std::string vendor_id; + + bool IsDefault() const { + return size_microns.IsEmpty() && vendor_id.empty(); + } + }; + PrintSettings(); ~PrintSettings(); @@ -43,6 +56,16 @@ class PRINTING_EXPORT PrintSettings { void SetOrientation(bool landscape); bool landscape() const { return landscape_; } + // Updates user requested media. + void set_requested_media(const RequestedMedia& media) { + requested_media_ = media; + } + // Media properties requested by the user. Translated into device media by the + // platform specific layers. + const RequestedMedia& requested_media() const { + return requested_media_; + } + // Set printer printable area in in device units. // Some platforms already provide flipped area. Set |landscape_needs_flip| // to false on those platforms to avoid double flipping. @@ -174,6 +197,9 @@ class PRINTING_EXPORT PrintSettings { // Printer device name as opened by the OS. base::string16 device_name_; + // Media requested by the user. + RequestedMedia requested_media_; + // Page setup in device units. PageSetup page_setup_device_units_; diff --git a/printing/print_settings_initializer.cc b/printing/print_settings_initializer.cc index 565fc78..df6a32e 100644 --- a/printing/print_settings_initializer.cc +++ b/printing/print_settings_initializer.cc @@ -51,6 +51,25 @@ bool PrintSettingsInitializer::InitSettings( settings->set_should_print_backgrounds(backgrounds); settings->set_selection_only(selection_only); + PrintSettings::RequestedMedia requested_media; + const base::DictionaryValue* media_size_value = NULL; + if (job_settings.GetDictionary(kSettingMediaSize, &media_size_value)) { + int width_microns = 0; + int height_microns = 0; + if (media_size_value->GetInteger(kSettingMediaSizeWidthMicrons, + &width_microns) && + media_size_value->GetInteger(kSettingMediaSizeHeightMicrons, + &height_microns)) { + requested_media.size_microns = gfx::Size(width_microns, height_microns); + } + std::string vendor_id; + if (media_size_value->GetString(kSettingMediaSizeVendorId, &vendor_id) && + !vendor_id.empty()) { + requested_media.vendor_id = vendor_id; + } + } + settings->set_requested_media(requested_media); + int margin_type = DEFAULT_MARGINS; if (!job_settings.GetInteger(kSettingMarginsType, &margin_type) || (margin_type != DEFAULT_MARGINS && diff --git a/printing/printing_context.cc b/printing/printing_context.cc index 8d438d0..c7cd644 100644 --- a/printing/printing_context.cc +++ b/printing/printing_context.cc @@ -96,19 +96,13 @@ PrintingContext::Result PrintingContext::UpdatePrintSettings( is_cloud_dialog || print_with_privet)) { settings_.set_dpi(kDefaultPdfDpi); gfx::Size paper_size(GetPdfPaperSizeDeviceUnits()); - const base::DictionaryValue* media_size = NULL; - if (job_settings.GetDictionary(kSettingMediaSize, &media_size)) { - int width_microns = 0; - int height_microns = 0; - if (media_size->GetInteger(kSettingMediaSizeWidthMicrons, - &width_microns) && - media_size->GetInteger(kSettingMediaSizeHeightMicrons, - &height_microns)) { - float deviceMicronsPerDeviceUnit = - (kHundrethsMMPerInch * 10.0f) / settings_.device_units_per_inch(); - paper_size = gfx::Size(width_microns / deviceMicronsPerDeviceUnit, - height_microns / deviceMicronsPerDeviceUnit); - } + if (!settings_.requested_media().size_microns.IsEmpty()) { + float deviceMicronsPerDeviceUnit = + (kHundrethsMMPerInch * 10.0f) / settings_.device_units_per_inch(); + paper_size = gfx::Size(settings_.requested_media().size_microns.width() / + deviceMicronsPerDeviceUnit, + settings_.requested_media().size_microns.height() / + deviceMicronsPerDeviceUnit); } gfx::Rect paper_rect(0, 0, paper_size.width(), paper_size.height()); if (print_to_cloud || print_with_privet) { |