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

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: remove requested_page 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);
kmadhusu 2011/08/19 19:51:03 how about OnPrintPreviewRequest => UpdatePreviewRe
Lei Zhang 2011/08/19 22:50:28 Most of the print preview UI methods are in the fo
486 settings->SetString(printing::kPreviewUIAddr,
kmadhusu 2011/08/19 19:51:03 Add a comment on why you are adding this UI addres
Lei Zhang 2011/08/19 22:50:28 Done.
487 print_preview_ui->GetPrintPreviewUIAddress());
480 488
481 // Increment request count. 489 // Increment request count.
482 ++regenerate_preview_request_count_; 490 ++regenerate_preview_request_count_;
483 491
484 PrintPreviewUI* print_preview_ui = static_cast<PrintPreviewUI*>(web_ui_);
485 print_preview_ui->OnPrintPreviewRequest();
486
487 TabContents* initiator_tab = GetInitiatorTab(); 492 TabContents* initiator_tab = GetInitiatorTab();
488 if (!initiator_tab) { 493 if (!initiator_tab) {
489 if (!reported_failed_preview_) { 494 if (!reported_failed_preview_) {
490 ReportUserActionHistogram(PREVIEW_FAILED); 495 ReportUserActionHistogram(PREVIEW_FAILED);
491 reported_failed_preview_ = true; 496 reported_failed_preview_ = true;
492 } 497 }
493 print_preview_ui->OnPrintPreviewFailed(); 498 print_preview_ui->OnPrintPreviewFailed();
494 return; 499 return;
495 } 500 }
496 501
(...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after
866 NULL); 871 NULL);
867 } 872 }
868 873
869 void PrintPreviewHandler::OnTabDestroyed() { 874 void PrintPreviewHandler::OnTabDestroyed() {
870 TabContents* initiator_tab = GetInitiatorTab(); 875 TabContents* initiator_tab = GetInitiatorTab();
871 if (!initiator_tab) 876 if (!initiator_tab)
872 return; 877 return;
873 878
874 TabContentsWrapper* wrapper = 879 TabContentsWrapper* wrapper =
875 TabContentsWrapper::GetCurrentWrapperForContents(initiator_tab); 880 TabContentsWrapper::GetCurrentWrapperForContents(initiator_tab);
876 wrapper->print_view_manager()->set_observer(NULL); 881 wrapper->print_view_manager()->set_observer(NULL);
kmadhusu 2011/08/19 19:51:03 Do you still need "OnTabDestroyed" function? Initi
Lei Zhang 2011/08/19 22:50:28 I believe it's still needed for http://crbug.com/8
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 } 882 }
883 883
884 void PrintPreviewHandler::FileSelected(const FilePath& path, 884 void PrintPreviewHandler::FileSelected(const FilePath& path,
885 int index, void* params) { 885 int index, void* params) {
886 PrintPreviewUI* print_preview_ui = static_cast<PrintPreviewUI*>(web_ui_); 886 PrintPreviewUI* print_preview_ui = static_cast<PrintPreviewUI*>(web_ui_);
887 scoped_refptr<RefCountedBytes> data; 887 scoped_refptr<RefCountedBytes> data;
888 print_preview_ui->GetPrintPreviewDataForIndex( 888 print_preview_ui->GetPrintPreviewDataForIndex(
889 printing::COMPLETE_PREVIEW_DOCUMENT_INDEX, &data); 889 printing::COMPLETE_PREVIEW_DOCUMENT_INDEX, &data);
890 if (!data.get()) { 890 if (!data.get()) {
891 NOTREACHED(); 891 NOTREACHED();
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
923 return; 923 return;
924 924
925 // We no longer require the initiator tab details. Remove those details 925 // We no longer require the initiator tab details. Remove those details
926 // associated with the preview tab to allow the initiator tab to create 926 // associated with the preview tab to allow the initiator tab to create
927 // another preview tab. 927 // another preview tab.
928 printing::PrintPreviewTabController* tab_controller = 928 printing::PrintPreviewTabController* tab_controller =
929 printing::PrintPreviewTabController::GetInstance(); 929 printing::PrintPreviewTabController::GetInstance();
930 if (tab_controller) 930 if (tab_controller)
931 tab_controller->EraseInitiatorTabInfo(preview_tab()); 931 tab_controller->EraseInitiatorTabInfo(preview_tab());
932 } 932 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698