summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/browser/printing/print_job_unittest.cc4
-rw-r--r--printing/print_settings.cc146
-rw-r--r--printing/print_settings.h38
-rw-r--r--printing/print_settings_initializer_gtk.cc78
-rw-r--r--printing/print_settings_initializer_gtk.h33
-rw-r--r--printing/print_settings_initializer_mac.cc70
-rw-r--r--printing/print_settings_initializer_mac.h32
-rw-r--r--printing/print_settings_initializer_win.cc54
-rw-r--r--printing/print_settings_initializer_win.h36
-rw-r--r--printing/printing.gyp12
-rw-r--r--printing/printing_context.cc2
-rw-r--r--printing/printing_context.h1
-rw-r--r--printing/printing_context_cairo.cc5
-rw-r--r--printing/printing_context_mac.mm5
-rw-r--r--printing/printing_context_win.cc18
15 files changed, 341 insertions, 193 deletions
diff --git a/chrome/browser/printing/print_job_unittest.cc b/chrome/browser/printing/print_job_unittest.cc
index 757d6c8..1b62016 100644
--- a/chrome/browser/printing/print_job_unittest.cc
+++ b/chrome/browser/printing/print_job_unittest.cc
@@ -92,8 +92,8 @@ class TestPrintNotifObserv : public NotificationObserver {
#define MAYBE_SimplePrint SimplePrint
#endif
TEST(PrintJobTest, MAYBE_SimplePrint) {
- // Test the multithreaded nature of PrintJob to make sure we can use it with
- // known livetime.
+ // Test the multi-threaded nature of PrintJob to make sure we can use it with
+ // known lifetime.
// This message loop is actually never run.
MessageLoop current;
diff --git a/printing/print_settings.cc b/printing/print_settings.cc
index 6ab53f6..cf8c50a 100644
--- a/printing/print_settings.cc
+++ b/printing/print_settings.cc
@@ -4,18 +4,7 @@
#include "printing/print_settings.h"
-// TODO(jhawkins): Move platform-specific implementations to their own files.
-#if defined(USE_X11)
-#include <gtk/gtk.h>
-#include <gtk/gtkprinter.h>
-#include "printing/native_metafile.h"
-#endif // defined(USE_X11)
-
#include "base/atomic_sequence_num.h"
-#include "base/logging.h"
-#include "base/string_piece.h"
-#include "base/sys_string_conversions.h"
-#include "base/utf_string_conversions.h"
#include "printing/units.h"
namespace printing {
@@ -49,141 +38,6 @@ void PrintSettings::Clear() {
landscape_ = false;
}
-#if defined(OS_WIN)
-void PrintSettings::Init(HDC hdc,
- const DEVMODE& dev_mode,
- const PageRanges& new_ranges,
- const std::wstring& new_device_name,
- bool print_selection_only) {
- DCHECK(hdc);
- printer_name_ = dev_mode.dmDeviceName;
- device_name_ = new_device_name;
- ranges = new_ranges;
- landscape_ = dev_mode.dmOrientation == DMORIENT_LANDSCAPE;
- selection_only = print_selection_only;
-
- dpi_ = GetDeviceCaps(hdc, LOGPIXELSX);
- // No printer device is known to advertise different dpi in X and Y axis; even
- // the fax device using the 200x100 dpi setting. It's ought to break so many
- // applications that it's not even needed to care about. WebKit doesn't
- // support different dpi settings in X and Y axis.
- DCHECK_EQ(dpi_, GetDeviceCaps(hdc, LOGPIXELSY));
-
- DCHECK_EQ(GetDeviceCaps(hdc, SCALINGFACTORX), 0);
- DCHECK_EQ(GetDeviceCaps(hdc, SCALINGFACTORY), 0);
-
- // Initialize page_setup_device_units_.
- gfx::Size physical_size_device_units(GetDeviceCaps(hdc, PHYSICALWIDTH),
- GetDeviceCaps(hdc, PHYSICALHEIGHT));
- gfx::Rect printable_area_device_units(GetDeviceCaps(hdc, PHYSICALOFFSETX),
- GetDeviceCaps(hdc, PHYSICALOFFSETY),
- GetDeviceCaps(hdc, HORZRES),
- GetDeviceCaps(hdc, VERTRES));
-
- SetPrinterPrintableArea(physical_size_device_units,
- printable_area_device_units,
- dpi_);
-}
-#elif defined(OS_MACOSX)
-void PrintSettings::Init(PMPrinter printer, PMPageFormat page_format,
- const PageRanges& new_ranges,
- bool print_selection_only) {
- printer_name_ = base::SysCFStringRefToWide(PMPrinterGetName(printer));
- device_name_ = base::SysCFStringRefToWide(PMPrinterGetID(printer));
- ranges = new_ranges;
- PMOrientation orientation = kPMPortrait;
- PMGetOrientation(page_format, &orientation);
- landscape_ = orientation == kPMLandscape;
- selection_only = print_selection_only;
-
- UInt32 resolution_count = 0;
- PMResolution best_resolution = { 72.0, 72.0 };
- OSStatus status = PMPrinterGetPrinterResolutionCount(printer,
- &resolution_count);
- if (status == noErr) {
- // Resolution indexes are 1-based.
- for (uint32 i = 1; i <= resolution_count; ++i) {
- PMResolution resolution;
- PMPrinterGetIndexedPrinterResolution(printer, i, &resolution);
- if (resolution.hRes > best_resolution.hRes)
- best_resolution = resolution;
- }
- }
- dpi_ = best_resolution.hRes;
- // See comment in the Windows code above.
- DCHECK_EQ(dpi_, best_resolution.vRes);
-
- // Get printable area and paper rects (in points)
- PMRect page_rect, paper_rect;
- PMGetAdjustedPageRect(page_format, &page_rect);
- PMGetAdjustedPaperRect(page_format, &paper_rect);
- // Device units are in points. Units per inch is 72.
- gfx::Size physical_size_device_units(
- (paper_rect.right - paper_rect.left),
- (paper_rect.bottom - paper_rect.top));
- gfx::Rect printable_area_device_units(
- (page_rect.left - paper_rect.left),
- (page_rect.top - paper_rect.top),
- (page_rect.right - page_rect.left),
- (page_rect.bottom - page_rect.top));
-
- SetPrinterPrintableArea(physical_size_device_units,
- printable_area_device_units,
- 72);
-}
-#elif defined(USE_X11)
-void PrintSettings::Init(GtkPrintSettings* settings,
- GtkPageSetup* page_setup,
- const PageRanges& new_ranges,
- bool print_selection_only) {
- // TODO(jhawkins): |printer_name_| and |device_name_| should be string16.
- base::StringPiece name(
- reinterpret_cast<const char*>(gtk_print_settings_get_printer(settings)));
- printer_name_ = UTF8ToWide(name);
- device_name_ = printer_name_;
- ranges = new_ranges;
- selection_only = print_selection_only;
-
- GtkPageOrientation orientation = gtk_print_settings_get_orientation(settings);
- landscape_ = orientation == GTK_PAGE_ORIENTATION_LANDSCAPE;
-
- gfx::Size physical_size_device_units;
- gfx::Rect printable_area_device_units;
- dpi_ = gtk_print_settings_get_resolution(settings);
- if (dpi_) {
- // Initialize page_setup_device_units_.
- physical_size_device_units.SetSize(
- gtk_page_setup_get_paper_width(page_setup, GTK_UNIT_INCH) * dpi_,
- gtk_page_setup_get_paper_height(page_setup, GTK_UNIT_INCH) * dpi_);
- printable_area_device_units.SetRect(
- gtk_page_setup_get_left_margin(page_setup, GTK_UNIT_INCH) * dpi_,
- gtk_page_setup_get_top_margin(page_setup, GTK_UNIT_INCH) * dpi_,
- gtk_page_setup_get_page_width(page_setup, GTK_UNIT_INCH) * dpi_,
- gtk_page_setup_get_page_height(page_setup, GTK_UNIT_INCH) * dpi_);
- } else {
- // Use dummy values if we cannot get valid values.
- // TODO(jhawkins) Remove this hack when the Linux printing refactoring
- // finishes.
- dpi_ = kPixelsPerInch;
- double page_width_in_pixel = 8.5 * dpi_;
- double page_height_in_pixel = 11.0 * dpi_;
- physical_size_device_units.SetSize(
- static_cast<int>(page_width_in_pixel),
- static_cast<int>(page_height_in_pixel));
- printable_area_device_units.SetRect(
- static_cast<int>(
- NativeMetafile::kLeftMarginInInch * printing::kPixelsPerInch),
- static_cast<int>(
- NativeMetafile::kTopMarginInInch * printing::kPixelsPerInch),
- page_width_in_pixel,
- page_height_in_pixel);
- }
- SetPrinterPrintableArea(physical_size_device_units,
- printable_area_device_units,
- dpi_);
-}
-#endif
-
void PrintSettings::SetPrinterPrintableArea(
gfx::Size const& physical_size_device_units,
gfx::Rect const& printable_area_device_units,
diff --git a/printing/print_settings.h b/printing/print_settings.h
index a7fe73c..bc9cbaf 100644
--- a/printing/print_settings.h
+++ b/printing/print_settings.h
@@ -10,18 +10,6 @@
#include "printing/page_range.h"
#include "printing/page_setup.h"
-#if defined(OS_MACOSX)
-#import <ApplicationServices/ApplicationServices.h>
-#endif
-
-#if defined(OS_WIN)
-typedef struct HDC__* HDC;
-typedef struct _devicemodeW DEVMODE;
-#elif defined(USE_X11)
-typedef struct _GtkPrintSettings GtkPrintSettings;
-typedef struct _GtkPageSetup GtkPageSetup;
-#endif
-
namespace printing {
// OS-independent print settings.
@@ -33,27 +21,6 @@ class PrintSettings {
// Reinitialize the settings to the default values.
void Clear();
-#if defined(OS_WIN)
- // Reads the settings from the selected device context. Calculates derived
- // values like printable_area_.
- void Init(HDC hdc,
- const DEVMODE& dev_mode,
- const PageRanges& new_ranges,
- const std::wstring& new_device_name,
- bool selection_only);
-#elif defined(OS_MACOSX)
- // Reads the settings from the given PMPrinter and PMPageFormat.
- void Init(PMPrinter printer, PMPageFormat page_format,
- const PageRanges& new_ranges, bool print_selection_only);
-#elif defined(USE_X11)
- // Initializes the settings from the given GtkPrintSettings and GtkPageSetup.
- // TODO(jhawkins): This method is a mess across the platforms. Refactor.
- void Init(GtkPrintSettings* settings,
- GtkPageSetup* page_setup,
- const PageRanges& new_ranges,
- bool print_selection_onl);
-#endif
-
// Set printer printable area in in device units.
void SetPrinterPrintableArea(gfx::Size const& physical_size_device_units,
gfx::Rect const& printable_area_device_units,
@@ -64,11 +31,16 @@ class PrintSettings {
// output.
bool Equals(const PrintSettings& rhs) const;
+ void set_landscape(bool landscape) { landscape_ = landscape; }
+ void set_printer_name(const std::wstring& printer_name) {
+ printer_name_ = printer_name;
+ }
const std::wstring& printer_name() const { return printer_name_; }
void set_device_name(const std::wstring& device_name) {
device_name_ = device_name;
}
const std::wstring& device_name() const { return device_name_; }
+ void set_dpi(int dpi) { dpi_ = dpi; }
int dpi() const { return dpi_; }
const PageSetup& page_setup_device_units() const {
return page_setup_device_units_;
diff --git a/printing/print_settings_initializer_gtk.cc b/printing/print_settings_initializer_gtk.cc
new file mode 100644
index 0000000..fd7a5fd
--- /dev/null
+++ b/printing/print_settings_initializer_gtk.cc
@@ -0,0 +1,78 @@
+// Copyright (c) 2010 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_gtk.h"
+
+#include <gtk/gtk.h>
+#include <gtk/gtkprinter.h>
+
+#include "base/string_piece.h"
+#include "base/utf_string_conversions.h"
+#include "printing/native_metafile.h"
+#include "printing/print_settings.h"
+#include "printing/units.h"
+
+namespace printing {
+
+// static
+void PrintSettingsInitializerGtk::InitPrintSettings(
+ GtkPrintSettings* settings,
+ GtkPageSetup* page_setup,
+ const PageRanges& new_ranges,
+ bool print_selection_only,
+ PrintSettings* print_settings) {
+ DCHECK(settings);
+ DCHECK(page_setup);
+ DCHECK(print_settings);
+
+ // TODO(jhawkins): |printer_name_| and |device_name_| should be string16.
+ base::StringPiece name(
+ reinterpret_cast<const char*>(gtk_print_settings_get_printer(settings)));
+ print_settings->set_printer_name(UTF8ToWide(name));
+ print_settings->set_device_name(print_settings->printer_name());
+ print_settings->ranges = new_ranges;
+ print_settings->selection_only = print_selection_only;
+
+ GtkPageOrientation orientation = gtk_print_settings_get_orientation(settings);
+ print_settings->set_landscape(orientation == GTK_PAGE_ORIENTATION_LANDSCAPE);
+
+ gfx::Size physical_size_device_units;
+ gfx::Rect printable_area_device_units;
+ int dpi = gtk_print_settings_get_resolution(settings);
+ if (dpi) {
+ // Initialize page_setup_device_units_.
+ physical_size_device_units.SetSize(
+ gtk_page_setup_get_paper_width(page_setup, GTK_UNIT_INCH) * dpi,
+ gtk_page_setup_get_paper_height(page_setup, GTK_UNIT_INCH) * dpi);
+ printable_area_device_units.SetRect(
+ gtk_page_setup_get_left_margin(page_setup, GTK_UNIT_INCH) * dpi,
+ gtk_page_setup_get_top_margin(page_setup, GTK_UNIT_INCH) * dpi,
+ gtk_page_setup_get_page_width(page_setup, GTK_UNIT_INCH) * dpi,
+ gtk_page_setup_get_page_height(page_setup, GTK_UNIT_INCH) * dpi);
+ } else {
+ // Use dummy values if we cannot get valid values.
+ // TODO(jhawkins) Remove this hack when the Linux printing refactoring
+ // finishes.
+ dpi = kPixelsPerInch;
+ double page_width_in_pixel = 8.5 * dpi;
+ double page_height_in_pixel = 11.0 * dpi;
+ physical_size_device_units.SetSize(
+ static_cast<int>(page_width_in_pixel),
+ static_cast<int>(page_height_in_pixel));
+ printable_area_device_units.SetRect(
+ static_cast<int>(
+ NativeMetafile::kLeftMarginInInch * printing::kPixelsPerInch),
+ static_cast<int>(
+ NativeMetafile::kTopMarginInInch * printing::kPixelsPerInch),
+ page_width_in_pixel,
+ page_height_in_pixel);
+ }
+
+ print_settings->set_dpi(dpi);
+ print_settings->SetPrinterPrintableArea(physical_size_device_units,
+ printable_area_device_units,
+ dpi);
+}
+
+} // namespace printing
diff --git a/printing/print_settings_initializer_gtk.h b/printing/print_settings_initializer_gtk.h
new file mode 100644
index 0000000..6dd3930
--- /dev/null
+++ b/printing/print_settings_initializer_gtk.h
@@ -0,0 +1,33 @@
+// Copyright (c) 2010 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.
+
+#ifndef PRINTING_PRINT_SETTINGS_INITIALIZER_GTK_H_
+#define PRINTING_PRINT_SETTINGS_INITIALIZER_GTK_H_
+
+#include "base/logging.h"
+#include "printing/page_range.h"
+
+typedef struct _GtkPrintSettings GtkPrintSettings;
+typedef struct _GtkPageSetup GtkPageSetup;
+
+namespace printing {
+
+class PrintSettings;
+
+// Initializes a PrintSettings object from the provided Gtk printer objects.
+class PrintSettingsInitializerGtk {
+ public:
+ static void InitPrintSettings(GtkPrintSettings* settings,
+ GtkPageSetup* page_setup,
+ const PageRanges& new_ranges,
+ bool print_selection_only,
+ PrintSettings* print_settings);
+
+ private:
+ DISALLOW_IMPLICIT_CONSTRUCTORS(PrintSettingsInitializerGtk);
+};
+
+} // namespace printing
+
+#endif // PRINTING_PRINT_SETTINGS_INITIALIZER_GTK_H_
diff --git a/printing/print_settings_initializer_mac.cc b/printing/print_settings_initializer_mac.cc
new file mode 100644
index 0000000..5bb7282
--- /dev/null
+++ b/printing/print_settings_initializer_mac.cc
@@ -0,0 +1,70 @@
+// Copyright (c) 2010 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_mac.h"
+
+#include "base/sys_string_conversions.h"
+#include "printing/print_settings.h"
+
+namespace printing {
+
+// static
+void PrintSettingsInitializerMac::InitPrintSettings(
+ PMPrinter printer,
+ PMPageFormat page_format,
+ const PageRanges& new_ranges,
+ bool print_selection_only,
+ PrintSettings* print_settings) {
+ DCHECK(print_settings);
+
+ print_settings->set_printer_name(
+ base::SysCFStringRefToWide(PMPrinterGetName(printer)));
+ print_settings->set_device_name(
+ base::SysCFStringRefToWide(PMPrinterGetID(printer)));
+ print_settings->ranges = new_ranges;
+
+ PMOrientation orientation = kPMPortrait;
+ PMGetOrientation(page_format, &orientation);
+ print_settings->set_landscape(orientation == kPMLandscape);
+ print_settings->selection_only = print_selection_only;
+
+ UInt32 resolution_count = 0;
+ PMResolution best_resolution = { 72.0, 72.0 };
+ OSStatus status = PMPrinterGetPrinterResolutionCount(printer,
+ &resolution_count);
+ if (status == noErr) {
+ // Resolution indexes are 1-based.
+ for (uint32 i = 1; i <= resolution_count; ++i) {
+ PMResolution resolution;
+ PMPrinterGetIndexedPrinterResolution(printer, i, &resolution);
+ if (resolution.hRes > best_resolution.hRes)
+ best_resolution = resolution;
+ }
+ }
+ int dpi = best_resolution.hRes;
+ print_settings->set_dpi(dpi);
+
+ DCHECK_EQ(dpi, best_resolution.vRes);
+
+ // Get printable area and paper rects (in points)
+ PMRect page_rect, paper_rect;
+ PMGetAdjustedPageRect(page_format, &page_rect);
+ PMGetAdjustedPaperRect(page_format, &paper_rect);
+
+ // Device units are in points. Units per inch is 72.
+ gfx::Size physical_size_device_units(
+ (paper_rect.right - paper_rect.left),
+ (paper_rect.bottom - paper_rect.top));
+ gfx::Rect printable_area_device_units(
+ (page_rect.left - paper_rect.left),
+ (page_rect.top - paper_rect.top),
+ (page_rect.right - page_rect.left),
+ (page_rect.bottom - page_rect.top));
+
+ print_settings->SetPrinterPrintableArea(physical_size_device_units,
+ printable_area_device_units,
+ 72);
+}
+
+} // namespace printing
diff --git a/printing/print_settings_initializer_mac.h b/printing/print_settings_initializer_mac.h
new file mode 100644
index 0000000..75307e1
--- /dev/null
+++ b/printing/print_settings_initializer_mac.h
@@ -0,0 +1,32 @@
+// Copyright (c) 2010 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.
+
+#ifndef PRINTING_PRINTING_SETTINGS_INITIALIZER_MAC_H_
+#define PRINTING_PRINTING_SETTINGS_INITIALIZER_MAC_H_
+
+#import <ApplicationServices/ApplicationServices.h>
+
+#include "base/logging.h"
+#include "printing/page_range.h"
+
+namespace printing {
+
+class PrintSettings;
+
+// Initializes a PrintSettings object from the provided device context.
+class PrintSettingsInitializerMac {
+ public:
+ static void InitPrintSettings(PMPrinter printer,
+ PMPageFormat page_format,
+ const PageRanges& new_ranges,
+ bool print_selection_only,
+ PrintSettings* print_settings);
+
+ private:
+ DISALLOW_IMPLICIT_CONSTRUCTORS(PrintSettingsInitializerMac);
+};
+
+} // namespace printing
+
+#endif // PRINTING_PRINTING_SETTINGS_INITIALIZER_MAC_H_
diff --git a/printing/print_settings_initializer_win.cc b/printing/print_settings_initializer_win.cc
new file mode 100644
index 0000000..f840f4d
--- /dev/null
+++ b/printing/print_settings_initializer_win.cc
@@ -0,0 +1,54 @@
+// Copyright (c) 2010 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_win.h"
+
+#include <windows.h>
+
+#include "printing/print_settings.h"
+
+namespace printing {
+
+// static
+void PrintSettingsInitializerWin::InitPrintSettings(
+ HDC hdc,
+ const DEVMODE& dev_mode,
+ const PageRanges& new_ranges,
+ const std::wstring& new_device_name,
+ bool print_selection_only,
+ PrintSettings* print_settings) {
+ DCHECK(hdc);
+ DCHECK(print_settings);
+
+ print_settings->set_printer_name(dev_mode.dmDeviceName);
+ print_settings->set_device_name(new_device_name);
+ print_settings->ranges = new_ranges;
+ print_settings->set_landscape(dev_mode.dmOrientation == DMORIENT_LANDSCAPE);
+ print_settings->selection_only = print_selection_only;
+
+ int dpi = GetDeviceCaps(hdc, LOGPIXELSX);
+ print_settings->set_dpi(dpi);
+ // No printer device is known to advertise different dpi in X and Y axis; even
+ // the fax device using the 200x100 dpi setting. It's ought to break so many
+ // applications that it's not even needed to care about. WebKit doesn't
+ // support different dpi settings in X and Y axis.
+ DCHECK_EQ(dpi, GetDeviceCaps(hdc, LOGPIXELSY));
+
+ DCHECK_EQ(GetDeviceCaps(hdc, SCALINGFACTORX), 0);
+ DCHECK_EQ(GetDeviceCaps(hdc, SCALINGFACTORY), 0);
+
+ // Initialize page_setup_device_units_.
+ gfx::Size physical_size_device_units(GetDeviceCaps(hdc, PHYSICALWIDTH),
+ GetDeviceCaps(hdc, PHYSICALHEIGHT));
+ gfx::Rect printable_area_device_units(GetDeviceCaps(hdc, PHYSICALOFFSETX),
+ GetDeviceCaps(hdc, PHYSICALOFFSETY),
+ GetDeviceCaps(hdc, HORZRES),
+ GetDeviceCaps(hdc, VERTRES));
+
+ print_settings->SetPrinterPrintableArea(physical_size_device_units,
+ printable_area_device_units,
+ dpi);
+}
+
+} // namespace printing
diff --git a/printing/print_settings_initializer_win.h b/printing/print_settings_initializer_win.h
new file mode 100644
index 0000000..9ed68e9
--- /dev/null
+++ b/printing/print_settings_initializer_win.h
@@ -0,0 +1,36 @@
+// Copyright (c) 2010 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.
+
+#ifndef PRINTING_PRINTING_SETTINGS_INITIALIZER_WIN_H_
+#define PRINTING_PRINTING_SETTINGS_INITIALIZER_WIN_H_
+
+#include <string>
+
+#include "base/logging.h"
+#include "printing/page_range.h"
+
+typedef struct HDC__* HDC;
+typedef struct _devicemodeW DEVMODE;
+
+namespace printing {
+
+class PrintSettings;
+
+// Initializes a PrintSettings object from the provided device context.
+class PrintSettingsInitializerWin {
+ public:
+ static void InitPrintSettings(HDC hdc,
+ const DEVMODE& dev_mode,
+ const PageRanges& new_ranges,
+ const std::wstring& new_device_name,
+ bool print_selection_only,
+ PrintSettings* print_settings);
+
+ private:
+ DISALLOW_IMPLICIT_CONSTRUCTORS(PrintSettingsInitializerWin);
+};
+
+} // namespace printing
+
+#endif // PRINTING_PRINTING_SETTINGS_INITIALIZER_WIN_H_
diff --git a/printing/printing.gyp b/printing/printing.gyp
index a9f36e5..ac87ab3 100644
--- a/printing/printing.gyp
+++ b/printing/printing.gyp
@@ -58,16 +58,22 @@
'printed_page.cc',
'printed_page.h',
'printed_pages_source.h',
- 'printing_context_cairo.cc',
- 'printing_context_cairo.h',
'printing_context.cc',
'printing_context.h',
- 'printing_context_mac.h',
+ 'printing_context_cairo.cc',
+ 'printing_context_cairo.h',
'printing_context_mac.mm',
+ 'printing_context_mac.h',
'printing_context_win.cc',
'printing_context_win.h',
'print_settings.cc',
'print_settings.h',
+ 'print_settings_initializer_gtk.cc',
+ 'print_settings_initializer_gtk.h',
+ 'print_settings_initializer_mac.cc',
+ 'print_settings_initializer_mac.h',
+ 'print_settings_initializer_win.cc',
+ 'print_settings_initializer_win.h',
'units.cc',
'units.h',
],
diff --git a/printing/printing_context.cc b/printing/printing_context.cc
index 933906d..cd888ea 100644
--- a/printing/printing_context.cc
+++ b/printing/printing_context.cc
@@ -17,7 +17,9 @@ PrintingContext::~PrintingContext() {
void PrintingContext::ResetSettings() {
ReleaseContext();
+
settings_.Clear();
+
in_print_job_ = false;
dialog_box_dismissed_ = false;
abort_printing_ = false;
diff --git a/printing/printing_context.h b/printing/printing_context.h
index 6c9daaa..4edd84e 100644
--- a/printing/printing_context.h
+++ b/printing/printing_context.h
@@ -9,7 +9,6 @@
#include "base/basictypes.h"
#include "base/callback.h"
-#include "base/scoped_ptr.h"
#include "base/string16.h"
#include "gfx/native_widget_types.h"
#include "printing/print_settings.h"
diff --git a/printing/printing_context_cairo.cc b/printing/printing_context_cairo.cc
index 0f5a500..c2097f2 100644
--- a/printing/printing_context_cairo.cc
+++ b/printing/printing_context_cairo.cc
@@ -8,6 +8,7 @@
#include <gtk/gtkprintunixdialog.h>
#include "base/logging.h"
+#include "printing/print_settings_initializer_gtk.h"
namespace printing {
@@ -44,7 +45,8 @@ PrintingContext::Result PrintingContextCairo::UseDefaultSettings() {
gtk_print_unix_dialog_get_page_setup(GTK_PRINT_UNIX_DIALOG(dialog));
PageRanges ranges_vector; // Nothing to initialize for default settings.
- settings_.Init(settings, page_setup, ranges_vector, false);
+ PrintSettingsInitializerGtk::InitPrintSettings(
+ settings, page_setup, ranges_vector, false, &settings_);
g_object_unref(settings);
// |page_setup| is owned by dialog, so it does not need to be unref'ed.
@@ -56,6 +58,7 @@ PrintingContext::Result PrintingContextCairo::UseDefaultSettings() {
PrintingContext::Result PrintingContextCairo::InitWithSettings(
const PrintSettings& settings) {
DCHECK(!in_print_job_);
+
settings_ = settings;
NOTIMPLEMENTED();
diff --git a/printing/printing_context_mac.mm b/printing/printing_context_mac.mm
index a0ca19a..63c67bd 100644
--- a/printing/printing_context_mac.mm
+++ b/printing/printing_context_mac.mm
@@ -10,6 +10,7 @@
#include "base/logging.h"
#include "base/mac/scoped_cftyperef.h"
#include "base/sys_string_conversions.h"
+#include "printing/print_settings_initializer_mac.h"
namespace printing {
@@ -97,12 +98,14 @@ void PrintingContextMac::ParsePrintInfo(NSPrintInfo* print_info) {
PMPrinter printer;
PMSessionGetCurrentPrinter(print_session, &printer);
- settings_.Init(printer, page_format, page_ranges, false);
+ PrintSettingsInitializerMac::InitPrintSettings(
+ printer, page_format, page_ranges, false, &settings_);
}
PrintingContext::Result PrintingContextMac::InitWithSettings(
const PrintSettings& settings) {
DCHECK(!in_print_job_);
+
settings_ = settings;
NOTIMPLEMENTED();
diff --git a/printing/printing_context_win.cc b/printing/printing_context_win.cc
index 9d855cd..9cd65f9 100644
--- a/printing/printing_context_win.cc
+++ b/printing/printing_context_win.cc
@@ -12,6 +12,7 @@
#include "base/message_loop.h"
#include "base/time.h"
#include "base/utf_string_conversions.h"
+#include "printing/print_settings_initializer_win.h"
#include "printing/printed_document.h"
#include "skia/ext/platform_device_win.h"
@@ -212,8 +213,10 @@ PrintingContext::Result PrintingContextWin::UseDefaultSettings() {
PrintingContext::Result PrintingContextWin::InitWithSettings(
const PrintSettings& settings) {
DCHECK(!in_print_job_);
+
settings_ = settings;
- // TODO(maruel): settings_->ToDEVMODE()
+
+ // TODO(maruel): settings_.ToDEVMODE()
HANDLE printer;
if (!OpenPrinter(const_cast<wchar_t*>(settings_.device_name().c_str()),
&printer,
@@ -393,11 +396,14 @@ bool PrintingContextWin::InitializeSettings(const DEVMODE& dev_mode,
ranges_vector.push_back(range);
}
}
- settings_.Init(context_,
- dev_mode,
- ranges_vector,
- new_device_name,
- selection_only);
+
+ PrintSettingsInitializerWin::InitPrintSettings(context_,
+ dev_mode,
+ ranges_vector,
+ new_device_name,
+ selection_only,
+ &settings_);
+
return true;
}