| 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 "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/files/file_util.h" | 8 #include "base/files/file_util.h" |
| 9 #include "base/json/json_writer.h" | 9 #include "base/json/json_writer.h" |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 61 std::wstring printer_name_wide; | 61 std::wstring printer_name_wide; |
| 62 if (!printer_name.empty()) { | 62 if (!printer_name.empty()) { |
| 63 printer_name_wide = base::UTF8ToWide(printer_name); | 63 printer_name_wide = base::UTF8ToWide(printer_name); |
| 64 printer_name_to_use = const_cast<LPTSTR>(printer_name_wide.c_str()); | 64 printer_name_to_use = const_cast<LPTSTR>(printer_name_wide.c_str()); |
| 65 } | 65 } |
| 66 bool ret = false; | 66 bool ret = false; |
| 67 if (printer_.OpenPrinter(printer_name_to_use)) { | 67 if (printer_.OpenPrinter(printer_name_to_use)) { |
| 68 printer_change_.Set(FindFirstPrinterChangeNotification( | 68 printer_change_.Set(FindFirstPrinterChangeNotification( |
| 69 printer_.Get(), PRINTER_CHANGE_PRINTER|PRINTER_CHANGE_JOB, 0, NULL)); | 69 printer_.Get(), PRINTER_CHANGE_PRINTER|PRINTER_CHANGE_JOB, 0, NULL)); |
| 70 if (printer_change_.IsValid()) { | 70 if (printer_change_.IsValid()) { |
| 71 ret = watcher_.StartWatching(printer_change_.Get(), this); | 71 ret = watcher_.StartWatching(printer_change_.Get(), this, false); |
| 72 } | 72 } |
| 73 } | 73 } |
| 74 if (!ret) { | 74 if (!ret) { |
| 75 Stop(); | 75 Stop(); |
| 76 } | 76 } |
| 77 return ret; | 77 return ret; |
| 78 } | 78 } |
| 79 | 79 |
| 80 bool Stop() { | 80 bool Stop() { |
| 81 watcher_.StopWatching(); | 81 watcher_.StopWatching(); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 99 delegate_->OnPrinterAdded(); | 99 delegate_->OnPrinterAdded(); |
| 100 } else if (change & PRINTER_CHANGE_DELETE_PRINTER) { | 100 } else if (change & PRINTER_CHANGE_DELETE_PRINTER) { |
| 101 delegate_->OnPrinterDeleted(); | 101 delegate_->OnPrinterDeleted(); |
| 102 } else if (change & PRINTER_CHANGE_SET_PRINTER) { | 102 } else if (change & PRINTER_CHANGE_SET_PRINTER) { |
| 103 delegate_->OnPrinterChanged(); | 103 delegate_->OnPrinterChanged(); |
| 104 } | 104 } |
| 105 if (change & PRINTER_CHANGE_JOB) { | 105 if (change & PRINTER_CHANGE_JOB) { |
| 106 delegate_->OnJobChanged(); | 106 delegate_->OnJobChanged(); |
| 107 } | 107 } |
| 108 } | 108 } |
| 109 watcher_.StartWatching(printer_change_.Get(), this); | 109 watcher_.StartWatching(printer_change_.Get(), this, false); |
| 110 } | 110 } |
| 111 | 111 |
| 112 bool GetCurrentPrinterInfo(printing::PrinterBasicInfo* printer_info) { | 112 bool GetCurrentPrinterInfo(printing::PrinterBasicInfo* printer_info) { |
| 113 DCHECK(printer_info); | 113 DCHECK(printer_info); |
| 114 return InitBasicPrinterInfo(printer_.Get(), printer_info); | 114 return InitBasicPrinterInfo(printer_.Get(), printer_info); |
| 115 } | 115 } |
| 116 | 116 |
| 117 private: | 117 private: |
| 118 base::win::ObjectWatcher watcher_; | 118 base::win::ObjectWatcher watcher_; |
| 119 printing::ScopedPrinterHandle printer_; // The printer being watched | 119 printing::ScopedPrinterHandle printer_; // The printer being watched |
| (...skipping 688 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 808 } | 808 } |
| 809 | 809 |
| 810 } // namespace | 810 } // namespace |
| 811 | 811 |
| 812 scoped_refptr<PrintSystem> PrintSystem::CreateInstance( | 812 scoped_refptr<PrintSystem> PrintSystem::CreateInstance( |
| 813 const base::DictionaryValue* print_system_settings) { | 813 const base::DictionaryValue* print_system_settings) { |
| 814 return new PrintSystemWin; | 814 return new PrintSystemWin; |
| 815 } | 815 } |
| 816 | 816 |
| 817 } // namespace cloud_print | 817 } // namespace cloud_print |
| OLD | NEW |