OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "printing/print_settings_initializer.h" | 5 #include "printing/print_settings_initializer.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <cmath> | 8 #include <cmath> |
9 #include <string> | 9 #include <string> |
10 | 10 |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 bool backgrounds = false; | 44 bool backgrounds = false; |
45 bool selection_only = false; | 45 bool selection_only = false; |
46 if (!job_settings.GetBoolean(kSettingShouldPrintBackgrounds, &backgrounds) || | 46 if (!job_settings.GetBoolean(kSettingShouldPrintBackgrounds, &backgrounds) || |
47 !job_settings.GetBoolean(kSettingShouldPrintSelectionOnly, | 47 !job_settings.GetBoolean(kSettingShouldPrintSelectionOnly, |
48 &selection_only)) { | 48 &selection_only)) { |
49 return false; | 49 return false; |
50 } | 50 } |
51 settings->set_should_print_backgrounds(backgrounds); | 51 settings->set_should_print_backgrounds(backgrounds); |
52 settings->set_selection_only(selection_only); | 52 settings->set_selection_only(selection_only); |
53 | 53 |
| 54 PrintSettings::RequestedMedia requested_media; |
| 55 const base::DictionaryValue* media_size_value = NULL; |
| 56 if (job_settings.GetDictionary(kSettingMediaSize, &media_size_value)) { |
| 57 int width_microns = 0; |
| 58 int height_microns = 0; |
| 59 if (media_size_value->GetInteger(kSettingMediaSizeWidthMicrons, |
| 60 &width_microns) && |
| 61 media_size_value->GetInteger(kSettingMediaSizeHeightMicrons, |
| 62 &height_microns)) { |
| 63 requested_media.size_microns = gfx::Size(width_microns, height_microns); |
| 64 } |
| 65 std::string vendor_id; |
| 66 if (media_size_value->GetString(kSettingMediaSizeVendorId, &vendor_id) && |
| 67 !vendor_id.empty()) { |
| 68 requested_media.vendor_id = vendor_id; |
| 69 } |
| 70 } |
| 71 settings->set_requested_media(requested_media); |
| 72 |
54 int margin_type = DEFAULT_MARGINS; | 73 int margin_type = DEFAULT_MARGINS; |
55 if (!job_settings.GetInteger(kSettingMarginsType, &margin_type) || | 74 if (!job_settings.GetInteger(kSettingMarginsType, &margin_type) || |
56 (margin_type != DEFAULT_MARGINS && | 75 (margin_type != DEFAULT_MARGINS && |
57 margin_type != NO_MARGINS && | 76 margin_type != NO_MARGINS && |
58 margin_type != CUSTOM_MARGINS && | 77 margin_type != CUSTOM_MARGINS && |
59 margin_type != PRINTABLE_AREA_MARGINS)) { | 78 margin_type != PRINTABLE_AREA_MARGINS)) { |
60 margin_type = DEFAULT_MARGINS; | 79 margin_type = DEFAULT_MARGINS; |
61 } | 80 } |
62 settings->set_margin_type(static_cast<MarginType>(margin_type)); | 81 settings->set_margin_type(static_cast<MarginType>(margin_type)); |
63 | 82 |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
97 settings->set_copies(copies); | 116 settings->set_copies(copies); |
98 settings->SetOrientation(landscape); | 117 settings->SetOrientation(landscape); |
99 settings->set_device_name(device_name); | 118 settings->set_device_name(device_name); |
100 settings->set_duplex_mode(static_cast<DuplexMode>(duplex_mode)); | 119 settings->set_duplex_mode(static_cast<DuplexMode>(duplex_mode)); |
101 settings->set_color(static_cast<ColorModel>(color)); | 120 settings->set_color(static_cast<ColorModel>(color)); |
102 | 121 |
103 return true; | 122 return true; |
104 } | 123 } |
105 | 124 |
106 } // namespace printing | 125 } // namespace printing |
OLD | NEW |