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

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, 7 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/print_job_constants.h" 35 #include "printing/print_job_constants.h"
(...skipping 494 matching lines...) Expand 10 before | Expand all | Expand 10 after
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;
541 PrintPreviewUI* print_preview_ui = static_cast<PrintPreviewUI*>(web_ui_); 540 PrintPreviewUI* print_preview_ui = static_cast<PrintPreviewUI*>(web_ui_);
542 print_preview_ui->html_source()->GetPrintPreviewData(&data); 541 scoped_refptr<RefCountedBytes> data(new RefCountedBytes());
543 if (!data.first || !data.second) { 542 print_preview_ui->GetPrintPreviewData(&data);
543 if (!data->front() || !data->size()) {
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(reinterpret_cast<const void*>(data->front()),
Lei Zhang 2011/05/27 17:26:53 can you static_cast here?
kmadhusu 2011/05/27 23:44:42 Done.
550 data->size());
550 551
551 // Updating last_saved_path_ to the newly selected folder. 552 // Updating last_saved_path_ to the newly selected folder.
552 *last_saved_path_ = path.DirName(); 553 *last_saved_path_ = path.DirName();
553 554
554 PrintToPdfTask* task = new PrintToPdfTask(metafile, path); 555 PrintToPdfTask* task = new PrintToPdfTask(metafile, path);
555 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, task); 556 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, task);
556 557
557 ActivateInitiatorTabAndClosePreviewTab(); 558 ActivateInitiatorTabAndClosePreviewTab();
558 } 559 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698