Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(521)

Side by Side Diff: printing/printing_context_mac.mm

Issue 6533006: Print Preview: Hook up the print button to initiate printing without displaying a print dialog. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: '' Created 9 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2009 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 "printing/print_settings_initializer_mac.h" 14 #include "printing/print_settings_initializer_mac.h"
14 15
15 namespace printing { 16 namespace printing {
16 17
17 // static 18 // static
18 PrintingContext* PrintingContext::Create(const std::string& app_locale) { 19 PrintingContext* PrintingContext::Create(const std::string& app_locale) {
19 return static_cast<PrintingContext*>(new PrintingContextMac(app_locale)); 20 return static_cast<PrintingContext*>(new PrintingContextMac(app_locale));
20 } 21 }
21 22
22 PrintingContextMac::PrintingContextMac(const std::string& app_locale) 23 PrintingContextMac::PrintingContextMac(const std::string& app_locale)
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 } 74 }
74 75
75 PrintingContext::Result PrintingContextMac::UseDefaultSettings() { 76 PrintingContext::Result PrintingContextMac::UseDefaultSettings() {
76 DCHECK(!in_print_job_); 77 DCHECK(!in_print_job_);
77 78
78 ParsePrintInfo([NSPrintInfo sharedPrintInfo]); 79 ParsePrintInfo([NSPrintInfo sharedPrintInfo]);
79 80
80 return OK; 81 return OK;
81 } 82 }
82 83
84 PrintingContext::Result PrintingContextMac::UpdatePrintSettings(
85 const DictionaryValue* job_settings, const PageRanges& ranges) {
86 DCHECK(!in_print_job_);
87
88 // TODO (kmadhusu): Update other print job settings such as number of copies,
89 // collate, etc.,
90
91 // Update the print range information.
92 settings_.ranges = ranges;
93
94 return OK;
95 }
96
83 void PrintingContextMac::ParsePrintInfo(NSPrintInfo* print_info) { 97 void PrintingContextMac::ParsePrintInfo(NSPrintInfo* print_info) {
84 ResetSettings(); 98 ResetSettings();
85 print_info_ = [print_info retain]; 99 print_info_ = [print_info retain];
86 PageRanges page_ranges; 100 PageRanges page_ranges;
87 NSDictionary* print_info_dict = [print_info_ dictionary]; 101 NSDictionary* print_info_dict = [print_info_ dictionary];
88 if (![[print_info_dict objectForKey:NSPrintAllPages] boolValue]) { 102 if (![[print_info_dict objectForKey:NSPrintAllPages] boolValue]) {
89 PageRange range; 103 PageRange range;
90 range.from = [[print_info_dict objectForKey:NSPrintFirstPage] intValue] - 1; 104 range.from = [[print_info_dict objectForKey:NSPrintFirstPage] intValue] - 1;
91 range.to = [[print_info_dict objectForKey:NSPrintLastPage] intValue] - 1; 105 range.to = [[print_info_dict objectForKey:NSPrintLastPage] intValue] - 1;
92 page_ranges.push_back(range); 106 page_ranges.push_back(range);
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
207 print_info_ = nil; 221 print_info_ = nil;
208 context_ = NULL; 222 context_ = NULL;
209 } 223 }
210 } 224 }
211 225
212 gfx::NativeDrawingContext PrintingContextMac::context() const { 226 gfx::NativeDrawingContext PrintingContextMac::context() const {
213 return context_; 227 return context_;
214 } 228 }
215 229
216 } // namespace printing 230 } // namespace printing
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698