diff options
author | abodenha@google.com <abodenha@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-04-22 15:41:47 +0000 |
---|---|---|
committer | abodenha@google.com <abodenha@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-04-22 15:41:47 +0000 |
commit | 6ddda2321e36dbe985aa67a6711c4ec3ce5b2285 (patch) | |
tree | 733e9b136c96b9cf44b046b159d6f6bd631912e8 /cloud_print | |
parent | 83216fffcbb29966a3a003404519cafdc999c163 (diff) | |
download | chromium_src-6ddda2321e36dbe985aa67a6711c4ec3ce5b2285.zip chromium_src-6ddda2321e36dbe985aa67a6711c4ec3ce5b2285.tar.gz chromium_src-6ddda2321e36dbe985aa67a6711c4ec3ce5b2285.tar.bz2 |
Fix deletion of temp files from port monitor.
Adds a new switch to Chrome that will delete the printed file once the print dialog finishes.
BUG=
TEST=
Review URL: http://codereview.chromium.org/6882092
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@82651 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'cloud_print')
-rw-r--r-- | cloud_print/virtual_driver/win/port_monitor/port_monitor.cc | 24 |
1 files changed, 8 insertions, 16 deletions
diff --git a/cloud_print/virtual_driver/win/port_monitor/port_monitor.cc b/cloud_print/virtual_driver/win/port_monitor/port_monitor.cc index 5141f99..450ef56 100644 --- a/cloud_print/virtual_driver/win/port_monitor/port_monitor.cc +++ b/cloud_print/virtual_driver/win/port_monitor/port_monitor.cc @@ -28,6 +28,10 @@ namespace switches { // in order to avoid dependency problems. // TODO(abodenha@chromium.org) Reunify them in some sensible manner. +// Used with kCloudPrintFile. Tells Chrome to delete the file when +// finished displaying the print dialog. +const char kCloudPrintDeleteFile[] = "cloud-print-delete-file"; + // Tells chrome to display the cloud print dialog and upload the // specified file for printing. const char kCloudPrintFile[] = "cloud-print-file"; @@ -191,11 +195,8 @@ void HandlePortUi(HWND hwnd, const string16& caption) { // Launches the Cloud Print dialog in Chrome. // xps_path references a file to print. // job_title is the title to be used for the resulting print job. -// process_handle is set to the handle of the resulting process. bool LaunchPrintDialog(const string16& xps_path, - const string16& job_title, - base::ProcessHandle* process_handle) { - DCHECK(process_handle != NULL); + const string16& job_title) { HANDLE token = NULL; if (!OpenThreadToken(GetCurrentThread(), TOKEN_QUERY|TOKEN_DUPLICATE|TOKEN_ASSIGN_PRIMARY, @@ -227,10 +228,11 @@ bool LaunchPrintDialog(const string16& xps_path, kXpsMimeType); command_line.AppendSwitchNative(switches::kCloudPrintJobTitle, job_title); + command_line.AppendSwitch(switches::kCloudPrintDeleteFile); base::LaunchAppAsUser(primary_token_scoped, command_line.command_line_string(), false, - process_handle); + NULL); return true; } @@ -452,7 +454,6 @@ BOOL WINAPI Monitor2ReadPort(HANDLE, BYTE*, DWORD, DWORD* read_bytes) { BOOL WINAPI Monitor2EndDocPort(HANDLE port_handle) { LOG(INFO) << "Monitor2EndDocPort"; - HANDLE process_handle = NULL; if (!ValidateCurrentUser()) { // TODO(abodenha@chromium.org) Abort the print job. return FALSE; @@ -473,16 +474,7 @@ BOOL WINAPI Monitor2EndDocPort(HANDLE port_handle) { &job_title); } LaunchPrintDialog(port_data->file_path->value().c_str(), - job_title, - &process_handle); - - // Wait for the print dialog process to exit and then delete the file. - // TODO(abodenha@chromium.org) Consider launching a thread to handle the - // deletion. - if (process_handle != NULL) { - WaitForSingleObject(process_handle, INFINITE); - } - file_util::Delete(*(port_data->file_path), false); + job_title); } if (port_data->printer_handle != NULL) { // Tell the spooler that the job is complete. |