diff options
author | jhawkins@chromium.org <jhawkins@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-10-06 22:21:17 +0000 |
---|---|---|
committer | jhawkins@chromium.org <jhawkins@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-10-06 22:21:17 +0000 |
commit | 51e8d9357bb1738b462baa48da9f86e016f936ce (patch) | |
tree | 463241b65d5c3993992f62e313d49aebce220bfc /printing/printing_context_mac.mm | |
parent | c27a5ed3f25971f028dd1baedd73efb59497ceeb (diff) | |
download | chromium_src-51e8d9357bb1738b462baa48da9f86e016f936ce.zip chromium_src-51e8d9357bb1738b462baa48da9f86e016f936ce.tar.gz chromium_src-51e8d9357bb1738b462baa48da9f86e016f936ce.tar.bz2 |
Printing: Convert PrintingContext into an interface implemented by the separate
platforms.
BUG=none
TEST=none
Review URL: http://codereview.chromium.org/3610013
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@61714 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'printing/printing_context_mac.mm')
-rw-r--r-- | printing/printing_context_mac.mm | 70 |
1 files changed, 35 insertions, 35 deletions
diff --git a/printing/printing_context_mac.mm b/printing/printing_context_mac.mm index 828a7f4..50431ae6 100644 --- a/printing/printing_context_mac.mm +++ b/printing/printing_context_mac.mm @@ -2,33 +2,36 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "printing/printing_context.h" +#include "printing/printing_context_mac.h" #import <ApplicationServices/ApplicationServices.h> #import <AppKit/AppKit.h> #include "base/logging.h" +#include "base/scoped_cftyperef.h" #include "base/sys_string_conversions.h" namespace printing { -PrintingContext::PrintingContext() - : context_(NULL), - print_info_(nil), - dialog_box_dismissed_(false), - in_print_job_(false), - abort_printing_(false) { +// static +PrintingContext* PrintingContext::Create() { + return static_cast<PrintingContext*>(new PrintingContextMac); } -PrintingContext::~PrintingContext() { - ResetSettings(); +PrintingContextMac::PrintingContextMac() + : PrintingContext(), + print_info_(NULL), + context_(NULL) { } +PrintingContextMac::~PrintingContextMac() { + ReleaseContext(); +} -void PrintingContext::AskUserForSettings(gfx::NativeView parent_view, - int max_pages, - bool has_selection, - PrintSettingsCallback* callback) { +void PrintingContextMac::AskUserForSettings(gfx::NativeView parent_view, + int max_pages, + bool has_selection, + PrintSettingsCallback* callback) { DCHECK([NSThread isMainThread]); // We deliberately don't feed max_pages into the dialog, because setting @@ -68,7 +71,7 @@ void PrintingContext::AskUserForSettings(gfx::NativeView parent_view, } } -PrintingContext::Result PrintingContext::UseDefaultSettings() { +PrintingContext::Result PrintingContextMac::UseDefaultSettings() { DCHECK(!in_print_job_); ParsePrintInfo([NSPrintInfo sharedPrintInfo]); @@ -76,7 +79,7 @@ PrintingContext::Result PrintingContext::UseDefaultSettings() { return OK; } -void PrintingContext::ParsePrintInfo(NSPrintInfo* print_info) { +void PrintingContextMac::ParsePrintInfo(NSPrintInfo* print_info) { ResetSettings(); print_info_ = [print_info retain]; PageRanges page_ranges; @@ -97,7 +100,7 @@ void PrintingContext::ParsePrintInfo(NSPrintInfo* print_info) { settings_.Init(printer, page_format, page_ranges, false); } -PrintingContext::Result PrintingContext::InitWithSettings( +PrintingContext::Result PrintingContextMac::InitWithSettings( const PrintSettings& settings) { DCHECK(!in_print_job_); settings_ = settings; @@ -107,17 +110,7 @@ PrintingContext::Result PrintingContext::InitWithSettings( return FAILED; } -void PrintingContext::ResetSettings() { - [print_info_ autorelease]; - print_info_ = nil; - settings_.Clear(); - dialog_box_dismissed_ = false; - abort_printing_ = false; - in_print_job_ = false; - context_ = NULL; -} - -PrintingContext::Result PrintingContext::NewDocument( +PrintingContext::Result PrintingContextMac::NewDocument( const string16& document_name) { DCHECK(!in_print_job_); @@ -143,7 +136,7 @@ PrintingContext::Result PrintingContext::NewDocument( return OK; } -PrintingContext::Result PrintingContext::NewPage() { +PrintingContext::Result PrintingContextMac::NewPage() { if (abort_printing_) return CANCEL; DCHECK(in_print_job_); @@ -164,7 +157,7 @@ PrintingContext::Result PrintingContext::NewPage() { return OK; } -PrintingContext::Result PrintingContext::PageDone() { +PrintingContext::Result PrintingContextMac::PageDone() { if (abort_printing_) return CANCEL; DCHECK(in_print_job_); @@ -180,7 +173,7 @@ PrintingContext::Result PrintingContext::PageDone() { return OK; } -PrintingContext::Result PrintingContext::DocumentDone() { +PrintingContext::Result PrintingContextMac::DocumentDone() { if (abort_printing_) return CANCEL; DCHECK(in_print_job_); @@ -195,7 +188,7 @@ PrintingContext::Result PrintingContext::DocumentDone() { return OK; } -void PrintingContext::Cancel() { +void PrintingContextMac::Cancel() { abort_printing_ = true; in_print_job_ = false; context_ = NULL; @@ -205,13 +198,20 @@ void PrintingContext::Cancel() { PMSessionEndPageNoDialog(print_session); } -void PrintingContext::DismissDialog() { +void PrintingContextMac::DismissDialog() { NOTIMPLEMENTED(); } -PrintingContext::Result PrintingContext::OnError() { - ResetSettings(); - return abort_printing_ ? CANCEL : FAILED; +void PrintingContextMac::ReleaseContext() { + if (print_info_) { + [print_info_ autorelease]; + print_info_ = nil; + context_ = NULL; + } +} + +gfx::NativeDrawingContext PrintingContextMac::context() const { + return context_; } } // namespace printing |