Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(247)

Side by Side Diff: chrome/browser/ui/webui/print_preview_data_source.cc

Issue 7721001: PrintPreview: Make ctrl-shift-p start the native print flow. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Addressed review comments. Created 9 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 #endif
32
33 }; // namespace
34
26 PrintPreviewDataSource::PrintPreviewDataSource() 35 PrintPreviewDataSource::PrintPreviewDataSource()
27 : ChromeWebUIDataSource(chrome::kChromeUIPrintHost) { 36 : ChromeWebUIDataSource(chrome::kChromeUIPrintHost) {
28 37
29 AddLocalizedString("title", IDS_PRINT_PREVIEW_TITLE); 38 AddLocalizedString("title", IDS_PRINT_PREVIEW_TITLE);
30 AddLocalizedString("loading", IDS_PRINT_PREVIEW_LOADING); 39 AddLocalizedString("loading", IDS_PRINT_PREVIEW_LOADING);
31 #if defined(GOOGLE_CHROME_BUILD) 40 #if defined(GOOGLE_CHROME_BUILD)
32 AddString("noPlugin", l10n_util::GetStringFUTF16( 41 AddString("noPlugin", l10n_util::GetStringFUTF16(
33 IDS_PRINT_PREVIEW_NO_PLUGIN, ASCIIToUTF16("chrome://plugins/"))); 42 IDS_PRINT_PREVIEW_NO_PLUGIN, ASCIIToUTF16("chrome://plugins/")));
34 #else 43 #else
35 AddLocalizedString("noPlugin", IDS_PRINT_PREVIEW_NO_PLUGIN); 44 AddLocalizedString("noPlugin", IDS_PRINT_PREVIEW_NO_PLUGIN);
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 AddLocalizedString("printPreviewSummaryFormatLong", 79 AddLocalizedString("printPreviewSummaryFormatLong",
71 IDS_PRINT_PREVIEW_SUMMARY_FORMAT_LONG); 80 IDS_PRINT_PREVIEW_SUMMARY_FORMAT_LONG);
72 AddLocalizedString("printPreviewSheetsLabelSingular", 81 AddLocalizedString("printPreviewSheetsLabelSingular",
73 IDS_PRINT_PREVIEW_SHEETS_LABEL_SINGULAR); 82 IDS_PRINT_PREVIEW_SHEETS_LABEL_SINGULAR);
74 AddLocalizedString("printPreviewSheetsLabelPlural", 83 AddLocalizedString("printPreviewSheetsLabelPlural",
75 IDS_PRINT_PREVIEW_SHEETS_LABEL_PLURAL); 84 IDS_PRINT_PREVIEW_SHEETS_LABEL_PLURAL);
76 AddLocalizedString("printPreviewPageLabelSingular", 85 AddLocalizedString("printPreviewPageLabelSingular",
77 IDS_PRINT_PREVIEW_PAGE_LABEL_SINGULAR); 86 IDS_PRINT_PREVIEW_PAGE_LABEL_SINGULAR);
78 AddLocalizedString("printPreviewPageLabelPlural", 87 AddLocalizedString("printPreviewPageLabelPlural",
79 IDS_PRINT_PREVIEW_PAGE_LABEL_PLURAL); 88 IDS_PRINT_PREVIEW_PAGE_LABEL_PLURAL);
80 AddLocalizedString("systemDialogOption", 89 #if defined(OS_MACOSX)
81 IDS_PRINT_PREVIEW_SYSTEM_DIALOG_OPTION); 90 const string16 shortcut_text = UTF8ToUTF16(kAdvancedPrintShortcut);
91 #else
92 const string16 shortcut_text =
93 l10n_util::GetStringUTF16(IDS_PRINT_PREVIEW_ADVANCED_SHORTCUT_KEY);
Lei Zhang 2011/08/25 20:43:23 Since this doesn't need to be translated, just def
kmadhusu 2011/08/25 22:47:39 good catch.. Fixed.
94 #endif
95 AddString("systemDialogOption", l10n_util::GetStringFUTF16(
96 IDS_PRINT_PREVIEW_SYSTEM_DIALOG_OPTION,
97 shortcut_text));
98
82 AddLocalizedString("pageRangeInstruction", 99 AddLocalizedString("pageRangeInstruction",
83 IDS_PRINT_PREVIEW_PAGE_RANGE_INSTRUCTION); 100 IDS_PRINT_PREVIEW_PAGE_RANGE_INSTRUCTION);
84 AddLocalizedString("copiesInstruction", IDS_PRINT_PREVIEW_COPIES_INSTRUCTION); 101 AddLocalizedString("copiesInstruction", IDS_PRINT_PREVIEW_COPIES_INSTRUCTION);
85 AddLocalizedString("signIn", IDS_PRINT_PREVIEW_SIGN_IN); 102 AddLocalizedString("signIn", IDS_PRINT_PREVIEW_SIGN_IN);
86 AddLocalizedString("morePrinters", IDS_PRINT_PREVIEW_MORE_PRINTERS); 103 AddLocalizedString("morePrinters", IDS_PRINT_PREVIEW_MORE_PRINTERS);
87 AddLocalizedString("addCloudPrinter", IDS_PRINT_PREVIEW_ADD_CLOUD_PRINTER); 104 AddLocalizedString("addCloudPrinter", IDS_PRINT_PREVIEW_ADD_CLOUD_PRINTER);
88 AddLocalizedString("cloudPrinters", IDS_PRINT_PREVIEW_CLOUD_PRINTERS); 105 AddLocalizedString("cloudPrinters", IDS_PRINT_PREVIEW_CLOUD_PRINTERS);
89 AddLocalizedString("localPrinters", IDS_PRINT_PREVIEW_LOCAL_PRINTERS); 106 AddLocalizedString("localPrinters", IDS_PRINT_PREVIEW_LOCAL_PRINTERS);
90 AddLocalizedString("manageCloudPrinters", 107 AddLocalizedString("manageCloudPrinters",
91 IDS_PRINT_PREVIEW_MANAGE_CLOUD_PRINTERS); 108 IDS_PRINT_PREVIEW_MANAGE_CLOUD_PRINTERS);
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 url_substr[0], page_index, &data); 147 url_substr[0], page_index, &data);
131 } 148 }
132 if (data.get()) { 149 if (data.get()) {
133 SendResponse(request_id, data); 150 SendResponse(request_id, data);
134 return; 151 return;
135 } 152 }
136 // Invalid request. 153 // Invalid request.
137 scoped_refptr<RefCountedBytes> empty_bytes(new RefCountedBytes); 154 scoped_refptr<RefCountedBytes> empty_bytes(new RefCountedBytes);
138 SendResponse(request_id, empty_bytes); 155 SendResponse(request_id, empty_bytes);
139 } 156 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698