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

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

Issue 7715022: Print Preview: Provide a link to try printing with the system dialog when print preview fails. Al... (Closed) Base URL: svn://chrome-svn/chrome/trunk/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 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 #endif 68 #endif
69 69
70 enum UserActionBuckets { 70 enum UserActionBuckets {
71 PRINT_TO_PRINTER, 71 PRINT_TO_PRINTER,
72 PRINT_TO_PDF, 72 PRINT_TO_PDF,
73 CANCEL, 73 CANCEL,
74 FALLBACK_TO_ADVANCED_SETTINGS_DIALOG, 74 FALLBACK_TO_ADVANCED_SETTINGS_DIALOG,
75 PREVIEW_FAILED, 75 PREVIEW_FAILED,
76 PREVIEW_STARTED, 76 PREVIEW_STARTED,
77 INITIATOR_TAB_CRASHED, 77 INITIATOR_TAB_CRASHED,
78 INITIATOR_TAB_CLOSED,
78 USERACTION_BUCKET_BOUNDARY 79 USERACTION_BUCKET_BOUNDARY
79 }; 80 };
80 81
81 enum PrintSettingsBuckets { 82 enum PrintSettingsBuckets {
82 LANDSCAPE, 83 LANDSCAPE,
83 PORTRAIT, 84 PORTRAIT,
84 COLOR, 85 COLOR,
85 BLACK_AND_WHITE, 86 BLACK_AND_WHITE,
86 COLLATE, 87 COLLATE,
87 SIMPLEX, 88 SIMPLEX,
(...skipping 399 matching lines...) Expand 10 before | Expand all | Expand 10 after
487 // when calling PrintPreviewUI::GetCurrentPrintPreviewStatus() on the IO 488 // when calling PrintPreviewUI::GetCurrentPrintPreviewStatus() on the IO
488 // thread. 489 // thread.
489 settings->SetString(printing::kPreviewUIAddr, 490 settings->SetString(printing::kPreviewUIAddr,
490 print_preview_ui->GetPrintPreviewUIAddress()); 491 print_preview_ui->GetPrintPreviewUIAddress());
491 492
492 // Increment request count. 493 // Increment request count.
493 ++regenerate_preview_request_count_; 494 ++regenerate_preview_request_count_;
494 495
495 TabContents* initiator_tab = GetInitiatorTab(); 496 TabContents* initiator_tab = GetInitiatorTab();
496 if (!initiator_tab) { 497 if (!initiator_tab) {
497 if (!reported_failed_preview_) { 498 ReportUserActionHistogram(INITIATOR_TAB_CLOSED);
498 ReportUserActionHistogram(PREVIEW_FAILED); 499 print_preview_ui->OnInitiatorTabClosed();
499 reported_failed_preview_ = true;
500 }
501 print_preview_ui->OnPrintPreviewFailed();
502 return; 500 return;
503 } 501 }
504 502
505 // Retrieve the page title and url and send it to the renderer process if 503 // Retrieve the page title and url and send it to the renderer process if
506 // headers and footers are to be displayed. 504 // headers and footers are to be displayed.
507 bool display_header_footer = false; 505 bool display_header_footer = false;
508 if (!settings->GetBoolean(printing::kSettingHeaderFooterEnabled, 506 if (!settings->GetBoolean(printing::kSettingHeaderFooterEnabled,
509 &display_header_footer)) { 507 &display_header_footer)) {
510 NOTREACHED(); 508 NOTREACHED();
511 } 509 }
(...skipping 365 matching lines...) Expand 10 before | Expand all | Expand 10 after
877 void PrintPreviewHandler::OnTabDestroyed() { 875 void PrintPreviewHandler::OnTabDestroyed() {
878 TabContents* initiator_tab = GetInitiatorTab(); 876 TabContents* initiator_tab = GetInitiatorTab();
879 if (!initiator_tab) 877 if (!initiator_tab)
880 return; 878 return;
881 879
882 TabContentsWrapper* wrapper = 880 TabContentsWrapper* wrapper =
883 TabContentsWrapper::GetCurrentWrapperForContents(initiator_tab); 881 TabContentsWrapper::GetCurrentWrapperForContents(initiator_tab);
884 wrapper->print_view_manager()->set_observer(NULL); 882 wrapper->print_view_manager()->set_observer(NULL);
885 } 883 }
886 884
885 void PrintPreviewHandler::OnPrintPreviewFailed() {
886 if (reported_failed_preview_)
887 return;
888 reported_failed_preview_ = true;
889 ReportUserActionHistogram(PREVIEW_FAILED);
890 }
891
887 void PrintPreviewHandler::FileSelected(const FilePath& path, 892 void PrintPreviewHandler::FileSelected(const FilePath& path,
888 int index, void* params) { 893 int index, void* params) {
889 PrintPreviewUI* print_preview_ui = static_cast<PrintPreviewUI*>(web_ui_); 894 PrintPreviewUI* print_preview_ui = static_cast<PrintPreviewUI*>(web_ui_);
890 scoped_refptr<RefCountedBytes> data; 895 scoped_refptr<RefCountedBytes> data;
891 print_preview_ui->GetPrintPreviewDataForIndex( 896 print_preview_ui->GetPrintPreviewDataForIndex(
892 printing::COMPLETE_PREVIEW_DOCUMENT_INDEX, &data); 897 printing::COMPLETE_PREVIEW_DOCUMENT_INDEX, &data);
893 if (!data.get()) { 898 if (!data.get()) {
894 NOTREACHED(); 899 NOTREACHED();
895 return; 900 return;
896 } 901 }
(...skipping 29 matching lines...) Expand all
926 return; 931 return;
927 932
928 // We no longer require the initiator tab details. Remove those details 933 // We no longer require the initiator tab details. Remove those details
929 // associated with the preview tab to allow the initiator tab to create 934 // associated with the preview tab to allow the initiator tab to create
930 // another preview tab. 935 // another preview tab.
931 printing::PrintPreviewTabController* tab_controller = 936 printing::PrintPreviewTabController* tab_controller =
932 printing::PrintPreviewTabController::GetInstance(); 937 printing::PrintPreviewTabController::GetInstance();
933 if (tab_controller) 938 if (tab_controller)
934 tab_controller->EraseInitiatorTabInfo(preview_tab()); 939 tab_controller->EraseInitiatorTabInfo(preview_tab());
935 } 940 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698