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

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

Issue 7747033: Merge 97702, 97820, 97976 (Closed) Base URL: svn://chrome-svn/chrome/branches/835/src/
Patch Set: Created 9 years, 4 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/base64.h" 9 #include "base/base64.h"
10 #if !defined(OS_CHROMEOS) 10 #if !defined(OS_CHROMEOS)
(...skipping 455 matching lines...) Expand 10 before | Expand all | Expand 10 after
466 BrowserThread::PostTask( 466 BrowserThread::PostTask(
467 BrowserThread::FILE, FROM_HERE, 467 BrowserThread::FILE, FROM_HERE,
468 NewRunnableMethod(task.get(), 468 NewRunnableMethod(task.get(),
469 &PrintSystemTaskProxy::EnumeratePrinters)); 469 &PrintSystemTaskProxy::EnumeratePrinters));
470 } 470 }
471 471
472 void PrintPreviewHandler::HandleGetPreview(const ListValue* args) { 472 void PrintPreviewHandler::HandleGetPreview(const ListValue* args) {
473 scoped_ptr<DictionaryValue> settings(GetSettingsDictionary(args)); 473 scoped_ptr<DictionaryValue> settings(GetSettingsDictionary(args));
474 if (!settings.get()) 474 if (!settings.get())
475 return; 475 return;
476 int request_id = -1;
477 if (!settings->GetInteger(printing::kPreviewRequestID, &request_id))
478 return;
479
480 PrintPreviewUI* print_preview_ui = static_cast<PrintPreviewUI*>(web_ui_);
481 print_preview_ui->OnPrintPreviewRequest(request_id);
482 // Add an additional key in order to identify |print_preview_ui| later on
483 // when calling PrintPreviewUI::GetCurrentPrintPreviewStatus() on the IO
484 // thread.
485 settings->SetString(printing::kPreviewUIAddr,
486 print_preview_ui->GetPrintPreviewUIAddress());
476 487
477 // Increment request count. 488 // Increment request count.
478 ++regenerate_preview_request_count_; 489 ++regenerate_preview_request_count_;
479 490
480 PrintPreviewUI* print_preview_ui = static_cast<PrintPreviewUI*>(web_ui_);
481 print_preview_ui->OnPrintPreviewRequest();
482
483 TabContents* initiator_tab = GetInitiatorTab(); 491 TabContents* initiator_tab = GetInitiatorTab();
484 if (!initiator_tab) { 492 if (!initiator_tab) {
485 if (!reported_failed_preview_) { 493 if (!reported_failed_preview_) {
486 ReportUserActionHistogram(PREVIEW_FAILED); 494 ReportUserActionHistogram(PREVIEW_FAILED);
487 reported_failed_preview_ = true; 495 reported_failed_preview_ = true;
488 } 496 }
489 print_preview_ui->OnPrintPreviewFailed(); 497 print_preview_ui->OnPrintPreviewFailed();
490 return; 498 return;
491 } 499 }
492 VLOG(1) << "Print preview request start"; 500 VLOG(1) << "Print preview request start";
(...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after
830 } 838 }
831 839
832 void PrintPreviewHandler::OnNavigation() { 840 void PrintPreviewHandler::OnNavigation() {
833 TabContents* initiator_tab = GetInitiatorTab(); 841 TabContents* initiator_tab = GetInitiatorTab();
834 if (!initiator_tab) 842 if (!initiator_tab)
835 return; 843 return;
836 844
837 TabContentsWrapper* wrapper = 845 TabContentsWrapper* wrapper =
838 TabContentsWrapper::GetCurrentWrapperForContents(initiator_tab); 846 TabContentsWrapper::GetCurrentWrapperForContents(initiator_tab);
839 wrapper->print_view_manager()->set_observer(NULL); 847 wrapper->print_view_manager()->set_observer(NULL);
840
841 // Tell the initiator tab to stop rendering the print preview, if any,
842 // since the preview tab is gone.
843 RenderViewHost* rvh = initiator_tab->render_view_host();
844 rvh->Send(new PrintMsg_AbortPreview(rvh->routing_id()));
845 } 848 }
846 849
847 void PrintPreviewHandler::FileSelected(const FilePath& path, 850 void PrintPreviewHandler::FileSelected(const FilePath& path,
848 int index, void* params) { 851 int index, void* params) {
849 PrintPreviewUI* print_preview_ui = static_cast<PrintPreviewUI*>(web_ui_); 852 PrintPreviewUI* print_preview_ui = static_cast<PrintPreviewUI*>(web_ui_);
850 scoped_refptr<RefCountedBytes> data; 853 scoped_refptr<RefCountedBytes> data;
851 print_preview_ui->GetPrintPreviewDataForIndex( 854 print_preview_ui->GetPrintPreviewDataForIndex(
852 printing::COMPLETE_PREVIEW_DOCUMENT_INDEX, &data); 855 printing::COMPLETE_PREVIEW_DOCUMENT_INDEX, &data);
853 if (!data.get()) { 856 if (!data.get()) {
854 NOTREACHED(); 857 NOTREACHED();
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
886 return; 889 return;
887 890
888 // We no longer require the initiator tab details. Remove those details 891 // We no longer require the initiator tab details. Remove those details
889 // associated with the preview tab to allow the initiator tab to create 892 // associated with the preview tab to allow the initiator tab to create
890 // another preview tab. 893 // another preview tab.
891 printing::PrintPreviewTabController* tab_controller = 894 printing::PrintPreviewTabController* tab_controller =
892 printing::PrintPreviewTabController::GetInstance(); 895 printing::PrintPreviewTabController::GetInstance();
893 if (tab_controller) 896 if (tab_controller)
894 tab_controller->EraseInitiatorTabInfo(preview_tab()); 897 tab_controller->EraseInitiatorTabInfo(preview_tab());
895 } 898 }
OLDNEW
« no previous file with comments | « chrome/browser/printing/printing_message_filter.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