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

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

Issue 16290004: Update chrome/ to use scoped_refptr<T>::get() rather than implicit "operator T*" (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 6 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/print_preview_handler.h" 5 #include "chrome/browser/ui/webui/print_preview/print_preview_handler.h"
6 6
7 #include <ctype.h> 7 #include <ctype.h>
8 8
9 #include <string> 9 #include <string>
10 10
(...skipping 532 matching lines...) Expand 10 before | Expand all | Expand 10 after
543 string16 title; 543 string16 title;
544 if (!GetPreviewDataAndTitle(&data, &title)) { 544 if (!GetPreviewDataAndTitle(&data, &title)) {
545 // Nothing to print, no preview available. 545 // Nothing to print, no preview available.
546 return; 546 return;
547 } 547 }
548 548
549 if (is_cloud_printer) { 549 if (is_cloud_printer) {
550 UMA_HISTOGRAM_COUNTS("PrintPreview.PageCount.PrintToCloudPrint", 550 UMA_HISTOGRAM_COUNTS("PrintPreview.PageCount.PrintToCloudPrint",
551 page_count); 551 page_count);
552 ReportUserActionHistogram(PRINT_WITH_CLOUD_PRINT); 552 ReportUserActionHistogram(PRINT_WITH_CLOUD_PRINT);
553 SendCloudPrintJob(data); 553 SendCloudPrintJob(data.get());
554 } else { 554 } else {
555 UMA_HISTOGRAM_COUNTS("PrintPreview.PageCount.PrintToPrinter", page_count); 555 UMA_HISTOGRAM_COUNTS("PrintPreview.PageCount.PrintToPrinter", page_count);
556 ReportUserActionHistogram(PRINT_TO_PRINTER); 556 ReportUserActionHistogram(PRINT_TO_PRINTER);
557 ReportPrintSettingsStats(*settings); 557 ReportPrintSettingsStats(*settings);
558 558
559 // This tries to activate the initiator tab as well, so do not clear the 559 // This tries to activate the initiator tab as well, so do not clear the
560 // association with the initiator tab yet. 560 // association with the initiator tab yet.
561 PrintPreviewUI* print_preview_ui = static_cast<PrintPreviewUI*>( 561 PrintPreviewUI* print_preview_ui = static_cast<PrintPreviewUI*>(
562 web_ui()->GetController()); 562 web_ui()->GetController());
563 print_preview_ui->OnHidePreviewDialog(); 563 print_preview_ui->OnHidePreviewDialog();
(...skipping 24 matching lines...) Expand all
588 printing::PrintViewManager::FromWebContents(initiator_tab); 588 printing::PrintViewManager::FromWebContents(initiator_tab);
589 print_view_manager->PrintPreviewDone(); 589 print_view_manager->PrintPreviewDone();
590 } 590 }
591 } 591 }
592 } 592 }
593 593
594 void PrintPreviewHandler::PrintToPdf() { 594 void PrintPreviewHandler::PrintToPdf() {
595 if (print_to_pdf_path_.get()) { 595 if (print_to_pdf_path_.get()) {
596 // User has already selected a path, no need to show the dialog again. 596 // User has already selected a path, no need to show the dialog again.
597 PostPrintToPdfTask(); 597 PostPrintToPdfTask();
598 } else if (!select_file_dialog_ || 598 } else if (!select_file_dialog_.get() ||
599 !select_file_dialog_->IsRunning( 599 !select_file_dialog_->IsRunning(platform_util::GetTopLevel(
600 platform_util::GetTopLevel( 600 preview_web_contents()->GetView()->GetNativeView()))) {
601 preview_web_contents()->GetView()->GetNativeView()))) {
602 PrintPreviewUI* print_preview_ui = static_cast<PrintPreviewUI*>( 601 PrintPreviewUI* print_preview_ui = static_cast<PrintPreviewUI*>(
603 web_ui()->GetController()); 602 web_ui()->GetController());
604 // Pre-populating select file dialog with print job title. 603 // Pre-populating select file dialog with print job title.
605 string16 print_job_title_utf16 = print_preview_ui->initiator_tab_title(); 604 string16 print_job_title_utf16 = print_preview_ui->initiator_tab_title();
606 605
607 #if defined(OS_WIN) 606 #if defined(OS_WIN)
608 base::FilePath::StringType print_job_title(print_job_title_utf16); 607 base::FilePath::StringType print_job_title(print_job_title_utf16);
609 #elif defined(OS_POSIX) 608 #elif defined(OS_POSIX)
610 base::FilePath::StringType print_job_title = 609 base::FilePath::StringType print_job_title =
611 UTF16ToUTF8(print_job_title_utf16); 610 UTF16ToUTF8(print_job_title_utf16);
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
702 if (!GetPreviewDataAndTitle(&data, &title)) { 701 if (!GetPreviewDataAndTitle(&data, &title)) {
703 // Nothing to print, no preview available. 702 // Nothing to print, no preview available.
704 return; 703 return;
705 } 704 }
706 705
707 gfx::NativeWindow modal_parent = platform_util::GetTopLevel( 706 gfx::NativeWindow modal_parent = platform_util::GetTopLevel(
708 preview_web_contents()->GetView()->GetNativeView()); 707 preview_web_contents()->GetView()->GetNativeView());
709 print_dialog_cloud::CreatePrintDialogForBytes( 708 print_dialog_cloud::CreatePrintDialogForBytes(
710 preview_web_contents()->GetBrowserContext(), 709 preview_web_contents()->GetBrowserContext(),
711 modal_parent, 710 modal_parent,
712 data, 711 data.get(),
713 title, 712 title,
714 string16(), 713 string16(),
715 std::string("application/pdf")); 714 std::string("application/pdf"));
716 715
717 // Once the cloud print dialog comes up we're no longer in a background 716 // Once the cloud print dialog comes up we're no longer in a background
718 // printing situation. Close the print preview. 717 // printing situation. Close the print preview.
719 // TODO(abodenha@chromium.org) The flow should be changed as described in 718 // TODO(abodenha@chromium.org) The flow should be changed as described in
720 // http://code.google.com/p/chromium/issues/detail?id=44093 719 // http://code.google.com/p/chromium/issues/detail?id=44093
721 ClosePreviewDialog(); 720 ClosePreviewDialog();
722 } 721 }
(...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after
1072 1071
1073 bool PrintPreviewHandler::GetPreviewDataAndTitle( 1072 bool PrintPreviewHandler::GetPreviewDataAndTitle(
1074 scoped_refptr<base::RefCountedBytes>* data, 1073 scoped_refptr<base::RefCountedBytes>* data,
1075 string16* title) const { 1074 string16* title) const {
1076 PrintPreviewUI* print_preview_ui = static_cast<PrintPreviewUI*>( 1075 PrintPreviewUI* print_preview_ui = static_cast<PrintPreviewUI*>(
1077 web_ui()->GetController()); 1076 web_ui()->GetController());
1078 scoped_refptr<base::RefCountedBytes> tmp_data; 1077 scoped_refptr<base::RefCountedBytes> tmp_data;
1079 print_preview_ui->GetPrintPreviewDataForIndex( 1078 print_preview_ui->GetPrintPreviewDataForIndex(
1080 printing::COMPLETE_PREVIEW_DOCUMENT_INDEX, &tmp_data); 1079 printing::COMPLETE_PREVIEW_DOCUMENT_INDEX, &tmp_data);
1081 1080
1082 if (!tmp_data) { 1081 if (!tmp_data.get()) {
1083 // Nothing to print, no preview available. 1082 // Nothing to print, no preview available.
1084 return false; 1083 return false;
1085 } 1084 }
1086 DCHECK(tmp_data->size() && tmp_data->front()); 1085 DCHECK(tmp_data->size() && tmp_data->front());
1087 1086
1088 *data = tmp_data; 1087 *data = tmp_data;
1089 *title = print_preview_ui->initiator_tab_title(); 1088 *title = print_preview_ui->initiator_tab_title();
1090 return true; 1089 return true;
1091 } 1090 }
1092 1091
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/options/options_ui.cc ('k') | chrome/browser/ui/webui/print_preview/print_preview_ui.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698