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

Side by Side Diff: trunk/src/chrome/service/cloud_print/print_system_win.cc

Issue 23503070: Revert 223610 "Set the printer info in crash reports using the c..." (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: Created 7 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "chrome/service/cloud_print/print_system.h" 5 #include "chrome/service/cloud_print/print_system.h"
6 6
7 #include <objidl.h> 7 #include <objidl.h>
8 #include <winspool.h> 8 #include <winspool.h>
9 #include <xpsprint.h> 9 #include <xpsprint.h>
10 10
11 #include "base/bind.h" 11 #include "base/bind.h"
12 #include "base/file_util.h" 12 #include "base/file_util.h"
13 #include "base/files/file_path.h" 13 #include "base/files/file_path.h"
14 #include "base/memory/scoped_ptr.h" 14 #include "base/memory/scoped_ptr.h"
15 #include "base/strings/utf_string_conversions.h" 15 #include "base/strings/utf_string_conversions.h"
16 #include "base/win/object_watcher.h" 16 #include "base/win/object_watcher.h"
17 #include "base/win/scoped_bstr.h" 17 #include "base/win/scoped_bstr.h"
18 #include "base/win/scoped_com_initializer.h" 18 #include "base/win/scoped_com_initializer.h"
19 #include "base/win/scoped_comptr.h" 19 #include "base/win/scoped_comptr.h"
20 #include "base/win/scoped_hdc.h" 20 #include "base/win/scoped_hdc.h"
21 #include "chrome/common/crash_keys.h" 21 #include "chrome/common/child_process_logging.h"
22 #include "chrome/service/service_process.h" 22 #include "chrome/service/service_process.h"
23 #include "chrome/service/service_utility_process_host.h" 23 #include "chrome/service/service_utility_process_host.h"
24 #include "grit/generated_resources.h" 24 #include "grit/generated_resources.h"
25 #include "printing/backend/print_backend.h" 25 #include "printing/backend/print_backend.h"
26 #include "printing/backend/print_backend_consts.h" 26 #include "printing/backend/print_backend_consts.h"
27 #include "printing/backend/win_helper.h" 27 #include "printing/backend/win_helper.h"
28 #include "printing/emf_win.h" 28 #include "printing/emf_win.h"
29 #include "printing/page_range.h" 29 #include "printing/page_range.h"
30 #include "printing/pdf_render_settings.h" 30 #include "printing/pdf_render_settings.h"
31 #include "ui/base/l10n/l10n_util.h" 31 #include "ui/base/l10n/l10n_util.h"
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 virtual void OnPrinterAdded() = 0; 163 virtual void OnPrinterAdded() = 0;
164 virtual void OnPrinterDeleted() = 0; 164 virtual void OnPrinterDeleted() = 0;
165 virtual void OnPrinterChanged() = 0; 165 virtual void OnPrinterChanged() = 0;
166 virtual void OnJobChanged() = 0; 166 virtual void OnJobChanged() = 0;
167 }; 167 };
168 168
169 bool Start(const std::string& printer_name, Delegate* delegate) { 169 bool Start(const std::string& printer_name, Delegate* delegate) {
170 scoped_refptr<printing::PrintBackend> print_backend( 170 scoped_refptr<printing::PrintBackend> print_backend(
171 printing::PrintBackend::CreateInstance(NULL)); 171 printing::PrintBackend::CreateInstance(NULL));
172 printer_info_ = print_backend->GetPrinterDriverInfo(printer_name); 172 printer_info_ = print_backend->GetPrinterDriverInfo(printer_name);
173 crash_keys::ScopedPrinterInfo crash_key(printer_info_); 173 child_process_logging::ScopedPrinterInfoSetter prn_info(printer_info_);
174 174
175 delegate_ = delegate; 175 delegate_ = delegate;
176 // An empty printer name means watch the current server, we need to pass 176 // An empty printer name means watch the current server, we need to pass
177 // NULL to OpenPrinter. 177 // NULL to OpenPrinter.
178 LPTSTR printer_name_to_use = NULL; 178 LPTSTR printer_name_to_use = NULL;
179 std::wstring printer_name_wide; 179 std::wstring printer_name_wide;
180 if (!printer_name.empty()) { 180 if (!printer_name.empty()) {
181 printer_name_wide = UTF8ToWide(printer_name); 181 printer_name_wide = UTF8ToWide(printer_name);
182 printer_name_to_use = const_cast<LPTSTR>(printer_name_wide.c_str()); 182 printer_name_to_use = const_cast<LPTSTR>(printer_name_wide.c_str());
183 } 183 }
(...skipping 12 matching lines...) Expand all
196 } 196 }
197 bool Stop() { 197 bool Stop() {
198 watcher_.StopWatching(); 198 watcher_.StopWatching();
199 printer_.Close(); 199 printer_.Close();
200 printer_change_.Close(); 200 printer_change_.Close();
201 return true; 201 return true;
202 } 202 }
203 203
204 // base::ObjectWatcher::Delegate method 204 // base::ObjectWatcher::Delegate method
205 virtual void OnObjectSignaled(HANDLE object) { 205 virtual void OnObjectSignaled(HANDLE object) {
206 crash_keys::ScopedPrinterInfo crash_key(printer_info_); 206 child_process_logging::ScopedPrinterInfoSetter prn_info(printer_info_);
207 DWORD change = 0; 207 DWORD change = 0;
208 FindNextPrinterChangeNotification(object, &change, NULL, NULL); 208 FindNextPrinterChangeNotification(object, &change, NULL, NULL);
209 209
210 if (change != ((PRINTER_CHANGE_PRINTER|PRINTER_CHANGE_JOB) & 210 if (change != ((PRINTER_CHANGE_PRINTER|PRINTER_CHANGE_JOB) &
211 (~PRINTER_CHANGE_FAILED_CONNECTION_PRINTER))) { 211 (~PRINTER_CHANGE_FAILED_CONNECTION_PRINTER))) {
212 // For printer connections, we get spurious change notifications with 212 // For printer connections, we get spurious change notifications with
213 // all flags set except PRINTER_CHANGE_FAILED_CONNECTION_PRINTER. 213 // all flags set except PRINTER_CHANGE_FAILED_CONNECTION_PRINTER.
214 // Ignore these. 214 // Ignore these.
215 if (change & PRINTER_CHANGE_ADD_PRINTER) { 215 if (change & PRINTER_CHANGE_ADD_PRINTER) {
216 delegate_->OnPrinterAdded(); 216 delegate_->OnPrinterAdded();
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
363 virtual bool Spool(const std::string& print_ticket, 363 virtual bool Spool(const std::string& print_ticket,
364 const base::FilePath& print_data_file_path, 364 const base::FilePath& print_data_file_path,
365 const std::string& print_data_mime_type, 365 const std::string& print_data_mime_type,
366 const std::string& printer_name, 366 const std::string& printer_name,
367 const std::string& job_title, 367 const std::string& job_title,
368 const std::vector<std::string>& tags, 368 const std::vector<std::string>& tags,
369 JobSpooler::Delegate* delegate) OVERRIDE { 369 JobSpooler::Delegate* delegate) OVERRIDE {
370 // TODO(gene): add tags handling. 370 // TODO(gene): add tags handling.
371 scoped_refptr<printing::PrintBackend> print_backend( 371 scoped_refptr<printing::PrintBackend> print_backend(
372 printing::PrintBackend::CreateInstance(NULL)); 372 printing::PrintBackend::CreateInstance(NULL));
373 crash_keys::ScopedPrinterInfo crash_key( 373 child_process_logging::ScopedPrinterInfoSetter prn_info(
374 print_backend->GetPrinterDriverInfo(printer_name)); 374 print_backend->GetPrinterDriverInfo(printer_name));
375 return core_->Spool(print_ticket, print_data_file_path, 375 return core_->Spool(print_ticket, print_data_file_path,
376 print_data_mime_type, printer_name, job_title, 376 print_data_mime_type, printer_name, job_title,
377 delegate); 377 delegate);
378 } 378 }
379 379
380 protected: 380 protected:
381 virtual ~JobSpoolerWin() {} 381 virtual ~JobSpoolerWin() {}
382 382
383 private: 383 private:
(...skipping 12 matching lines...) Expand all
396 ~Core() {} 396 ~Core() {}
397 397
398 bool Spool(const std::string& print_ticket, 398 bool Spool(const std::string& print_ticket,
399 const base::FilePath& print_data_file_path, 399 const base::FilePath& print_data_file_path,
400 const std::string& print_data_mime_type, 400 const std::string& print_data_mime_type,
401 const std::string& printer_name, 401 const std::string& printer_name,
402 const std::string& job_title, 402 const std::string& job_title,
403 JobSpooler::Delegate* delegate) { 403 JobSpooler::Delegate* delegate) {
404 scoped_refptr<printing::PrintBackend> print_backend( 404 scoped_refptr<printing::PrintBackend> print_backend(
405 printing::PrintBackend::CreateInstance(NULL)); 405 printing::PrintBackend::CreateInstance(NULL));
406 crash_keys::ScopedPrinterInfo crash_key( 406 child_process_logging::ScopedPrinterInfoSetter prn_info(
407 print_backend->GetPrinterDriverInfo(printer_name)); 407 print_backend->GetPrinterDriverInfo(printer_name));
408 if (delegate_) { 408 if (delegate_) {
409 // We are already in the process of printing. 409 // We are already in the process of printing.
410 NOTREACHED(); 410 NOTREACHED();
411 return false; 411 return false;
412 } 412 }
413 last_page_printed_ = -1; 413 last_page_printed_ = -1;
414 // We only support PDF and XPS documents for now. 414 // We only support PDF and XPS documents for now.
415 if (print_data_mime_type == "application/pdf") { 415 if (print_data_mime_type == "application/pdf") {
416 DevMode pt_dev_mode; 416 DevMode pt_dev_mode;
(...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after
785 handler->Start(); 785 handler->Start();
786 } 786 }
787 787
788 bool PrintSystemWin::IsValidPrinter(const std::string& printer_name) { 788 bool PrintSystemWin::IsValidPrinter(const std::string& printer_name) {
789 return print_backend_->IsValidPrinter(printer_name); 789 return print_backend_->IsValidPrinter(printer_name);
790 } 790 }
791 791
792 bool PrintSystemWin::ValidatePrintTicket( 792 bool PrintSystemWin::ValidatePrintTicket(
793 const std::string& printer_name, 793 const std::string& printer_name,
794 const std::string& print_ticket_data) { 794 const std::string& print_ticket_data) {
795 crash_keys::ScopedPrinterInfo crash_key( 795 child_process_logging::ScopedPrinterInfoSetter prn_info(
796 print_backend_->GetPrinterDriverInfo(printer_name)); 796 print_backend_->GetPrinterDriverInfo(printer_name));
797 printing::ScopedXPSInitializer xps_initializer; 797 printing::ScopedXPSInitializer xps_initializer;
798 if (!xps_initializer.initialized()) { 798 if (!xps_initializer.initialized()) {
799 // TODO(sanjeevr): Handle legacy proxy case (with no prntvpt.dll) 799 // TODO(sanjeevr): Handle legacy proxy case (with no prntvpt.dll)
800 return false; 800 return false;
801 } 801 }
802 bool ret = false; 802 bool ret = false;
803 HPTPROVIDER provider = NULL; 803 HPTPROVIDER provider = NULL;
804 printing::XPSModule::OpenProvider(UTF8ToWide(printer_name.c_str()), 804 printing::XPSModule::OpenProvider(UTF8ToWide(printer_name.c_str()),
805 1, 805 1,
(...skipping 20 matching lines...) Expand all
826 result_ticket_stream.get(), 826 result_ticket_stream.get(),
827 error.Receive())); 827 error.Receive()));
828 printing::XPSModule::CloseProvider(provider); 828 printing::XPSModule::CloseProvider(provider);
829 } 829 }
830 return ret; 830 return ret;
831 } 831 }
832 832
833 bool PrintSystemWin::GetJobDetails(const std::string& printer_name, 833 bool PrintSystemWin::GetJobDetails(const std::string& printer_name,
834 PlatformJobId job_id, 834 PlatformJobId job_id,
835 PrintJobDetails *job_details) { 835 PrintJobDetails *job_details) {
836 crash_keys::ScopedPrinterInfo crash_key( 836 child_process_logging::ScopedPrinterInfoSetter prn_info(
837 print_backend_->GetPrinterDriverInfo(printer_name)); 837 print_backend_->GetPrinterDriverInfo(printer_name));
838 DCHECK(job_details); 838 DCHECK(job_details);
839 printing::ScopedPrinterHandle printer_handle; 839 printing::ScopedPrinterHandle printer_handle;
840 std::wstring printer_name_wide = UTF8ToWide(printer_name); 840 std::wstring printer_name_wide = UTF8ToWide(printer_name);
841 printer_handle.OpenPrinter(printer_name_wide.c_str()); 841 printer_handle.OpenPrinter(printer_name_wide.c_str());
842 DCHECK(printer_handle.IsValid()); 842 DCHECK(printer_handle.IsValid());
843 bool ret = false; 843 bool ret = false;
844 if (printer_handle.IsValid()) { 844 if (printer_handle.IsValid()) {
845 DWORD bytes_needed = 0; 845 DWORD bytes_needed = 0;
846 GetJob(printer_handle, job_id, 1, NULL, 0, &bytes_needed); 846 GetJob(printer_handle, job_id, 1, NULL, 0, &bytes_needed);
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
897 return "application/pdf"; 897 return "application/pdf";
898 } 898 }
899 899
900 900
901 scoped_refptr<PrintSystem> PrintSystem::CreateInstance( 901 scoped_refptr<PrintSystem> PrintSystem::CreateInstance(
902 const base::DictionaryValue* print_system_settings) { 902 const base::DictionaryValue* print_system_settings) {
903 return new PrintSystemWin; 903 return new PrintSystemWin;
904 } 904 }
905 905
906 } // namespace cloud_print 906 } // namespace cloud_print
OLDNEW
« no previous file with comments | « trunk/src/chrome/service/cloud_print/print_system_cups.cc ('k') | trunk/src/chrome/utility/chrome_content_utility_client.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698