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/browser/printing/print_dialog_cloud.h" | 5 #include "chrome/browser/printing/print_dialog_cloud.h" |
6 | 6 |
7 | 7 |
8 #include "base/base64.h" | 8 #include "base/base64.h" |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
206 // We have the data in hand that needs to be pushed into the dialog | 206 // We have the data in hand that needs to be pushed into the dialog |
207 // contents; do so from the IO thread. | 207 // contents; do so from the IO thread. |
208 | 208 |
209 // TODO(scottbyer): If the print data ends up being larger than the | 209 // TODO(scottbyer): If the print data ends up being larger than the |
210 // upload limit (currently 10MB), what we need to do is upload that | 210 // upload limit (currently 10MB), what we need to do is upload that |
211 // large data to google docs and set the URL in the printing | 211 // large data to google docs and set the URL in the printing |
212 // JavaScript to that location, and make sure it gets deleted when not | 212 // JavaScript to that location, and make sure it gets deleted when not |
213 // needed. - 4/1/2010 | 213 // needed. - 4/1/2010 |
214 void CloudPrintDataSender::SendPrintData() { | 214 void CloudPrintDataSender::SendPrintData() { |
215 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 215 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
216 if (!data_ || !data_->size()) | 216 if (!data_.get() || !data_->size()) |
217 return; | 217 return; |
218 | 218 |
219 std::string base64_data; | 219 std::string base64_data; |
220 base::Base64Encode( | 220 base::Base64Encode( |
221 base::StringPiece(reinterpret_cast<const char*>(data_->front()), | 221 base::StringPiece(reinterpret_cast<const char*>(data_->front()), |
222 data_->size()), | 222 data_->size()), |
223 &base64_data); | 223 &base64_data); |
224 std::string header("data:"); | 224 std::string header("data:"); |
225 header.append(file_type_); | 225 header.append(file_type_); |
226 header.append(";base64,"); | 226 header.append(";base64,"); |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
366 if (rvh) | 366 if (rvh) |
367 DevToolsWindow::OpenDevToolsWindow(rvh); | 367 DevToolsWindow::OpenDevToolsWindow(rvh); |
368 } | 368 } |
369 } | 369 } |
370 | 370 |
371 scoped_refptr<CloudPrintDataSender> | 371 scoped_refptr<CloudPrintDataSender> |
372 CloudPrintFlowHandler::CreateCloudPrintDataSender() { | 372 CloudPrintFlowHandler::CreateCloudPrintDataSender() { |
373 DCHECK(web_ui()); | 373 DCHECK(web_ui()); |
374 print_data_helper_.reset(new CloudPrintDataSenderHelper(web_ui())); | 374 print_data_helper_.reset(new CloudPrintDataSenderHelper(web_ui())); |
375 scoped_refptr<CloudPrintDataSender> sender( | 375 scoped_refptr<CloudPrintDataSender> sender( |
376 new CloudPrintDataSender(print_data_helper_.get(), print_job_title_, | 376 new CloudPrintDataSender(print_data_helper_.get(), |
377 print_ticket_, file_type_, data_)); | 377 print_job_title_, |
| 378 print_ticket_, |
| 379 file_type_, |
| 380 data_.get())); |
378 return sender; | 381 return sender; |
379 } | 382 } |
380 | 383 |
381 void CloudPrintFlowHandler::HandleSendPrintData(const ListValue* args) { | 384 void CloudPrintFlowHandler::HandleSendPrintData(const ListValue* args) { |
382 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 385 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
383 // This will cancel any ReadPrintDataFile() or SendPrintDataFile() | 386 // This will cancel any ReadPrintDataFile() or SendPrintDataFile() |
384 // requests in flight (this is anticipation of when setting page | 387 // requests in flight (this is anticipation of when setting page |
385 // setup parameters becomes asynchronous and may be set while some | 388 // setup parameters becomes asynchronous and may be set while some |
386 // data is in flight). Then we can clear out the print data. | 389 // data is in flight). Then we can clear out the print data. |
387 CancelAnyRunningTask(); | 390 CancelAnyRunningTask(); |
(...skipping 387 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
775 print_job_print_ticket, | 778 print_job_print_ticket, |
776 file_type, | 779 file_type, |
777 delete_on_close); | 780 delete_on_close); |
778 return true; | 781 return true; |
779 } | 782 } |
780 } | 783 } |
781 return false; | 784 return false; |
782 } | 785 } |
783 | 786 |
784 } // end namespace | 787 } // end namespace |
OLD | NEW |