| OLD | NEW |
| 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 |
| (...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 218 } | 218 } |
| 219 if (change & PRINTER_CHANGE_JOB) { | 219 if (change & PRINTER_CHANGE_JOB) { |
| 220 delegate_->OnJobChanged(); | 220 delegate_->OnJobChanged(); |
| 221 } | 221 } |
| 222 } | 222 } |
| 223 watcher_.StartWatching(printer_change_, this); | 223 watcher_.StartWatching(printer_change_, this); |
| 224 } | 224 } |
| 225 | 225 |
| 226 bool GetCurrentPrinterInfo(printing::PrinterBasicInfo* printer_info) { | 226 bool GetCurrentPrinterInfo(printing::PrinterBasicInfo* printer_info) { |
| 227 DCHECK(printer_info); | 227 DCHECK(printer_info); |
| 228 if (!printer_.IsValid()) | 228 return InitBasicPrinterInfo(printer_, printer_info); |
| 229 return false; | |
| 230 | |
| 231 DWORD bytes_needed = 0; | |
| 232 bool ret = false; | |
| 233 GetPrinter(printer_, 2, NULL, 0, &bytes_needed); | |
| 234 if (0 != bytes_needed) { | |
| 235 scoped_array<BYTE> printer_info_buffer(new BYTE[bytes_needed]); | |
| 236 if (GetPrinter(printer_, 2, printer_info_buffer.get(), | |
| 237 bytes_needed, &bytes_needed)) { | |
| 238 PRINTER_INFO_2* printer_info_win = | |
| 239 reinterpret_cast<PRINTER_INFO_2*>(printer_info_buffer.get()); | |
| 240 printer_info->printer_name = WideToUTF8(printer_info_win->pPrinterName); | |
| 241 if (printer_info_win->pComment) | |
| 242 printer_info->printer_description = | |
| 243 WideToUTF8(printer_info_win->pComment); | |
| 244 if (printer_info_win->pLocation) | |
| 245 printer_info->options[kLocationTagName] = | |
| 246 WideToUTF8(printer_info_win->pLocation); | |
| 247 if (printer_info_win->pDriverName) | |
| 248 printer_info->options[kDriverNameTagName] = | |
| 249 WideToUTF8(printer_info_win->pDriverName); | |
| 250 printer_info->printer_status = printer_info_win->Status; | |
| 251 ret = true; | |
| 252 } | |
| 253 } | |
| 254 return ret; | |
| 255 } | 229 } |
| 256 | 230 |
| 257 private: | 231 private: |
| 258 base::win::ObjectWatcher watcher_; | 232 base::win::ObjectWatcher watcher_; |
| 259 printing::ScopedPrinterHandle printer_; // The printer being watched | 233 printing::ScopedPrinterHandle printer_; // The printer being watched |
| 260 // Returned by FindFirstPrinterChangeNotifier. | 234 // Returned by FindFirstPrinterChangeNotifier. |
| 261 ScopedPrinterChangeHandle printer_change_; | 235 ScopedPrinterChangeHandle printer_change_; |
| 262 Delegate* delegate_; // Delegate to notify | 236 Delegate* delegate_; // Delegate to notify |
| 263 bool did_signal_; // DoneWaiting was called | 237 bool did_signal_; // DoneWaiting was called |
| 264 std::string printer_info_; // For crash reporting. | 238 std::string printer_info_; // For crash reporting. |
| (...skipping 650 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 915 RpcStringFree(reinterpret_cast<RPC_WSTR *>(&proxy_id_as_string)); | 889 RpcStringFree(reinterpret_cast<RPC_WSTR *>(&proxy_id_as_string)); |
| 916 return ret; | 890 return ret; |
| 917 } | 891 } |
| 918 | 892 |
| 919 scoped_refptr<PrintSystem> PrintSystem::CreateInstance( | 893 scoped_refptr<PrintSystem> PrintSystem::CreateInstance( |
| 920 const base::DictionaryValue* print_system_settings) { | 894 const base::DictionaryValue* print_system_settings) { |
| 921 return new PrintSystemWin; | 895 return new PrintSystemWin; |
| 922 } | 896 } |
| 923 | 897 |
| 924 } // namespace cloud_print | 898 } // namespace cloud_print |
| OLD | NEW |