OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/browser/printing/print_dialog_cloud.h" | 5 #include "chrome/browser/printing/print_dialog_cloud.h" |
6 #include "chrome/browser/printing/print_dialog_cloud_internal.h" | 6 #include "chrome/browser/printing/print_dialog_cloud_internal.h" |
7 | 7 |
8 #include "app/l10n_util.h" | 8 #include "app/l10n_util.h" |
9 #include "base/base64.h" | 9 #include "base/base64.h" |
10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
141 | 141 |
142 void CloudPrintDataSenderHelper::CallJavascriptFunction( | 142 void CloudPrintDataSenderHelper::CallJavascriptFunction( |
143 const std::wstring& function_name, const Value& arg1, const Value& arg2) { | 143 const std::wstring& function_name, const Value& arg1, const Value& arg2) { |
144 dom_ui_->CallJavascriptFunction(function_name, arg1, arg2); | 144 dom_ui_->CallJavascriptFunction(function_name, arg1, arg2); |
145 } | 145 } |
146 | 146 |
147 // Clears out the pointer we're using to communicate. Either routine is | 147 // Clears out the pointer we're using to communicate. Either routine is |
148 // potentially expensive enough that stopping whatever is in progress | 148 // potentially expensive enough that stopping whatever is in progress |
149 // is worth it. | 149 // is worth it. |
150 void CloudPrintDataSender::CancelPrintDataFile() { | 150 void CloudPrintDataSender::CancelPrintDataFile() { |
151 AutoLock lock(lock_); | 151 base::AutoLock lock(lock_); |
152 // We don't own helper, it was passed in to us, so no need to | 152 // We don't own helper, it was passed in to us, so no need to |
153 // delete, just let it go. | 153 // delete, just let it go. |
154 helper_ = NULL; | 154 helper_ = NULL; |
155 } | 155 } |
156 | 156 |
157 CloudPrintDataSender::CloudPrintDataSender(CloudPrintDataSenderHelper* helper, | 157 CloudPrintDataSender::CloudPrintDataSender(CloudPrintDataSenderHelper* helper, |
158 const string16& print_job_title) | 158 const string16& print_job_title) |
159 : helper_(helper), | 159 : helper_(helper), |
160 print_job_title_(print_job_title) { | 160 print_job_title_(print_job_title) { |
161 } | 161 } |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
195 // We have the data in hand that needs to be pushed into the dialog | 195 // We have the data in hand that needs to be pushed into the dialog |
196 // contents; do so from the IO thread. | 196 // contents; do so from the IO thread. |
197 | 197 |
198 // TODO(scottbyer): If the print data ends up being larger than the | 198 // TODO(scottbyer): If the print data ends up being larger than the |
199 // upload limit (currently 10MB), what we need to do is upload that | 199 // upload limit (currently 10MB), what we need to do is upload that |
200 // large data to google docs and set the URL in the printing | 200 // large data to google docs and set the URL in the printing |
201 // JavaScript to that location, and make sure it gets deleted when not | 201 // JavaScript to that location, and make sure it gets deleted when not |
202 // needed. - 4/1/2010 | 202 // needed. - 4/1/2010 |
203 void CloudPrintDataSender::SendPrintDataFile() { | 203 void CloudPrintDataSender::SendPrintDataFile() { |
204 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 204 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
205 AutoLock lock(lock_); | 205 base::AutoLock lock(lock_); |
206 if (helper_ && print_data_.get()) { | 206 if (helper_ && print_data_.get()) { |
207 StringValue title(print_job_title_); | 207 StringValue title(print_job_title_); |
208 | 208 |
209 // Send the print data to the dialog contents. The JavaScript | 209 // Send the print data to the dialog contents. The JavaScript |
210 // function is a preliminary API for prototyping purposes and is | 210 // function is a preliminary API for prototyping purposes and is |
211 // subject to change. | 211 // subject to change. |
212 const_cast<CloudPrintDataSenderHelper*>(helper_)->CallJavascriptFunction( | 212 const_cast<CloudPrintDataSenderHelper*>(helper_)->CallJavascriptFunction( |
213 L"printApp._printDataUrl", *print_data_, title); | 213 L"printApp._printDataUrl", *print_data_, title); |
214 } | 214 } |
215 } | 215 } |
(...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
527 int width = pref_service->GetInteger(prefs::kCloudPrintDialogWidth); | 527 int width = pref_service->GetInteger(prefs::kCloudPrintDialogWidth); |
528 int height = pref_service->GetInteger(prefs::kCloudPrintDialogHeight); | 528 int height = pref_service->GetInteger(prefs::kCloudPrintDialogHeight); |
529 HtmlDialogUIDelegate* dialog_delegate = | 529 HtmlDialogUIDelegate* dialog_delegate = |
530 new internal_cloud_print_helpers::CloudPrintHtmlDialogDelegate( | 530 new internal_cloud_print_helpers::CloudPrintHtmlDialogDelegate( |
531 path_to_pdf, width, height, std::string(), print_job_title); | 531 path_to_pdf, width, height, std::string(), print_job_title); |
532 browser_->BrowserShowHtmlDialog(dialog_delegate, NULL); | 532 browser_->BrowserShowHtmlDialog(dialog_delegate, NULL); |
533 } | 533 } |
534 | 534 |
535 PrintDialogCloud::~PrintDialogCloud() { | 535 PrintDialogCloud::~PrintDialogCloud() { |
536 } | 536 } |
OLD | NEW |