OLD | NEW |
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 | 8 |
9 #include "base/id_map.h" | 9 #include "base/id_map.h" |
10 #include "base/lazy_instance.h" | 10 #include "base/lazy_instance.h" |
(...skipping 502 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
513 | 513 |
514 if (!initial_preview_start_time_.is_null()) { | 514 if (!initial_preview_start_time_.is_null()) { |
515 UMA_HISTOGRAM_TIMES("PrintPreview.InitialDisplayTime", | 515 UMA_HISTOGRAM_TIMES("PrintPreview.InitialDisplayTime", |
516 base::TimeTicks::Now() - initial_preview_start_time_); | 516 base::TimeTicks::Now() - initial_preview_start_time_); |
517 UMA_HISTOGRAM_COUNTS("PrintPreview.PageCount.Initial", | 517 UMA_HISTOGRAM_COUNTS("PrintPreview.PageCount.Initial", |
518 expected_pages_count); | 518 expected_pages_count); |
519 initial_preview_start_time_ = base::TimeTicks(); | 519 initial_preview_start_time_ = base::TimeTicks(); |
520 } | 520 } |
521 base::FundamentalValue ui_identifier(id_); | 521 base::FundamentalValue ui_identifier(id_); |
522 base::FundamentalValue ui_preview_request_id(preview_request_id); | 522 base::FundamentalValue ui_preview_request_id(preview_request_id); |
523 if (AutoCancelForTesting()) { | 523 web_ui()->CallJavascriptFunction("updatePrintPreview", ui_identifier, |
524 OnClosePrintPreviewDialog(); | 524 ui_preview_request_id); |
525 } else { | |
526 web_ui()->CallJavascriptFunction("updatePrintPreview", ui_identifier, | |
527 ui_preview_request_id); | |
528 } | |
529 } | 525 } |
530 | 526 |
531 void PrintPreviewUI::OnPrintPreviewDialogDestroyed() { | 527 void PrintPreviewUI::OnPrintPreviewDialogDestroyed() { |
532 handler_->OnPrintPreviewDialogDestroyed(); | 528 handler_->OnPrintPreviewDialogDestroyed(); |
533 } | 529 } |
534 | 530 |
535 void PrintPreviewUI::OnFileSelectionCancelled() { | 531 void PrintPreviewUI::OnFileSelectionCancelled() { |
536 web_ui()->CallJavascriptFunction("fileSelectionCancelled"); | 532 web_ui()->CallJavascriptFunction("fileSelectionCancelled"); |
537 } | 533 } |
538 | 534 |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
579 delegate->OnDialogCloseFromWebUI(); | 575 delegate->OnDialogCloseFromWebUI(); |
580 } | 576 } |
581 | 577 |
582 void PrintPreviewUI::OnReloadPrintersList() { | 578 void PrintPreviewUI::OnReloadPrintersList() { |
583 web_ui()->CallJavascriptFunction("reloadPrintersList"); | 579 web_ui()->CallJavascriptFunction("reloadPrintersList"); |
584 } | 580 } |
585 | 581 |
586 void PrintPreviewUI::OnPrintPreviewScalingDisabled() { | 582 void PrintPreviewUI::OnPrintPreviewScalingDisabled() { |
587 web_ui()->CallJavascriptFunction("printScalingDisabledForSourcePDF"); | 583 web_ui()->CallJavascriptFunction("printScalingDisabledForSourcePDF"); |
588 } | 584 } |
589 | |
590 static bool g_auto_cancel_for_testing_ = false; | |
591 | |
592 void PrintPreviewUI::SetAutoCancelForTesting(bool auto_cancel) { | |
593 g_auto_cancel_for_testing_ = auto_cancel; | |
594 } | |
595 | |
596 bool PrintPreviewUI::AutoCancelForTesting() { | |
597 return g_auto_cancel_for_testing_; | |
598 } | |
OLD | NEW |