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

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

Issue 7202012: Print Preview: Display a throbber when the user requests the system print (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Review fix. Created 9 years, 5 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/i18n/file_util_icu.h" 9 #include "base/i18n/file_util_icu.h"
10 #include "base/json/json_reader.h" 10 #include "base/json/json_reader.h"
(...skipping 550 matching lines...) Expand 10 before | Expand all | Expand 10 after
561 printer_name)); 561 printer_name));
562 } 562 }
563 563
564 void PrintPreviewHandler::HandleShowSystemDialog(const ListValue* args) { 564 void PrintPreviewHandler::HandleShowSystemDialog(const ListValue* args) {
565 ReportStats(); 565 ReportStats();
566 ReportUserActionHistogram(FALLBACK_TO_ADVANCED_SETTINGS_DIALOG); 566 ReportUserActionHistogram(FALLBACK_TO_ADVANCED_SETTINGS_DIALOG);
567 567
568 TabContents* initiator_tab = GetInitiatorTab(); 568 TabContents* initiator_tab = GetInitiatorTab();
569 if (!initiator_tab) 569 if (!initiator_tab)
570 return; 570 return;
571 initiator_tab->Activate();
572 571
573 TabContentsWrapper* wrapper = 572 TabContentsWrapper* wrapper =
574 TabContentsWrapper::GetCurrentWrapperForContents(initiator_tab); 573 TabContentsWrapper::GetCurrentWrapperForContents(initiator_tab);
575 wrapper->print_view_manager()->PrintNow(); 574 printing::PrintViewManager* manager = wrapper->print_view_manager();
576 575 manager->set_observer(this);
577 ClosePrintPreviewTab(); 576 manager->PrintNow();
578 } 577 }
579 578
580 void PrintPreviewHandler::HandleManagePrinters(const ListValue* args) { 579 void PrintPreviewHandler::HandleManagePrinters(const ListValue* args) {
581 ++manage_printers_dialog_request_count_; 580 ++manage_printers_dialog_request_count_;
582 printing::PrinterManagerDialog::ShowPrinterManagerDialog(); 581 printing::PrinterManagerDialog::ShowPrinterManagerDialog();
583 } 582 }
584 583
585 void PrintPreviewHandler::HandleClosePreviewTab(const ListValue* args) { 584 void PrintPreviewHandler::HandleClosePreviewTab(const ListValue* args) {
586 ReportStats(); 585 ReportStats();
587 ReportUserActionHistogram(CANCEL); 586 ReportUserActionHistogram(CANCEL);
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
640 if (!preview_tab_browser) 639 if (!preview_tab_browser)
641 return; 640 return;
642 TabStripModel* tabstrip = preview_tab_browser->tabstrip_model(); 641 TabStripModel* tabstrip = preview_tab_browser->tabstrip_model();
643 642
644 // Keep print preview tab out of the recently closed tab list, because 643 // Keep print preview tab out of the recently closed tab list, because
645 // re-opening that page will just display a non-functional print preview page. 644 // re-opening that page will just display a non-functional print preview page.
646 tabstrip->CloseTabContentsAt(tabstrip->GetIndexOfController( 645 tabstrip->CloseTabContentsAt(tabstrip->GetIndexOfController(
647 &preview_tab()->controller()), TabStripModel::CLOSE_NONE); 646 &preview_tab()->controller()), TabStripModel::CLOSE_NONE);
648 } 647 }
649 648
649 void PrintPreviewHandler::OnPrintDialogShown() {
650 TabContents* initiator_tab = GetInitiatorTab();
651 DCHECK(initiator_tab);
652
653 initiator_tab->Activate();
654 ClosePrintPreviewTab();
655 }
656
650 void PrintPreviewHandler::SelectFile(const FilePath& default_filename) { 657 void PrintPreviewHandler::SelectFile(const FilePath& default_filename) {
651 SelectFileDialog::FileTypeInfo file_type_info; 658 SelectFileDialog::FileTypeInfo file_type_info;
652 file_type_info.extensions.resize(1); 659 file_type_info.extensions.resize(1);
653 file_type_info.extensions[0].push_back(FILE_PATH_LITERAL("pdf")); 660 file_type_info.extensions[0].push_back(FILE_PATH_LITERAL("pdf"));
654 661
655 // Initializing last_saved_path_ if it is not already initialized. 662 // Initializing last_saved_path_ if it is not already initialized.
656 if (!last_saved_path_) { 663 if (!last_saved_path_) {
657 last_saved_path_ = new FilePath(); 664 last_saved_path_ = new FilePath();
658 // Allowing IO operation temporarily. It is ok to do so here because 665 // Allowing IO operation temporarily. It is ok to do so here because
659 // the select file dialog performs IO anyway in order to display the 666 // the select file dialog performs IO anyway in order to display the
(...skipping 10 matching lines...) Expand all
670 string16(), 677 string16(),
671 last_saved_path_->Append(default_filename), 678 last_saved_path_->Append(default_filename),
672 &file_type_info, 679 &file_type_info,
673 0, 680 0,
674 FILE_PATH_LITERAL(""), 681 FILE_PATH_LITERAL(""),
675 preview_tab(), 682 preview_tab(),
676 platform_util::GetTopLevel(preview_tab()->GetNativeView()), 683 platform_util::GetTopLevel(preview_tab()->GetNativeView()),
677 NULL); 684 NULL);
678 } 685 }
679 686
687 void PrintPreviewHandler::OnNavigation() {
688 TabContents* initiator_tab = GetInitiatorTab();
689 if (!initiator_tab)
690 return;
691
692 TabContentsWrapper* wrapper =
693 TabContentsWrapper::GetCurrentWrapperForContents(initiator_tab);
694 wrapper->print_view_manager()->set_observer(NULL);
695 }
696
680 void PrintPreviewHandler::FileSelected(const FilePath& path, 697 void PrintPreviewHandler::FileSelected(const FilePath& path,
681 int index, void* params) { 698 int index, void* params) {
682 PrintPreviewUI* print_preview_ui = static_cast<PrintPreviewUI*>(web_ui_); 699 PrintPreviewUI* print_preview_ui = static_cast<PrintPreviewUI*>(web_ui_);
683 scoped_refptr<RefCountedBytes> data(new RefCountedBytes()); 700 scoped_refptr<RefCountedBytes> data(new RefCountedBytes());
684 print_preview_ui->GetPrintPreviewData(&data); 701 print_preview_ui->GetPrintPreviewData(&data);
685 if (!data->front()) { 702 if (!data->front()) {
686 NOTREACHED(); 703 NOTREACHED();
687 return; 704 return;
688 } 705 }
689 706
(...skipping 17 matching lines...) Expand all
707 void PrintPreviewHandler::HidePreviewTab() { 724 void PrintPreviewHandler::HidePreviewTab() {
708 TabContentsWrapper* preview_tab_wrapper = 725 TabContentsWrapper* preview_tab_wrapper =
709 TabContentsWrapper::GetCurrentWrapperForContents(preview_tab()); 726 TabContentsWrapper::GetCurrentWrapperForContents(preview_tab());
710 if (GetBackgroundPrintingManager()->HasTabContents(preview_tab_wrapper)) 727 if (GetBackgroundPrintingManager()->HasTabContents(preview_tab_wrapper))
711 return; 728 return;
712 GetBackgroundPrintingManager()->OwnTabContents(preview_tab_wrapper); 729 GetBackgroundPrintingManager()->OwnTabContents(preview_tab_wrapper);
713 } 730 }
714 731
715 void PrintPreviewHandler::ClearInitiatorTabDetails() { 732 void PrintPreviewHandler::ClearInitiatorTabDetails() {
716 TabContents* initiator_tab = GetInitiatorTab(); 733 TabContents* initiator_tab = GetInitiatorTab();
717 if (initiator_tab) { 734 if (!initiator_tab)
718 // We no longer require the intiator tab details. Remove those details 735 return;
719 // associated with the preview tab to allow the initiator tab to create 736
720 // another preview tab. 737 // We no longer require the initiator tab details. Remove those details
721 printing::PrintPreviewTabController* tab_controller = 738 // associated with the preview tab to allow the initiator tab to create
722 printing::PrintPreviewTabController::GetInstance(); 739 // another preview tab.
723 if (tab_controller) 740 printing::PrintPreviewTabController* tab_controller =
724 tab_controller->EraseInitiatorTabInfo(preview_tab()); 741 printing::PrintPreviewTabController::GetInstance();
725 } 742 if (tab_controller)
743 tab_controller->EraseInitiatorTabInfo(preview_tab());
726 } 744 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/print_preview_handler.h ('k') | chrome/browser/ui/webui/print_preview_ui.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698