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 "cloud_print/virtual_driver/win/port_monitor/port_monitor.h" | 5 #include "cloud_print/virtual_driver/win/port_monitor/port_monitor.h" |
6 | 6 |
7 #include <lmcons.h> | 7 #include <lmcons.h> |
8 #include <shellapi.h> | 8 #include <shellapi.h> |
9 #include <shlobj.h> | 9 #include <shlobj.h> |
10 #include <strsafe.h> | 10 #include <strsafe.h> |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
118 return file_path.Append(kAppDataDir); | 118 return file_path.Append(kAppDataDir); |
119 } | 119 } |
120 | 120 |
121 // Delete files which where not deleted by chrome. | 121 // Delete files which where not deleted by chrome. |
122 void DeleteLeakedFiles(const base::FilePath& dir) { | 122 void DeleteLeakedFiles(const base::FilePath& dir) { |
123 base::Time delete_before = base::Time::Now() - base::TimeDelta::FromDays(1); | 123 base::Time delete_before = base::Time::Now() - base::TimeDelta::FromDays(1); |
124 base::FileEnumerator enumerator(dir, false, base::FileEnumerator::FILES); | 124 base::FileEnumerator enumerator(dir, false, base::FileEnumerator::FILES); |
125 for (base::FilePath file_path = enumerator.Next(); !file_path.empty(); | 125 for (base::FilePath file_path = enumerator.Next(); !file_path.empty(); |
126 file_path = enumerator.Next()) { | 126 file_path = enumerator.Next()) { |
127 if (enumerator.GetInfo().GetLastModifiedTime() < delete_before) | 127 if (enumerator.GetInfo().GetLastModifiedTime() < delete_before) |
128 file_util::Delete(file_path, false); | 128 base::Delete(file_path, false); |
129 } | 129 } |
130 } | 130 } |
131 | 131 |
132 // Attempts to retrieve the title of the specified print job. | 132 // Attempts to retrieve the title of the specified print job. |
133 // On success returns TRUE and the first title_chars characters of the job title | 133 // On success returns TRUE and the first title_chars characters of the job title |
134 // are copied into title. | 134 // are copied into title. |
135 // On failure returns FALSE and title is unmodified. | 135 // On failure returns FALSE and title is unmodified. |
136 bool GetJobTitle(HANDLE printer_handle, | 136 bool GetJobTitle(HANDLE printer_handle, |
137 DWORD job_id, | 137 DWORD job_id, |
138 string16 *title) { | 138 string16 *title) { |
(...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
496 port_data->job_id, | 496 port_data->job_id, |
497 &job_title); | 497 &job_title); |
498 } | 498 } |
499 if (!LaunchPrintDialog(port_data->file_path, job_title)) { | 499 if (!LaunchPrintDialog(port_data->file_path, job_title)) { |
500 LaunchChromeDownloadPage(); | 500 LaunchChromeDownloadPage(); |
501 } else { | 501 } else { |
502 delete_file = false; | 502 delete_file = false; |
503 } | 503 } |
504 } | 504 } |
505 if (delete_file) | 505 if (delete_file) |
506 file_util::Delete(port_data->file_path, false); | 506 base::Delete(port_data->file_path, false); |
507 } | 507 } |
508 if (port_data->printer_handle != NULL) { | 508 if (port_data->printer_handle != NULL) { |
509 // Tell the spooler that the job is complete. | 509 // Tell the spooler that the job is complete. |
510 SetJob(port_data->printer_handle, | 510 SetJob(port_data->printer_handle, |
511 port_data->job_id, | 511 port_data->job_id, |
512 0, | 512 0, |
513 NULL, | 513 NULL, |
514 JOB_CONTROL_SENT_TO_PRINTER); | 514 JOB_CONTROL_SENT_TO_PRINTER); |
515 } | 515 } |
516 port_data->Close(); | 516 port_data->Close(); |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
637 SetLastError(ERROR_INVALID_PARAMETER); | 637 SetLastError(ERROR_INVALID_PARAMETER); |
638 return NULL; | 638 return NULL; |
639 } | 639 } |
640 return &cloud_print::g_monitor_2; | 640 return &cloud_print::g_monitor_2; |
641 } | 641 } |
642 | 642 |
643 MONITORUI* WINAPI InitializePrintMonitorUI(void) { | 643 MONITORUI* WINAPI InitializePrintMonitorUI(void) { |
644 return &cloud_print::g_monitor_ui; | 644 return &cloud_print::g_monitor_ui; |
645 } | 645 } |
646 | 646 |
OLD | NEW |