| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_handler.h" | 5 #include "chrome/browser/ui/webui/print_preview_handler.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/i18n/file_util_icu.h" | 9 #include "base/i18n/file_util_icu.h" |
| 10 #include "base/json/json_reader.h" | 10 #include "base/json/json_reader.h" |
| 11 #include "base/metrics/histogram.h" | 11 #include "base/metrics/histogram.h" |
| 12 #include "base/path_service.h" | 12 #include "base/path_service.h" |
| 13 #include "base/threading/thread.h" | 13 #include "base/threading/thread.h" |
| 14 #include "base/threading/thread_restrictions.h" | 14 #include "base/threading/thread_restrictions.h" |
| 15 #include "base/utf_string_conversions.h" | 15 #include "base/utf_string_conversions.h" |
| 16 #include "base/values.h" | 16 #include "base/values.h" |
| 17 #include "chrome/browser/browser_process.h" | 17 #include "chrome/browser/browser_process.h" |
| 18 #include "chrome/browser/platform_util.h" | 18 #include "chrome/browser/platform_util.h" |
| 19 #include "chrome/browser/printing/background_printing_manager.h" | 19 #include "chrome/browser/printing/background_printing_manager.h" |
| 20 #include "chrome/browser/printing/printer_manager_dialog.h" | 20 #include "chrome/browser/printing/printer_manager_dialog.h" |
| 21 #include "chrome/browser/printing/print_preview_tab_controller.h" | 21 #include "chrome/browser/printing/print_preview_tab_controller.h" |
| 22 #include "chrome/browser/tabs/tab_strip_model.h" | 22 #include "chrome/browser/tabs/tab_strip_model.h" |
| 23 #include "chrome/browser/ui/browser_list.h" | 23 #include "chrome/browser/ui/browser_list.h" |
| 24 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" | 24 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" |
| 25 #include "chrome/browser/ui/webui/print_preview_ui_html_source.h" | 25 #include "chrome/browser/ui/webui/print_preview_data_manager.h" |
| 26 #include "chrome/browser/ui/webui/print_preview_ui.h" | 26 #include "chrome/browser/ui/webui/print_preview_ui.h" |
| 27 #include "chrome/common/chrome_paths.h" | 27 #include "chrome/common/chrome_paths.h" |
| 28 #include "chrome/common/print_messages.h" | 28 #include "chrome/common/print_messages.h" |
| 29 #include "content/browser/browser_thread.h" | 29 #include "content/browser/browser_thread.h" |
| 30 #include "content/browser/renderer_host/render_view_host.h" | 30 #include "content/browser/renderer_host/render_view_host.h" |
| 31 #include "content/browser/tab_contents/tab_contents.h" | 31 #include "content/browser/tab_contents/tab_contents.h" |
| 32 #include "printing/backend/print_backend.h" | 32 #include "printing/backend/print_backend.h" |
| 33 #include "printing/metafile.h" | 33 #include "printing/metafile.h" |
| 34 #include "printing/metafile_impl.h" | 34 #include "printing/metafile_impl.h" |
| 35 #include "printing/print_job_constants.h" | 35 #include "printing/print_job_constants.h" |
| (...skipping 494 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 530 &file_type_info, | 530 &file_type_info, |
| 531 0, | 531 0, |
| 532 FILE_PATH_LITERAL(""), | 532 FILE_PATH_LITERAL(""), |
| 533 preview_tab(), | 533 preview_tab(), |
| 534 platform_util::GetTopLevel(preview_tab()->GetNativeView()), | 534 platform_util::GetTopLevel(preview_tab()->GetNativeView()), |
| 535 NULL); | 535 NULL); |
| 536 } | 536 } |
| 537 | 537 |
| 538 void PrintPreviewHandler::FileSelected(const FilePath& path, | 538 void PrintPreviewHandler::FileSelected(const FilePath& path, |
| 539 int index, void* params) { | 539 int index, void* params) { |
| 540 PrintPreviewUIHTMLSource::PrintPreviewData data; | 540 PrintPreviewDataManager::PrintPreviewData data; |
| 541 PrintPreviewUI* print_preview_ui = static_cast<PrintPreviewUI*>(web_ui_); | 541 PrintPreviewUI* print_preview_ui = static_cast<PrintPreviewUI*>(web_ui_); |
| 542 print_preview_ui->html_source()->GetPrintPreviewData(&data); | 542 print_preview_ui->GetPrintPreviewData(&data); |
| 543 if (!data.first || !data.second) { | 543 if (!data.first || !data.second) { |
| 544 NOTREACHED(); | 544 NOTREACHED(); |
| 545 return; | 545 return; |
| 546 } | 546 } |
| 547 | 547 |
| 548 printing::PreviewMetafile* metafile = new printing::PreviewMetafile; | 548 printing::PreviewMetafile* metafile = new printing::PreviewMetafile; |
| 549 metafile->InitFromData(data.first->memory(), data.second); | 549 metafile->InitFromData(data.first->memory(), data.second); |
| 550 | 550 |
| 551 // Updating last_saved_path_ to the newly selected folder. | 551 // Updating last_saved_path_ to the newly selected folder. |
| 552 *last_saved_path_ = path.DirName(); | 552 *last_saved_path_ = path.DirName(); |
| 553 | 553 |
| 554 PrintToPdfTask* task = new PrintToPdfTask(metafile, path); | 554 PrintToPdfTask* task = new PrintToPdfTask(metafile, path); |
| 555 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, task); | 555 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, task); |
| 556 | 556 |
| 557 ActivateInitiatorTabAndClosePreviewTab(); | 557 ActivateInitiatorTabAndClosePreviewTab(); |
| 558 } | 558 } |
| OLD | NEW |