Chromium Code Reviews| 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_data_source.h" | 5 #include "chrome/browser/ui/webui/print_preview_data_source.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
| 10 #include "base/string_number_conversions.h" | 10 #include "base/string_number_conversions.h" |
| 11 #include "base/string_piece.h" | 11 #include "base/string_piece.h" |
| 12 #include "base/string_split.h" | 12 #include "base/string_split.h" |
| 13 #include "base/string_util.h" | 13 #include "base/string_util.h" |
| 14 #include "base/utf_string_conversions.h" | 14 #include "base/utf_string_conversions.h" |
| 15 #include "base/values.h" | 15 #include "base/values.h" |
| 16 #include "chrome/browser/printing/print_preview_data_service.h" | 16 #include "chrome/browser/printing/print_preview_data_service.h" |
| 17 #include "chrome/common/jstemplate_builder.h" | 17 #include "chrome/common/jstemplate_builder.h" |
| 18 #include "chrome/common/url_constants.h" | 18 #include "chrome/common/url_constants.h" |
| 19 #include "grit/browser_resources.h" | 19 #include "grit/browser_resources.h" |
| 20 #include "grit/chromium_strings.h" | 20 #include "grit/chromium_strings.h" |
| 21 #include "grit/generated_resources.h" | 21 #include "grit/generated_resources.h" |
| 22 #include "grit/google_chrome_strings.h" | 22 #include "grit/google_chrome_strings.h" |
| 23 #include "ui/base/l10n/l10n_util.h" | 23 #include "ui/base/l10n/l10n_util.h" |
| 24 #include "ui/base/resource/resource_bundle.h" | 24 #include "ui/base/resource/resource_bundle.h" |
| 25 | 25 |
| 26 namespace{ | |
| 27 | |
| 28 #if defined(OS_MACOSX) | |
| 29 // U+0028 U+21E7 U+2318 U+0050 U+0029 in UTF8 | |
| 30 const char kAdvancedPrintShortcut[] = "\x28\xE2\x8C\x98\xE2\x87\xA7\x50\x29"; | |
| 31 #elif defined(OS_WIN) | |
| 32 const char kAdvancedPrintShortcut[] = "(Ctrl+Shift+P)"; | |
| 33 #else | |
| 34 const char kAdvancedPrintShortcut[] = "(Shift+Ctrl+P)"; | |
| 35 #endif | |
| 36 | |
| 37 }; // namespace | |
| 38 | |
| 26 PrintPreviewDataSource::PrintPreviewDataSource() | 39 PrintPreviewDataSource::PrintPreviewDataSource() |
| 27 : ChromeWebUIDataSource(chrome::kChromeUIPrintHost) { | 40 : ChromeWebUIDataSource(chrome::kChromeUIPrintHost) { |
| 28 | 41 |
| 29 AddLocalizedString("title", IDS_PRINT_PREVIEW_TITLE); | 42 AddLocalizedString("title", IDS_PRINT_PREVIEW_TITLE); |
| 30 AddLocalizedString("loading", IDS_PRINT_PREVIEW_LOADING); | 43 AddLocalizedString("loading", IDS_PRINT_PREVIEW_LOADING); |
| 31 #if defined(GOOGLE_CHROME_BUILD) | 44 #if defined(GOOGLE_CHROME_BUILD) |
| 32 AddString("noPlugin", l10n_util::GetStringFUTF16( | 45 AddString("noPlugin", l10n_util::GetStringFUTF16( |
| 33 IDS_PRINT_PREVIEW_NO_PLUGIN, ASCIIToUTF16("chrome://plugins/"))); | 46 IDS_PRINT_PREVIEW_NO_PLUGIN, ASCIIToUTF16("chrome://plugins/"))); |
| 34 #else | 47 #else |
| 35 AddLocalizedString("noPlugin", IDS_PRINT_PREVIEW_NO_PLUGIN); | 48 AddLocalizedString("noPlugin", IDS_PRINT_PREVIEW_NO_PLUGIN); |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 70 AddLocalizedString("printPreviewSummaryFormatLong", | 83 AddLocalizedString("printPreviewSummaryFormatLong", |
| 71 IDS_PRINT_PREVIEW_SUMMARY_FORMAT_LONG); | 84 IDS_PRINT_PREVIEW_SUMMARY_FORMAT_LONG); |
| 72 AddLocalizedString("printPreviewSheetsLabelSingular", | 85 AddLocalizedString("printPreviewSheetsLabelSingular", |
| 73 IDS_PRINT_PREVIEW_SHEETS_LABEL_SINGULAR); | 86 IDS_PRINT_PREVIEW_SHEETS_LABEL_SINGULAR); |
| 74 AddLocalizedString("printPreviewSheetsLabelPlural", | 87 AddLocalizedString("printPreviewSheetsLabelPlural", |
| 75 IDS_PRINT_PREVIEW_SHEETS_LABEL_PLURAL); | 88 IDS_PRINT_PREVIEW_SHEETS_LABEL_PLURAL); |
| 76 AddLocalizedString("printPreviewPageLabelSingular", | 89 AddLocalizedString("printPreviewPageLabelSingular", |
| 77 IDS_PRINT_PREVIEW_PAGE_LABEL_SINGULAR); | 90 IDS_PRINT_PREVIEW_PAGE_LABEL_SINGULAR); |
| 78 AddLocalizedString("printPreviewPageLabelPlural", | 91 AddLocalizedString("printPreviewPageLabelPlural", |
| 79 IDS_PRINT_PREVIEW_PAGE_LABEL_PLURAL); | 92 IDS_PRINT_PREVIEW_PAGE_LABEL_PLURAL); |
| 80 AddLocalizedString("systemDialogOption", | 93 #if defined(OS_MACOSX) |
|
Lei Zhang
2011/08/25 23:01:47
Probably don't need this. UTF8ToUTF16 should work
kmadhusu
2011/08/26 02:15:07
Done.
| |
| 81 IDS_PRINT_PREVIEW_SYSTEM_DIALOG_OPTION); | 94 const string16 shortcut_text(UTF8ToUTF16(kAdvancedPrintShortcut)); |
| 95 #else | |
| 96 const string16 shortcut_text(ASCIIToUTF16(kAdvancedPrintShortcut)); | |
| 97 #endif | |
| 98 AddString("systemDialogOption", l10n_util::GetStringFUTF16( | |
| 99 IDS_PRINT_PREVIEW_SYSTEM_DIALOG_OPTION, | |
| 100 shortcut_text)); | |
| 101 | |
| 82 AddLocalizedString("pageRangeInstruction", | 102 AddLocalizedString("pageRangeInstruction", |
| 83 IDS_PRINT_PREVIEW_PAGE_RANGE_INSTRUCTION); | 103 IDS_PRINT_PREVIEW_PAGE_RANGE_INSTRUCTION); |
| 84 AddLocalizedString("copiesInstruction", IDS_PRINT_PREVIEW_COPIES_INSTRUCTION); | 104 AddLocalizedString("copiesInstruction", IDS_PRINT_PREVIEW_COPIES_INSTRUCTION); |
| 85 AddLocalizedString("signIn", IDS_PRINT_PREVIEW_SIGN_IN); | 105 AddLocalizedString("signIn", IDS_PRINT_PREVIEW_SIGN_IN); |
| 86 AddLocalizedString("morePrinters", IDS_PRINT_PREVIEW_MORE_PRINTERS); | 106 AddLocalizedString("morePrinters", IDS_PRINT_PREVIEW_MORE_PRINTERS); |
| 87 AddLocalizedString("addCloudPrinter", IDS_PRINT_PREVIEW_ADD_CLOUD_PRINTER); | 107 AddLocalizedString("addCloudPrinter", IDS_PRINT_PREVIEW_ADD_CLOUD_PRINTER); |
| 88 AddLocalizedString("cloudPrinters", IDS_PRINT_PREVIEW_CLOUD_PRINTERS); | 108 AddLocalizedString("cloudPrinters", IDS_PRINT_PREVIEW_CLOUD_PRINTERS); |
| 89 AddLocalizedString("localPrinters", IDS_PRINT_PREVIEW_LOCAL_PRINTERS); | 109 AddLocalizedString("localPrinters", IDS_PRINT_PREVIEW_LOCAL_PRINTERS); |
| 90 AddLocalizedString("manageCloudPrinters", | 110 AddLocalizedString("manageCloudPrinters", |
| 91 IDS_PRINT_PREVIEW_MANAGE_CLOUD_PRINTERS); | 111 IDS_PRINT_PREVIEW_MANAGE_CLOUD_PRINTERS); |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 130 url_substr[0], page_index, &data); | 150 url_substr[0], page_index, &data); |
| 131 } | 151 } |
| 132 if (data.get()) { | 152 if (data.get()) { |
| 133 SendResponse(request_id, data); | 153 SendResponse(request_id, data); |
| 134 return; | 154 return; |
| 135 } | 155 } |
| 136 // Invalid request. | 156 // Invalid request. |
| 137 scoped_refptr<RefCountedBytes> empty_bytes(new RefCountedBytes); | 157 scoped_refptr<RefCountedBytes> empty_bytes(new RefCountedBytes); |
| 138 SendResponse(request_id, empty_bytes); | 158 SendResponse(request_id, empty_bytes); |
| 139 } | 159 } |
| OLD | NEW |