| 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 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/id_map.h" | 10 #include "base/id_map.h" |
| (...skipping 30 matching lines...) Expand all Loading... |
| 41 #include "ui/web_dialogs/web_dialog_delegate.h" | 41 #include "ui/web_dialogs/web_dialog_delegate.h" |
| 42 #include "ui/web_dialogs/web_dialog_ui.h" | 42 #include "ui/web_dialogs/web_dialog_ui.h" |
| 43 | 43 |
| 44 using content::WebContents; | 44 using content::WebContents; |
| 45 using printing::PageSizeMargins; | 45 using printing::PageSizeMargins; |
| 46 | 46 |
| 47 namespace { | 47 namespace { |
| 48 | 48 |
| 49 #if defined(OS_MACOSX) | 49 #if defined(OS_MACOSX) |
| 50 // U+0028 U+21E7 U+2318 U+0050 U+0029 in UTF8 | 50 // U+0028 U+21E7 U+2318 U+0050 U+0029 in UTF8 |
| 51 const char kAdvancedPrintShortcut[] = "\x28\xE2\x8c\xA5\xE2\x8C\x98\x50\x29"; | 51 const char kBasicPrintShortcut[] = "\x28\xE2\x8c\xA5\xE2\x8C\x98\x50\x29"; |
| 52 #elif defined(OS_WIN) || defined(OS_CHROMEOS) | 52 #elif defined(OS_WIN) || defined(OS_CHROMEOS) |
| 53 const char kAdvancedPrintShortcut[] = "(Ctrl+Shift+P)"; | 53 const char kBasicPrintShortcut[] = "(Ctrl+Shift+P)"; |
| 54 #else | 54 #else |
| 55 const char kAdvancedPrintShortcut[] = "(Shift+Ctrl+P)"; | 55 const char kBasicPrintShortcut[] = "(Shift+Ctrl+P)"; |
| 56 #endif | 56 #endif |
| 57 | 57 |
| 58 // Thread-safe wrapper around a std::map to keep track of mappings from | 58 // Thread-safe wrapper around a std::map to keep track of mappings from |
| 59 // PrintPreviewUI IDs to most recent print preview request IDs. | 59 // PrintPreviewUI IDs to most recent print preview request IDs. |
| 60 class PrintPreviewRequestIdMapWithLock { | 60 class PrintPreviewRequestIdMapWithLock { |
| 61 public: | 61 public: |
| 62 PrintPreviewRequestIdMapWithLock() {} | 62 PrintPreviewRequestIdMapWithLock() {} |
| 63 ~PrintPreviewRequestIdMapWithLock() {} | 63 ~PrintPreviewRequestIdMapWithLock() {} |
| 64 | 64 |
| 65 // Gets the value for |preview_id|. | 65 // Gets the value for |preview_id|. |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 204 source->AddLocalizedString("printPreviewSummaryFormatLong", | 204 source->AddLocalizedString("printPreviewSummaryFormatLong", |
| 205 IDS_PRINT_PREVIEW_SUMMARY_FORMAT_LONG); | 205 IDS_PRINT_PREVIEW_SUMMARY_FORMAT_LONG); |
| 206 source->AddLocalizedString("printPreviewSheetsLabelSingular", | 206 source->AddLocalizedString("printPreviewSheetsLabelSingular", |
| 207 IDS_PRINT_PREVIEW_SHEETS_LABEL_SINGULAR); | 207 IDS_PRINT_PREVIEW_SHEETS_LABEL_SINGULAR); |
| 208 source->AddLocalizedString("printPreviewSheetsLabelPlural", | 208 source->AddLocalizedString("printPreviewSheetsLabelPlural", |
| 209 IDS_PRINT_PREVIEW_SHEETS_LABEL_PLURAL); | 209 IDS_PRINT_PREVIEW_SHEETS_LABEL_PLURAL); |
| 210 source->AddLocalizedString("printPreviewPageLabelSingular", | 210 source->AddLocalizedString("printPreviewPageLabelSingular", |
| 211 IDS_PRINT_PREVIEW_PAGE_LABEL_SINGULAR); | 211 IDS_PRINT_PREVIEW_PAGE_LABEL_SINGULAR); |
| 212 source->AddLocalizedString("printPreviewPageLabelPlural", | 212 source->AddLocalizedString("printPreviewPageLabelPlural", |
| 213 IDS_PRINT_PREVIEW_PAGE_LABEL_PLURAL); | 213 IDS_PRINT_PREVIEW_PAGE_LABEL_PLURAL); |
| 214 const base::string16 shortcut_text(base::UTF8ToUTF16(kAdvancedPrintShortcut)); | 214 const base::string16 shortcut_text(base::UTF8ToUTF16(kBasicPrintShortcut)); |
| 215 #if defined(OS_CHROMEOS) | 215 #if defined(OS_CHROMEOS) |
| 216 source->AddString( | 216 source->AddString( |
| 217 "systemDialogOption", | 217 "systemDialogOption", |
| 218 l10n_util::GetStringFUTF16( | 218 l10n_util::GetStringFUTF16( |
| 219 IDS_PRINT_PREVIEW_CLOUD_DIALOG_OPTION, | 219 IDS_PRINT_PREVIEW_CLOUD_DIALOG_OPTION, |
| 220 l10n_util::GetStringUTF16(IDS_GOOGLE_CLOUD_PRINT), | 220 l10n_util::GetStringUTF16(IDS_GOOGLE_CLOUD_PRINT), |
| 221 shortcut_text)); | 221 shortcut_text)); |
| 222 #else | 222 #else |
| 223 source->AddString( | 223 source->AddString( |
| 224 "systemDialogOption", | 224 "systemDialogOption", |
| (...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 477 } | 477 } |
| 478 | 478 |
| 479 void PrintPreviewUI::OnPrintPreviewRequest(int request_id) { | 479 void PrintPreviewUI::OnPrintPreviewRequest(int request_id) { |
| 480 if (!initial_preview_start_time_.is_null()) { | 480 if (!initial_preview_start_time_.is_null()) { |
| 481 UMA_HISTOGRAM_TIMES("PrintPreview.InitializationTime", | 481 UMA_HISTOGRAM_TIMES("PrintPreview.InitializationTime", |
| 482 base::TimeTicks::Now() - initial_preview_start_time_); | 482 base::TimeTicks::Now() - initial_preview_start_time_); |
| 483 } | 483 } |
| 484 g_print_preview_request_id_map.Get().Set(id_, request_id); | 484 g_print_preview_request_id_map.Get().Set(id_, request_id); |
| 485 } | 485 } |
| 486 | 486 |
| 487 #if !defined(DISABLE_BASIC_PRINTING) |
| 487 void PrintPreviewUI::OnShowSystemDialog() { | 488 void PrintPreviewUI::OnShowSystemDialog() { |
| 488 web_ui()->CallJavascriptFunction("onSystemDialogLinkClicked"); | 489 web_ui()->CallJavascriptFunction("onSystemDialogLinkClicked"); |
| 489 } | 490 } |
| 491 #endif // !DISABLE_BASIC_PRINTING |
| 490 | 492 |
| 491 void PrintPreviewUI::OnDidGetPreviewPageCount( | 493 void PrintPreviewUI::OnDidGetPreviewPageCount( |
| 492 const PrintHostMsg_DidGetPreviewPageCount_Params& params) { | 494 const PrintHostMsg_DidGetPreviewPageCount_Params& params) { |
| 493 DCHECK_GT(params.page_count, 0); | 495 DCHECK_GT(params.page_count, 0); |
| 494 if (g_testing_delegate) | 496 if (g_testing_delegate) |
| 495 g_testing_delegate->DidGetPreviewPageCount(params.page_count); | 497 g_testing_delegate->DidGetPreviewPageCount(params.page_count); |
| 496 base::FundamentalValue count(params.page_count); | 498 base::FundamentalValue count(params.page_count); |
| 497 base::FundamentalValue request_id(params.preview_request_id); | 499 base::FundamentalValue request_id(params.preview_request_id); |
| 498 web_ui()->CallJavascriptFunction("onDidGetPreviewPageCount", | 500 web_ui()->CallJavascriptFunction("onDidGetPreviewPageCount", |
| 499 count, | 501 count, |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 633 } | 635 } |
| 634 | 636 |
| 635 void PrintPreviewUI::SetSelectedFileForTesting(const base::FilePath& path) { | 637 void PrintPreviewUI::SetSelectedFileForTesting(const base::FilePath& path) { |
| 636 handler_->FileSelected(path, 0, NULL); | 638 handler_->FileSelected(path, 0, NULL); |
| 637 } | 639 } |
| 638 | 640 |
| 639 void PrintPreviewUI::SetPdfSavedClosureForTesting( | 641 void PrintPreviewUI::SetPdfSavedClosureForTesting( |
| 640 const base::Closure& closure) { | 642 const base::Closure& closure) { |
| 641 handler_->SetPdfSavedClosureForTesting(closure); | 643 handler_->SetPdfSavedClosureForTesting(closure); |
| 642 } | 644 } |
| OLD | NEW |