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

Unified Diff: chrome/browser/resources/print_preview/settings/media_size_settings.js

Issue 447963005: Get printer's paper size custom_display_name_localized property into account. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/resources/print_preview/settings/media_size_settings.js
diff --git a/chrome/browser/resources/print_preview/settings/media_size_settings.js b/chrome/browser/resources/print_preview/settings/media_size_settings.js
index 445125305f11e352dda942a032c2a5d6ff96cb44..ba21cee663da0c4119c0c62e86a900ebdbcd6878 100644
--- a/chrome/browser/resources/print_preview/settings/media_size_settings.js
+++ b/chrome/browser/resources/print_preview/settings/media_size_settings.js
@@ -70,7 +70,26 @@ cr.define('print_preview', function() {
// TODO: Better heuristics for the display name and options grouping.
this.ticketItem_.capability.option.forEach(function(option, index) {
var selectOption = document.createElement('option');
- selectOption.text = option.custom_display_name || option.name;
+ var displayName = option.custom_display_name;
+ if (!displayName && option.custom_display_name_localized) {
+ var getLocaleToCompare = function(locale, languageOnly) {
Vitaly Buka (NO REVIEWS) 2014/08/07 23:05:52 why not to put this function inside the next one?
Aleksey Shlyapnikov 2014/08/08 00:25:49 Less nesting, easier to read.
+ var code = languageOnly ? locale.split('-')[0] : locale;
+ return code.toLowerCase();
+ };
+ var getItemForLocale = function(items, locale, languageOnly) {
+ locale = getLocaleToCompare(locale, languageOnly);
+ for (var i = 0; i < items.length; i++) {
+ if (getLocaleToCompare(items[i].locale) == locale)
Vitaly Buka (NO REVIEWS) 2014/08/07 23:05:53 forEach
Aleksey Shlyapnikov 2014/08/08 00:25:49 Nope, it won't work here. I need to stop and retur
+ return items[i].value;
+ }
+ return '';
+ };
+ var items = option.custom_display_name_localized;
+ displayName =
+ getItemForLocale(items, navigator.language, false) ||
+ getItemForLocale(items, navigator.language, true);
+ }
+ selectOption.text = displayName || option.name;
selectOption.value = JSON.stringify(option);
select.add(selectOption);
if (option.is_default) {
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698