Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(22)

Side by Side Diff: chrome/browser/ui/webui/print_preview_handler.cc

Issue 7063030: PrintPreview: Print Preview is not staying associated with initiator renderer. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: '' Created 9 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/memory/ref_counted.h"
11 #include "base/metrics/histogram.h" 12 #include "base/metrics/histogram.h"
12 #include "base/path_service.h" 13 #include "base/path_service.h"
13 #include "base/threading/thread.h" 14 #include "base/threading/thread.h"
14 #include "base/threading/thread_restrictions.h" 15 #include "base/threading/thread_restrictions.h"
15 #include "base/utf_string_conversions.h" 16 #include "base/utf_string_conversions.h"
16 #include "base/values.h" 17 #include "base/values.h"
17 #include "chrome/browser/browser_process.h" 18 #include "chrome/browser/browser_process.h"
18 #include "chrome/browser/platform_util.h" 19 #include "chrome/browser/platform_util.h"
19 #include "chrome/browser/printing/background_printing_manager.h" 20 #include "chrome/browser/printing/background_printing_manager.h"
20 #include "chrome/browser/printing/printer_manager_dialog.h" 21 #include "chrome/browser/printing/printer_manager_dialog.h"
21 #include "chrome/browser/printing/print_preview_tab_controller.h" 22 #include "chrome/browser/printing/print_preview_tab_controller.h"
22 #include "chrome/browser/tabs/tab_strip_model.h" 23 #include "chrome/browser/tabs/tab_strip_model.h"
23 #include "chrome/browser/ui/browser_list.h" 24 #include "chrome/browser/ui/browser_list.h"
24 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" 25 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
25 #include "chrome/browser/ui/webui/print_preview_ui_html_source.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/page_range.h" 35 #include "printing/page_range.h"
(...skipping 576 matching lines...) Expand 10 before | Expand all | Expand 10 after
612 &file_type_info, 612 &file_type_info,
613 0, 613 0,
614 FILE_PATH_LITERAL(""), 614 FILE_PATH_LITERAL(""),
615 preview_tab(), 615 preview_tab(),
616 platform_util::GetTopLevel(preview_tab()->GetNativeView()), 616 platform_util::GetTopLevel(preview_tab()->GetNativeView()),
617 NULL); 617 NULL);
618 } 618 }
619 619
620 void PrintPreviewHandler::FileSelected(const FilePath& path, 620 void PrintPreviewHandler::FileSelected(const FilePath& path,
621 int index, void* params) { 621 int index, void* params) {
622 PrintPreviewUIHTMLSource::PrintPreviewData data;
623 PrintPreviewUI* print_preview_ui = static_cast<PrintPreviewUI*>(web_ui_); 622 PrintPreviewUI* print_preview_ui = static_cast<PrintPreviewUI*>(web_ui_);
624 print_preview_ui->html_source()->GetPrintPreviewData(&data); 623 scoped_refptr<RefCountedBytes> data(new RefCountedBytes());
625 if (!data.first || !data.second) { 624 print_preview_ui->GetPrintPreviewData(&data);
625 if (!data->front()) {
626 NOTREACHED(); 626 NOTREACHED();
627 return; 627 return;
628 } 628 }
629 629
630 printing::PreviewMetafile* metafile = new printing::PreviewMetafile; 630 printing::PreviewMetafile* metafile = new printing::PreviewMetafile;
631 metafile->InitFromData(data.first->memory(), data.second); 631 metafile->InitFromData(static_cast<const void*>(data->front()), data->size());
632 632
633 // Updating last_saved_path_ to the newly selected folder. 633 // Updating last_saved_path_ to the newly selected folder.
634 *last_saved_path_ = path.DirName(); 634 *last_saved_path_ = path.DirName();
635 635
636 PrintToPdfTask* task = new PrintToPdfTask(metafile, path); 636 PrintToPdfTask* task = new PrintToPdfTask(metafile, path);
637 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, task); 637 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, task);
638 638
639 ActivateInitiatorTabAndClosePreviewTab(); 639 ActivateInitiatorTabAndClosePreviewTab();
640 } 640 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/print_preview_data_source.cc ('k') | chrome/browser/ui/webui/print_preview_ui.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698