Chromium Code Reviews| Index: chrome/browser/ui/webui/print_preview/print_preview_handler.cc |
| diff --git a/chrome/browser/ui/webui/print_preview/print_preview_handler.cc b/chrome/browser/ui/webui/print_preview/print_preview_handler.cc |
| index 66009cba46129547c7b38beca918586eb25c8814..26036343821d06dbb6f7dd0a92a4b789cd5e8ab3 100644 |
| --- a/chrome/browser/ui/webui/print_preview/print_preview_handler.cc |
| +++ b/chrome/browser/ui/webui/print_preview/print_preview_handler.cc |
| @@ -59,6 +59,10 @@ |
| #include "printing/print_settings.h" |
| #include "unicode/ulocdata.h" |
| +#ifdef OS_CHROMEOS |
| +#include "chrome/browser/chromeos/gdata/gdata_util.h" |
| +#endif |
| + |
| #if !defined(OS_MACOSX) |
| #include "base/command_line.h" |
| #include "chrome/common/chrome_switches.h" |
| @@ -213,6 +217,22 @@ void PrintToPdfCallback(Metafile* metafile, const FilePath& path) { |
| base::Bind(&base::DeletePointer<Metafile>, metafile)); |
| } |
| +#ifdef OS_CHROMEOS |
| +void PrintToPdfCallbackWithCheck(Metafile* metafile, |
| + gdata::GDataFileError error, |
| + const FilePath& path) { |
| + if (error != gdata::GDATA_FILE_OK) { |
| + LOG(ERROR) << "Save to pdf failed to write: " << error; |
| + } else { |
| + metafile->SaveTo(path); |
| + } |
| + // |metafile| must be deleted on the UI thread. |
| + BrowserThread::PostTask( |
| + BrowserThread::UI, FROM_HERE, |
| + base::Bind(&base::DeletePointer<Metafile>, metafile)); |
| +} |
| +#endif |
| + |
| static base::LazyInstance<printing::StickySettings> sticky_settings = |
| LAZY_INSTANCE_INITIALIZER; |
| @@ -911,9 +931,17 @@ void PrintPreviewHandler::PostPrintToPdfTask(base::RefCountedBytes* data) { |
| printing::PreviewMetafile* metafile = new printing::PreviewMetafile; |
| metafile->InitFromData(static_cast<const void*>(data->front()), data->size()); |
| // PrintToPdfCallback takes ownership of |metafile|. |
| +#ifdef OS_CHROMEOS |
|
satorux1
2012/08/02 06:59:16
on what thread this function is called? can you ad
kinaba
2012/08/02 07:22:39
Done.
|
| + gdata::util::PrepareWritableFileAndRun( |
| + Profile::FromBrowserContext(preview_web_contents()->GetBrowserContext()), |
| + *print_to_pdf_path_, |
| + base::Bind(&PrintToPdfCallbackWithCheck, metafile)); |
| +#else |
| BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, |
| base::Bind(&PrintToPdfCallback, metafile, |
| *print_to_pdf_path_)); |
| +#endif |
| + |
| print_to_pdf_path_.reset(); |
| ActivateInitiatorTabAndClosePreviewTab(); |
| } |