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/ui/webui/print_preview/print_preview_handler.h" | 5 #include "chrome/browser/ui/webui/print_preview/print_preview_handler.h" |
6 | 6 |
7 #include <ctype.h> | 7 #include <ctype.h> |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 | 10 |
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
218 void PrintToPdfCallback(Metafile* metafile, const FilePath& path) { | 218 void PrintToPdfCallback(Metafile* metafile, const FilePath& path) { |
219 metafile->SaveTo(path); | 219 metafile->SaveTo(path); |
220 // |metafile| must be deleted on the UI thread. | 220 // |metafile| must be deleted on the UI thread. |
221 BrowserThread::PostTask( | 221 BrowserThread::PostTask( |
222 BrowserThread::UI, FROM_HERE, | 222 BrowserThread::UI, FROM_HERE, |
223 base::Bind(&base::DeletePointer<Metafile>, metafile)); | 223 base::Bind(&base::DeletePointer<Metafile>, metafile)); |
224 } | 224 } |
225 | 225 |
226 #ifdef OS_CHROMEOS | 226 #ifdef OS_CHROMEOS |
227 void PrintToPdfCallbackWithCheck(Metafile* metafile, | 227 void PrintToPdfCallbackWithCheck(Metafile* metafile, |
228 gdata::DriveFileError error, | 228 drive::DriveFileError error, |
229 const FilePath& path) { | 229 const FilePath& path) { |
230 if (error != gdata::DRIVE_FILE_OK) { | 230 if (error != drive::DRIVE_FILE_OK) { |
231 LOG(ERROR) << "Save to pdf failed to write: " << error; | 231 LOG(ERROR) << "Save to pdf failed to write: " << error; |
232 } else { | 232 } else { |
233 metafile->SaveTo(path); | 233 metafile->SaveTo(path); |
234 } | 234 } |
235 // |metafile| must be deleted on the UI thread. | 235 // |metafile| must be deleted on the UI thread. |
236 BrowserThread::PostTask( | 236 BrowserThread::PostTask( |
237 BrowserThread::UI, FROM_HERE, | 237 BrowserThread::UI, FROM_HERE, |
238 base::Bind(&base::DeletePointer<Metafile>, metafile)); | 238 base::Bind(&base::DeletePointer<Metafile>, metafile)); |
239 } | 239 } |
240 #endif | 240 #endif |
(...skipping 661 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
902 void PrintPreviewHandler::PostPrintToPdfTask(base::RefCountedBytes* data) { | 902 void PrintPreviewHandler::PostPrintToPdfTask(base::RefCountedBytes* data) { |
903 if (!data) { | 903 if (!data) { |
904 NOTREACHED(); | 904 NOTREACHED(); |
905 return; | 905 return; |
906 } | 906 } |
907 printing::PreviewMetafile* metafile = new printing::PreviewMetafile; | 907 printing::PreviewMetafile* metafile = new printing::PreviewMetafile; |
908 metafile->InitFromData(static_cast<const void*>(data->front()), data->size()); | 908 metafile->InitFromData(static_cast<const void*>(data->front()), data->size()); |
909 // PrintToPdfCallback takes ownership of |metafile|. | 909 // PrintToPdfCallback takes ownership of |metafile|. |
910 #ifdef OS_CHROMEOS | 910 #ifdef OS_CHROMEOS |
911 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 911 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
912 gdata::util::PrepareWritableFileAndRun( | 912 drive::util::PrepareWritableFileAndRun( |
913 Profile::FromBrowserContext(preview_web_contents()->GetBrowserContext()), | 913 Profile::FromBrowserContext(preview_web_contents()->GetBrowserContext()), |
914 *print_to_pdf_path_, | 914 *print_to_pdf_path_, |
915 base::Bind(&PrintToPdfCallbackWithCheck, metafile)); | 915 base::Bind(&PrintToPdfCallbackWithCheck, metafile)); |
916 #else | 916 #else |
917 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, | 917 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, |
918 base::Bind(&PrintToPdfCallback, metafile, | 918 base::Bind(&PrintToPdfCallback, metafile, |
919 *print_to_pdf_path_)); | 919 *print_to_pdf_path_)); |
920 #endif | 920 #endif |
921 | 921 |
922 print_to_pdf_path_.reset(); | 922 print_to_pdf_path_.reset(); |
(...skipping 12 matching lines...) Expand all Loading... |
935 return; | 935 return; |
936 | 936 |
937 // We no longer require the initiator tab details. Remove those details | 937 // We no longer require the initiator tab details. Remove those details |
938 // associated with the preview tab to allow the initiator tab to create | 938 // associated with the preview tab to allow the initiator tab to create |
939 // another preview tab. | 939 // another preview tab. |
940 printing::PrintPreviewTabController* tab_controller = | 940 printing::PrintPreviewTabController* tab_controller = |
941 printing::PrintPreviewTabController::GetInstance(); | 941 printing::PrintPreviewTabController::GetInstance(); |
942 if (tab_controller) | 942 if (tab_controller) |
943 tab_controller->EraseInitiatorTabInfo(preview_tab_contents()); | 943 tab_controller->EraseInitiatorTabInfo(preview_tab_contents()); |
944 } | 944 } |
OLD | NEW |