| OLD | NEW |
| 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_ui.h" | 5 #include "chrome/browser/ui/webui/print_preview_ui.h" |
| 6 | 6 |
| 7 #include "base/metrics/histogram.h" | 7 #include "base/metrics/histogram.h" |
| 8 #include "base/string_util.h" | 8 #include "base/string_util.h" |
| 9 #include "base/values.h" | 9 #include "base/values.h" |
| 10 #include "chrome/browser/printing/print_preview_data_service.h" | 10 #include "chrome/browser/printing/print_preview_data_service.h" |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 61 } | 61 } |
| 62 | 62 |
| 63 void PrintPreviewUI::OnDidPreviewPage(int page_number) { | 63 void PrintPreviewUI::OnDidPreviewPage(int page_number) { |
| 64 DCHECK_GE(page_number, 0); | 64 DCHECK_GE(page_number, 0); |
| 65 FundamentalValue number(page_number); | 65 FundamentalValue number(page_number); |
| 66 CallJavascriptFunction("onDidPreviewPage", number); | 66 CallJavascriptFunction("onDidPreviewPage", number); |
| 67 } | 67 } |
| 68 | 68 |
| 69 void PrintPreviewUI::OnPreviewDataIsAvailable(int expected_pages_count, | 69 void PrintPreviewUI::OnPreviewDataIsAvailable(int expected_pages_count, |
| 70 const string16& job_title, | 70 const string16& job_title, |
| 71 bool modifiable) { | 71 bool modifiable, |
| 72 int preview_request_id) { |
| 72 VLOG(1) << "Print preview request finished with " | 73 VLOG(1) << "Print preview request finished with " |
| 73 << expected_pages_count << " pages"; | 74 << expected_pages_count << " pages"; |
| 74 DecrementRequestCount(); | 75 DecrementRequestCount(); |
| 75 | 76 |
| 76 if (!initial_preview_start_time_.is_null()) { | 77 if (!initial_preview_start_time_.is_null()) { |
| 77 UMA_HISTOGRAM_TIMES("PrintPreview.InitalDisplayTime", | 78 UMA_HISTOGRAM_TIMES("PrintPreview.InitalDisplayTime", |
| 78 base::TimeTicks::Now() - initial_preview_start_time_); | 79 base::TimeTicks::Now() - initial_preview_start_time_); |
| 79 UMA_HISTOGRAM_COUNTS("PrintPreview.PageCount.Initial", | 80 UMA_HISTOGRAM_COUNTS("PrintPreview.PageCount.Initial", |
| 80 expected_pages_count); | 81 expected_pages_count); |
| 81 initial_preview_start_time_ = base::TimeTicks(); | 82 initial_preview_start_time_ = base::TimeTicks(); |
| 82 } | 83 } |
| 83 FundamentalValue pages_count(expected_pages_count); | 84 FundamentalValue pages_count(expected_pages_count); |
| 84 StringValue title(job_title); | 85 StringValue title(job_title); |
| 85 FundamentalValue is_preview_modifiable(modifiable); | 86 FundamentalValue is_preview_modifiable(modifiable); |
| 86 StringValue ui_identifier(preview_ui_addr_str_); | 87 StringValue ui_identifier(preview_ui_addr_str_); |
| 88 FundamentalValue ui_preview_request_id(preview_request_id); |
| 87 CallJavascriptFunction("updatePrintPreview", title, is_preview_modifiable, | 89 CallJavascriptFunction("updatePrintPreview", title, is_preview_modifiable, |
| 88 ui_identifier); | 90 ui_identifier, ui_preview_request_id); |
| 89 } | 91 } |
| 90 | 92 |
| 91 void PrintPreviewUI::OnNavigation() { | 93 void PrintPreviewUI::OnNavigation() { |
| 92 handler_->OnNavigation(); | 94 handler_->OnNavigation(); |
| 93 } | 95 } |
| 94 | 96 |
| 95 void PrintPreviewUI::OnFileSelectionCancelled() { | 97 void PrintPreviewUI::OnFileSelectionCancelled() { |
| 96 CallJavascriptFunction("fileSelectionCancelled"); | 98 CallJavascriptFunction("fileSelectionCancelled"); |
| 97 } | 99 } |
| 98 | 100 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 111 | 113 |
| 112 PrintPreviewDataService* PrintPreviewUI::print_preview_data_service() { | 114 PrintPreviewDataService* PrintPreviewUI::print_preview_data_service() { |
| 113 return PrintPreviewDataService::GetInstance(); | 115 return PrintPreviewDataService::GetInstance(); |
| 114 } | 116 } |
| 115 | 117 |
| 116 void PrintPreviewUI::DecrementRequestCount() { | 118 void PrintPreviewUI::DecrementRequestCount() { |
| 117 DCHECK_GT(request_count_, 0U); | 119 DCHECK_GT(request_count_, 0U); |
| 118 if (request_count_ > 0) | 120 if (request_count_ > 0) |
| 119 request_count_--; | 121 request_count_--; |
| 120 } | 122 } |
| OLD | NEW |