| 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 500 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 511 base::FundamentalValue ui_identifier(id_); | 511 base::FundamentalValue ui_identifier(id_); |
| 512 base::FundamentalValue request_id(preview_request_id); | 512 base::FundamentalValue request_id(preview_request_id); |
| 513 if (g_testing_delegate) | 513 if (g_testing_delegate) |
| 514 g_testing_delegate->DidRenderPreviewPage(*web_ui()->GetWebContents()); | 514 g_testing_delegate->DidRenderPreviewPage(*web_ui()->GetWebContents()); |
| 515 web_ui()->CallJavascriptFunction( | 515 web_ui()->CallJavascriptFunction( |
| 516 "onDidPreviewPage", number, ui_identifier, request_id); | 516 "onDidPreviewPage", number, ui_identifier, request_id); |
| 517 if (g_testing_delegate && g_testing_delegate->IsAutoCancelEnabled()) | 517 if (g_testing_delegate && g_testing_delegate->IsAutoCancelEnabled()) |
| 518 web_ui()->CallJavascriptFunction("autoCancelForTesting"); | 518 web_ui()->CallJavascriptFunction("autoCancelForTesting"); |
| 519 } | 519 } |
| 520 | 520 |
| 521 void PrintPreviewUI::OnReusePreviewData(int preview_request_id) { | |
| 522 base::FundamentalValue ui_identifier(id_); | |
| 523 base::FundamentalValue ui_preview_request_id(preview_request_id); | |
| 524 web_ui()->CallJavascriptFunction("reloadPreviewPages", ui_identifier, | |
| 525 ui_preview_request_id); | |
| 526 } | |
| 527 | |
| 528 void PrintPreviewUI::OnPreviewDataIsAvailable(int expected_pages_count, | 521 void PrintPreviewUI::OnPreviewDataIsAvailable(int expected_pages_count, |
| 529 int preview_request_id) { | 522 int preview_request_id) { |
| 530 VLOG(1) << "Print preview request finished with " | 523 VLOG(1) << "Print preview request finished with " |
| 531 << expected_pages_count << " pages"; | 524 << expected_pages_count << " pages"; |
| 532 | 525 |
| 533 if (!initial_preview_start_time_.is_null()) { | 526 if (!initial_preview_start_time_.is_null()) { |
| 534 UMA_HISTOGRAM_TIMES("PrintPreview.InitialDisplayTime", | 527 UMA_HISTOGRAM_TIMES("PrintPreview.InitialDisplayTime", |
| 535 base::TimeTicks::Now() - initial_preview_start_time_); | 528 base::TimeTicks::Now() - initial_preview_start_time_); |
| 536 UMA_HISTOGRAM_COUNTS("PrintPreview.PageCount.Initial", | 529 UMA_HISTOGRAM_COUNTS("PrintPreview.PageCount.Initial", |
| 537 expected_pages_count); | 530 expected_pages_count); |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 599 } | 592 } |
| 600 | 593 |
| 601 void PrintPreviewUI::OnPrintPreviewScalingDisabled() { | 594 void PrintPreviewUI::OnPrintPreviewScalingDisabled() { |
| 602 web_ui()->CallJavascriptFunction("printScalingDisabledForSourcePDF"); | 595 web_ui()->CallJavascriptFunction("printScalingDisabledForSourcePDF"); |
| 603 } | 596 } |
| 604 | 597 |
| 605 // static | 598 // static |
| 606 void PrintPreviewUI::SetDelegateForTesting(TestingDelegate* delegate) { | 599 void PrintPreviewUI::SetDelegateForTesting(TestingDelegate* delegate) { |
| 607 g_testing_delegate = delegate; | 600 g_testing_delegate = delegate; |
| 608 } | 601 } |
| OLD | NEW |