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

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

Issue 2962983002: Print Preview: change getPreview to cr.sendWithPromise (Closed)
Patch Set: Rebase Created 3 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
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_ui.h" 5 #include "chrome/browser/ui/webui/print_preview/print_preview_ui.h"
6 6
7 #include <map> 7 #include <map>
8 #include <memory> 8 #include <memory>
9 #include <utility> 9 #include <utility>
10 #include <vector> 10 #include <vector>
(...skipping 601 matching lines...) Expand 10 before | Expand all | Expand 10 after
612 if (!initial_preview_start_time_.is_null()) { 612 if (!initial_preview_start_time_.is_null()) {
613 UMA_HISTOGRAM_TIMES("PrintPreview.InitialDisplayTime", 613 UMA_HISTOGRAM_TIMES("PrintPreview.InitialDisplayTime",
614 base::TimeTicks::Now() - initial_preview_start_time_); 614 base::TimeTicks::Now() - initial_preview_start_time_);
615 UMA_HISTOGRAM_COUNTS("PrintPreview.PageCount.Initial", 615 UMA_HISTOGRAM_COUNTS("PrintPreview.PageCount.Initial",
616 expected_pages_count); 616 expected_pages_count);
617 UMA_HISTOGRAM_COUNTS( 617 UMA_HISTOGRAM_COUNTS(
618 "PrintPreview.RegeneratePreviewRequest.BeforeFirstData", 618 "PrintPreview.RegeneratePreviewRequest.BeforeFirstData",
619 handler_->regenerate_preview_request_count()); 619 handler_->regenerate_preview_request_count());
620 initial_preview_start_time_ = base::TimeTicks(); 620 initial_preview_start_time_ = base::TimeTicks();
621 } 621 }
622 base::Value ui_identifier(id_); 622 handler_->OnPrintPreviewReady(id_, preview_request_id);
623 base::Value ui_preview_request_id(preview_request_id);
624 web_ui()->CallJavascriptFunctionUnsafe("updatePrintPreview", ui_identifier,
625 ui_preview_request_id);
626 } 623 }
627 624
628 void PrintPreviewUI::OnCancelPendingPreviewRequest() { 625 void PrintPreviewUI::OnCancelPendingPreviewRequest() {
629 g_print_preview_request_id_map.Get().Set(id_, -1); 626 g_print_preview_request_id_map.Get().Set(id_, -1);
630 } 627 }
631 628
632 void PrintPreviewUI::OnPrintPreviewFailed() { 629 void PrintPreviewUI::OnPrintPreviewFailed(int request_id) {
633 handler_->OnPrintPreviewFailed(); 630 handler_->OnPrintPreviewFailed(request_id);
634 web_ui()->CallJavascriptFunctionUnsafe("printPreviewFailed");
635 } 631 }
636 632
637 void PrintPreviewUI::OnInvalidPrinterSettings() { 633 void PrintPreviewUI::OnInvalidPrinterSettings(int request_id) {
638 web_ui()->CallJavascriptFunctionUnsafe("invalidPrinterSettings"); 634 handler_->OnInvalidPrinterSettings(request_id);
639 } 635 }
640 636
641 void PrintPreviewUI::OnHidePreviewDialog() { 637 void PrintPreviewUI::OnHidePreviewDialog() {
642 WebContents* preview_dialog = web_ui()->GetWebContents(); 638 WebContents* preview_dialog = web_ui()->GetWebContents();
643 printing::BackgroundPrintingManager* background_printing_manager = 639 printing::BackgroundPrintingManager* background_printing_manager =
644 g_browser_process->background_printing_manager(); 640 g_browser_process->background_printing_manager();
645 if (background_printing_manager->HasPrintPreviewDialog(preview_dialog)) 641 if (background_printing_manager->HasPrintPreviewDialog(preview_dialog))
646 return; 642 return;
647 643
648 ConstrainedWebDialogDelegate* delegate = GetConstrainedDelegate(); 644 ConstrainedWebDialogDelegate* delegate = GetConstrainedDelegate();
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
688 } 684 }
689 685
690 void PrintPreviewUI::SetSelectedFileForTesting(const base::FilePath& path) { 686 void PrintPreviewUI::SetSelectedFileForTesting(const base::FilePath& path) {
691 handler_->FileSelected(path, 0, NULL); 687 handler_->FileSelected(path, 0, NULL);
692 } 688 }
693 689
694 void PrintPreviewUI::SetPdfSavedClosureForTesting( 690 void PrintPreviewUI::SetPdfSavedClosureForTesting(
695 const base::Closure& closure) { 691 const base::Closure& closure) {
696 handler_->SetPdfSavedClosureForTesting(closure); 692 handler_->SetPdfSavedClosureForTesting(closure);
697 } 693 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698