| Index: printing/print_settings_initializer.cc
|
| diff --git a/printing/print_settings_initializer.cc b/printing/print_settings_initializer.cc
|
| deleted file mode 100644
|
| index df6a32e40e5a56575e562637e6e021f1a120d56e..0000000000000000000000000000000000000000
|
| --- a/printing/print_settings_initializer.cc
|
| +++ /dev/null
|
| @@ -1,125 +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/print_settings_initializer.h"
|
| -
|
| -#include <algorithm>
|
| -#include <cmath>
|
| -#include <string>
|
| -
|
| -#include "base/strings/string_number_conversions.h"
|
| -#include "base/strings/utf_string_conversions.h"
|
| -#include "base/time/time.h"
|
| -#include "base/values.h"
|
| -#include "printing/page_size_margins.h"
|
| -#include "printing/print_job_constants.h"
|
| -#include "printing/print_settings.h"
|
| -#include "printing/units.h"
|
| -
|
| -namespace printing {
|
| -
|
| -bool PrintSettingsInitializer::InitSettings(
|
| - const base::DictionaryValue& job_settings,
|
| - const PageRanges& ranges,
|
| - PrintSettings* settings) {
|
| - bool display_header_footer = false;
|
| - if (!job_settings.GetBoolean(kSettingHeaderFooterEnabled,
|
| - &display_header_footer)) {
|
| - return false;
|
| - }
|
| - settings->set_display_header_footer(display_header_footer);
|
| -
|
| - if (settings->display_header_footer()) {
|
| - base::string16 title;
|
| - base::string16 url;
|
| - if (!job_settings.GetString(kSettingHeaderFooterTitle, &title) ||
|
| - !job_settings.GetString(kSettingHeaderFooterURL, &url)) {
|
| - return false;
|
| - }
|
| - settings->set_title(title);
|
| - settings->set_url(url);
|
| - }
|
| -
|
| - bool backgrounds = false;
|
| - bool selection_only = false;
|
| - if (!job_settings.GetBoolean(kSettingShouldPrintBackgrounds, &backgrounds) ||
|
| - !job_settings.GetBoolean(kSettingShouldPrintSelectionOnly,
|
| - &selection_only)) {
|
| - return false;
|
| - }
|
| - 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 &&
|
| - margin_type != NO_MARGINS &&
|
| - margin_type != CUSTOM_MARGINS &&
|
| - margin_type != PRINTABLE_AREA_MARGINS)) {
|
| - margin_type = DEFAULT_MARGINS;
|
| - }
|
| - settings->set_margin_type(static_cast<MarginType>(margin_type));
|
| -
|
| - if (margin_type == CUSTOM_MARGINS) {
|
| - PageSizeMargins page_size_margins;
|
| - GetCustomMarginsFromJobSettings(job_settings, &page_size_margins);
|
| -
|
| - 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;
|
| -
|
| - settings->SetCustomMargins(margins_in_points);
|
| - }
|
| -
|
| - settings->set_ranges(ranges);
|
| -
|
| - int color = 0;
|
| - bool landscape = false;
|
| - int duplex_mode = 0;
|
| - base::string16 device_name;
|
| - bool collate = false;
|
| - int copies = 1;
|
| -
|
| - if (!job_settings.GetBoolean(kSettingCollate, &collate) ||
|
| - !job_settings.GetInteger(kSettingCopies, &copies) ||
|
| - !job_settings.GetInteger(kSettingColor, &color) ||
|
| - !job_settings.GetInteger(kSettingDuplexMode, &duplex_mode) ||
|
| - !job_settings.GetBoolean(kSettingLandscape, &landscape) ||
|
| - !job_settings.GetString(kSettingDeviceName, &device_name)) {
|
| - return false;
|
| - }
|
| -
|
| - settings->set_collate(collate);
|
| - settings->set_copies(copies);
|
| - settings->SetOrientation(landscape);
|
| - settings->set_device_name(device_name);
|
| - settings->set_duplex_mode(static_cast<DuplexMode>(duplex_mode));
|
| - settings->set_color(static_cast<ColorModel>(color));
|
| -
|
| - return true;
|
| -}
|
| -
|
| -} // namespace printing
|
|
|