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/printing_context_mac.h" | 5 #include "printing/printing_context_mac.h" |
6 | 6 |
7 #import <ApplicationServices/ApplicationServices.h> | 7 #import <ApplicationServices/ApplicationServices.h> |
8 #import <AppKit/AppKit.h> | 8 #import <AppKit/AppKit.h> |
9 | 9 |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
11 #include "base/mac/scoped_cftyperef.h" | 11 #include "base/mac/scoped_cftyperef.h" |
12 #include "base/sys_string_conversions.h" | 12 #include "base/sys_string_conversions.h" |
13 #include "base/values.h" | 13 #include "base/values.h" |
14 #include "printing/print_job_constants.h" | |
15 #include "printing/print_settings_initializer_mac.h" | 14 #include "printing/print_settings_initializer_mac.h" |
16 | 15 |
17 namespace printing { | 16 namespace printing { |
18 | 17 |
19 // static | 18 // static |
20 PrintingContext* PrintingContext::Create(const std::string& app_locale) { | 19 PrintingContext* PrintingContext::Create(const std::string& app_locale) { |
21 return static_cast<PrintingContext*>(new PrintingContextMac(app_locale)); | 20 return static_cast<PrintingContext*>(new PrintingContextMac(app_locale)); |
22 } | 21 } |
23 | 22 |
24 PrintingContextMac::PrintingContextMac(const std::string& app_locale) | 23 PrintingContextMac::PrintingContextMac(const std::string& app_locale) |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
86 const DictionaryValue& job_settings, const PageRanges& ranges) { | 85 const DictionaryValue& job_settings, const PageRanges& ranges) { |
87 DCHECK(!in_print_job_); | 86 DCHECK(!in_print_job_); |
88 | 87 |
89 // TODO (kmadhusu): Update other print job settings such as number of copies, | 88 // TODO (kmadhusu): Update other print job settings such as number of copies, |
90 // collate, etc., | 89 // collate, etc., |
91 | 90 |
92 ResetSettings(); | 91 ResetSettings(); |
93 print_info_.reset([[NSPrintInfo sharedPrintInfo] copy]); | 92 print_info_.reset([[NSPrintInfo sharedPrintInfo] copy]); |
94 | 93 |
95 bool landscape; | 94 bool landscape; |
96 if (!job_settings.GetBoolean(kSettingLandscape, &landscape)) | 95 std::string printer_name; |
| 96 if (!GetSettingsFromDict(job_settings, &landscape, &printer_name)) |
97 return OnError(); | 97 return OnError(); |
| 98 |
98 settings_.SetOrientation(landscape); | 99 settings_.SetOrientation(landscape); |
99 | 100 |
100 std::string printer_name; | |
101 if (!job_settings.GetString(kSettingPrinterName, &printer_name)) | |
102 return OnError(); | |
103 | |
104 if (!SetPrinter(printer_name)) | 101 if (!SetPrinter(printer_name)) |
105 return OnError(); | 102 return OnError(); |
106 | 103 |
107 InitPrintSettingsFromPrintInfo(ranges); | 104 InitPrintSettingsFromPrintInfo(ranges); |
108 return OK; | 105 return OK; |
109 } | 106 } |
110 | 107 |
111 void PrintingContextMac::InitPrintSettingsFromPrintInfo( | 108 void PrintingContextMac::InitPrintSettingsFromPrintInfo( |
112 const PageRanges& ranges) { | 109 const PageRanges& ranges) { |
113 PMPrintSession print_session = | 110 PMPrintSession print_session = |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
251 void PrintingContextMac::ReleaseContext() { | 248 void PrintingContextMac::ReleaseContext() { |
252 print_info_.reset(); | 249 print_info_.reset(); |
253 context_ = NULL; | 250 context_ = NULL; |
254 } | 251 } |
255 | 252 |
256 gfx::NativeDrawingContext PrintingContextMac::context() const { | 253 gfx::NativeDrawingContext PrintingContextMac::context() const { |
257 return context_; | 254 return context_; |
258 } | 255 } |
259 | 256 |
260 } // namespace printing | 257 } // namespace printing |
OLD | NEW |