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

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: Rebase and add missing file. Created 9 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) 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 534 matching lines...) Expand 10 before | Expand all | Expand 10 after
545 printer_name)); 545 printer_name));
546 } 546 }
547 547
548 void PrintPreviewHandler::HandleShowSystemDialog(const ListValue* args) { 548 void PrintPreviewHandler::HandleShowSystemDialog(const ListValue* args) {
549 ReportStats(); 549 ReportStats();
550 ReportUserActionHistogram(FALLBACK_TO_ADVANCED_SETTINGS_DIALOG); 550 ReportUserActionHistogram(FALLBACK_TO_ADVANCED_SETTINGS_DIALOG);
551 551
552 TabContents* initiator_tab = GetInitiatorTab(); 552 TabContents* initiator_tab = GetInitiatorTab();
553 if (!initiator_tab) 553 if (!initiator_tab)
554 return; 554 return;
555 initiator_tab->Activate();
556 555
557 TabContentsWrapper* wrapper = 556 TabContentsWrapper* wrapper =
558 TabContentsWrapper::GetCurrentWrapperForContents(initiator_tab); 557 TabContentsWrapper::GetCurrentWrapperForContents(initiator_tab);
559 wrapper->print_view_manager()->PrintNow(); 558 wrapper->print_view_manager()->PrintNow(this);
560
561 ClosePrintPreviewTab();
562 } 559 }
563 560
564 void PrintPreviewHandler::HandleManagePrinters(const ListValue* args) { 561 void PrintPreviewHandler::HandleManagePrinters(const ListValue* args) {
565 ++manage_printers_dialog_request_count_; 562 ++manage_printers_dialog_request_count_;
566 printing::PrinterManagerDialog::ShowPrinterManagerDialog(); 563 printing::PrinterManagerDialog::ShowPrinterManagerDialog();
567 } 564 }
568 565
569 void PrintPreviewHandler::HandleClosePreviewTab(const ListValue* args) { 566 void PrintPreviewHandler::HandleClosePreviewTab(const ListValue* args) {
570 ReportStats(); 567 ReportStats();
571 ReportUserActionHistogram(CANCEL); 568 ReportUserActionHistogram(CANCEL);
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
624 if (!preview_tab_browser) 621 if (!preview_tab_browser)
625 return; 622 return;
626 TabStripModel* tabstrip = preview_tab_browser->tabstrip_model(); 623 TabStripModel* tabstrip = preview_tab_browser->tabstrip_model();
627 624
628 // Keep print preview tab out of the recently closed tab list, because 625 // Keep print preview tab out of the recently closed tab list, because
629 // re-opening that page will just display a non-functional print preview page. 626 // re-opening that page will just display a non-functional print preview page.
630 tabstrip->CloseTabContentsAt(tabstrip->GetIndexOfController( 627 tabstrip->CloseTabContentsAt(tabstrip->GetIndexOfController(
631 &preview_tab()->controller()), TabStripModel::CLOSE_NONE); 628 &preview_tab()->controller()), TabStripModel::CLOSE_NONE);
632 } 629 }
633 630
631 void PrintPreviewHandler::OnPrintDialogShown() {
632 TabContents* initiator_tab = GetInitiatorTab();
633 if (!initiator_tab)
Lei Zhang 2011/06/21 01:54:46 FWIW, I don't think is can happen.
James Hawkins 2011/06/22 23:47:24 It can (just tested).
Lei Zhang 2011/06/23 17:08:45 How?
James Hawkins 2011/06/27 21:58:17 Just tested again and it's now not possible, thoug
634 return;
635
636 initiator_tab->Activate();
637 ClosePrintPreviewTab();
638 }
639
634 void PrintPreviewHandler::SelectFile(const FilePath& default_filename) { 640 void PrintPreviewHandler::SelectFile(const FilePath& default_filename) {
635 SelectFileDialog::FileTypeInfo file_type_info; 641 SelectFileDialog::FileTypeInfo file_type_info;
636 file_type_info.extensions.resize(1); 642 file_type_info.extensions.resize(1);
637 file_type_info.extensions[0].push_back(FILE_PATH_LITERAL("pdf")); 643 file_type_info.extensions[0].push_back(FILE_PATH_LITERAL("pdf"));
638 644
639 // Initializing last_saved_path_ if it is not already initialized. 645 // Initializing last_saved_path_ if it is not already initialized.
640 if (!last_saved_path_) { 646 if (!last_saved_path_) {
641 last_saved_path_ = new FilePath(); 647 last_saved_path_ = new FilePath();
642 // Allowing IO operation temporarily. It is ok to do so here because 648 // Allowing IO operation temporarily. It is ok to do so here because
643 // the select file dialog performs IO anyway in order to display the 649 // the select file dialog performs IO anyway in order to display the
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
701 if (initiator_tab) { 707 if (initiator_tab) {
702 // We no longer require the intiator tab details. Remove those details 708 // We no longer require the intiator tab details. Remove those details
703 // associated with the preview tab to allow the initiator tab to create 709 // associated with the preview tab to allow the initiator tab to create
704 // another preview tab. 710 // another preview tab.
705 printing::PrintPreviewTabController* tab_controller = 711 printing::PrintPreviewTabController* tab_controller =
706 printing::PrintPreviewTabController::GetInstance(); 712 printing::PrintPreviewTabController::GetInstance();
707 if (tab_controller) 713 if (tab_controller)
708 tab_controller->EraseInitiatorTabInfo(preview_tab()); 714 tab_controller->EraseInitiatorTabInfo(preview_tab());
709 } 715 }
710 } 716 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698