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

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

Issue 7621087: Print Preview: Go from event driven print preview back to print preview with sync messages. The s... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: fix missing lock 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 459 matching lines...) Expand 10 before | Expand all | Expand 10 after
470 BrowserThread::PostTask( 470 BrowserThread::PostTask(
471 BrowserThread::FILE, FROM_HERE, 471 BrowserThread::FILE, FROM_HERE,
472 NewRunnableMethod(task.get(), 472 NewRunnableMethod(task.get(),
473 &PrintSystemTaskProxy::EnumeratePrinters)); 473 &PrintSystemTaskProxy::EnumeratePrinters));
474 } 474 }
475 475
476 void PrintPreviewHandler::HandleGetPreview(const ListValue* args) { 476 void PrintPreviewHandler::HandleGetPreview(const ListValue* args) {
477 scoped_ptr<DictionaryValue> settings(GetSettingsDictionary(args)); 477 scoped_ptr<DictionaryValue> settings(GetSettingsDictionary(args));
478 if (!settings.get()) 478 if (!settings.get())
479 return; 479 return;
480 int request_id = -1;
481 if (!settings->GetInteger(printing::kPreviewRequestID, &request_id))
482 return;
483
484 PrintPreviewUI* print_preview_ui = static_cast<PrintPreviewUI*>(web_ui_);
485 print_preview_ui->OnPrintPreviewRequest(request_id);
486 // Add an additional key in order to identify |print_preview_ui| later on
487 // when calling PrintPreviewUI::GetCurrentPrintPreviewStatus() on the IO
488 // thread.
489 settings->SetString(printing::kPreviewUIAddr,
490 print_preview_ui->GetPrintPreviewUIAddress());
480 491
481 // Increment request count. 492 // Increment request count.
482 ++regenerate_preview_request_count_; 493 ++regenerate_preview_request_count_;
483 494
484 PrintPreviewUI* print_preview_ui = static_cast<PrintPreviewUI*>(web_ui_);
485 print_preview_ui->OnPrintPreviewRequest();
486
487 TabContents* initiator_tab = GetInitiatorTab(); 495 TabContents* initiator_tab = GetInitiatorTab();
488 if (!initiator_tab) { 496 if (!initiator_tab) {
489 if (!reported_failed_preview_) { 497 if (!reported_failed_preview_) {
490 ReportUserActionHistogram(PREVIEW_FAILED); 498 ReportUserActionHistogram(PREVIEW_FAILED);
491 reported_failed_preview_ = true; 499 reported_failed_preview_ = true;
492 } 500 }
493 print_preview_ui->OnPrintPreviewFailed(); 501 print_preview_ui->OnPrintPreviewFailed();
494 return; 502 return;
495 } 503 }
496 504
(...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after
867 } 875 }
868 876
869 void PrintPreviewHandler::OnTabDestroyed() { 877 void PrintPreviewHandler::OnTabDestroyed() {
870 TabContents* initiator_tab = GetInitiatorTab(); 878 TabContents* initiator_tab = GetInitiatorTab();
871 if (!initiator_tab) 879 if (!initiator_tab)
872 return; 880 return;
873 881
874 TabContentsWrapper* wrapper = 882 TabContentsWrapper* wrapper =
875 TabContentsWrapper::GetCurrentWrapperForContents(initiator_tab); 883 TabContentsWrapper::GetCurrentWrapperForContents(initiator_tab);
876 wrapper->print_view_manager()->set_observer(NULL); 884 wrapper->print_view_manager()->set_observer(NULL);
877
878 // Tell the initiator tab to stop rendering the print preview, if any,
879 // since the preview tab is gone.
880 RenderViewHost* rvh = initiator_tab->render_view_host();
881 rvh->Send(new PrintMsg_AbortPreview(rvh->routing_id()));
882 } 885 }
883 886
884 void PrintPreviewHandler::FileSelected(const FilePath& path, 887 void PrintPreviewHandler::FileSelected(const FilePath& path,
885 int index, void* params) { 888 int index, void* params) {
886 PrintPreviewUI* print_preview_ui = static_cast<PrintPreviewUI*>(web_ui_); 889 PrintPreviewUI* print_preview_ui = static_cast<PrintPreviewUI*>(web_ui_);
887 scoped_refptr<RefCountedBytes> data; 890 scoped_refptr<RefCountedBytes> data;
888 print_preview_ui->GetPrintPreviewDataForIndex( 891 print_preview_ui->GetPrintPreviewDataForIndex(
889 printing::COMPLETE_PREVIEW_DOCUMENT_INDEX, &data); 892 printing::COMPLETE_PREVIEW_DOCUMENT_INDEX, &data);
890 if (!data.get()) { 893 if (!data.get()) {
891 NOTREACHED(); 894 NOTREACHED();
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
923 return; 926 return;
924 927
925 // We no longer require the initiator tab details. Remove those details 928 // We no longer require the initiator tab details. Remove those details
926 // associated with the preview tab to allow the initiator tab to create 929 // associated with the preview tab to allow the initiator tab to create
927 // another preview tab. 930 // another preview tab.
928 printing::PrintPreviewTabController* tab_controller = 931 printing::PrintPreviewTabController* tab_controller =
929 printing::PrintPreviewTabController::GetInstance(); 932 printing::PrintPreviewTabController::GetInstance();
930 if (tab_controller) 933 if (tab_controller)
931 tab_controller->EraseInitiatorTabInfo(preview_tab()); 934 tab_controller->EraseInitiatorTabInfo(preview_tab());
932 } 935 }
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