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

Side by Side Diff: printing/printing_context_mac.mm

Issue 504763002: Revert of Added PrintingContext::Delegate to get parent view handle and application locale. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 3 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
« no previous file with comments | « printing/printing_context_mac.h ('k') | printing/printing_context_no_system_dialog.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #import <iomanip> 10 #import <iomanip>
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 best_matching_paper = paper; 61 best_matching_paper = paper;
62 best_match = difference; 62 best_match = difference;
63 } 63 }
64 } 64 }
65 return best_matching_paper; 65 return best_matching_paper;
66 } 66 }
67 67
68 } // namespace 68 } // namespace
69 69
70 // static 70 // static
71 scoped_ptr<PrintingContext> PrintingContext::Create(Delegate* delegate) { 71 PrintingContext* PrintingContext::Create(const std::string& app_locale) {
72 return make_scoped_ptr<PrintingContext>(new PrintingContextMac(delegate)); 72 return static_cast<PrintingContext*>(new PrintingContextMac(app_locale));
73 } 73 }
74 74
75 PrintingContextMac::PrintingContextMac(Delegate* delegate) 75 PrintingContextMac::PrintingContextMac(const std::string& app_locale)
76 : PrintingContext(delegate), 76 : PrintingContext(app_locale),
77 print_info_([[NSPrintInfo sharedPrintInfo] copy]), 77 print_info_([[NSPrintInfo sharedPrintInfo] copy]),
78 context_(NULL) { 78 context_(NULL) {
79 } 79 }
80 80
81 PrintingContextMac::~PrintingContextMac() { 81 PrintingContextMac::~PrintingContextMac() {
82 ReleaseContext(); 82 ReleaseContext();
83 } 83 }
84 84
85 void PrintingContextMac::AskUserForSettings( 85 void PrintingContextMac::AskUserForSettings(
86 gfx::NativeView parent_view,
86 int max_pages, 87 int max_pages,
87 bool has_selection, 88 bool has_selection,
88 const PrintSettingsCallback& callback) { 89 const PrintSettingsCallback& callback) {
89 // Third-party print drivers seem to be an area prone to raising exceptions. 90 // Third-party print drivers seem to be an area prone to raising exceptions.
90 // This will allow exceptions to be raised, but does not handle them. The 91 // This will allow exceptions to be raised, but does not handle them. The
91 // NSPrintPanel appears to have appropriate NSException handlers. 92 // NSPrintPanel appears to have appropriate NSException handlers.
92 base::mac::ScopedNSExceptionEnabler enabler; 93 base::mac::ScopedNSExceptionEnabler enabler;
93 94
94 // Exceptions can also happen when the NSPrintPanel is being 95 // Exceptions can also happen when the NSPrintPanel is being
95 // deallocated, so it must be autoreleased within this scope. 96 // deallocated, so it must be autoreleased within this scope.
(...skipping 11 matching lines...) Expand all
107 NSPrintPanel* panel = [NSPrintPanel printPanel]; 108 NSPrintPanel* panel = [NSPrintPanel printPanel];
108 NSPrintInfo* printInfo = print_info_.get(); 109 NSPrintInfo* printInfo = print_info_.get();
109 110
110 NSPrintPanelOptions options = [panel options]; 111 NSPrintPanelOptions options = [panel options];
111 options |= NSPrintPanelShowsPaperSize; 112 options |= NSPrintPanelShowsPaperSize;
112 options |= NSPrintPanelShowsOrientation; 113 options |= NSPrintPanelShowsOrientation;
113 options |= NSPrintPanelShowsScaling; 114 options |= NSPrintPanelShowsScaling;
114 [panel setOptions:options]; 115 [panel setOptions:options];
115 116
116 // Set the print job title text. 117 // Set the print job title text.
117 gfx::NativeView parent_view = delegate_->GetParentView();
118 if (parent_view) { 118 if (parent_view) {
119 NSString* job_title = [[parent_view window] title]; 119 NSString* job_title = [[parent_view window] title];
120 if (job_title) { 120 if (job_title) {
121 PMPrintSettings printSettings = 121 PMPrintSettings printSettings =
122 (PMPrintSettings)[printInfo PMPrintSettings]; 122 (PMPrintSettings)[printInfo PMPrintSettings];
123 PMPrintSettingsSetJobName(printSettings, (CFStringRef)job_title); 123 PMPrintSettingsSetJobName(printSettings, (CFStringRef)job_title);
124 [printInfo updateFromPMPrintSettings]; 124 [printInfo updateFromPMPrintSettings];
125 } 125 }
126 } 126 }
127 127
(...skipping 388 matching lines...) Expand 10 before | Expand all | Expand 10 after
516 void PrintingContextMac::ReleaseContext() { 516 void PrintingContextMac::ReleaseContext() {
517 print_info_.reset(); 517 print_info_.reset();
518 context_ = NULL; 518 context_ = NULL;
519 } 519 }
520 520
521 gfx::NativeDrawingContext PrintingContextMac::context() const { 521 gfx::NativeDrawingContext PrintingContextMac::context() const {
522 return context_; 522 return context_;
523 } 523 }
524 524
525 } // namespace printing 525 } // namespace printing
OLDNEW
« no previous file with comments | « printing/printing_context_mac.h ('k') | printing/printing_context_no_system_dialog.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698