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

Side by Side Diff: chrome/browser/resources/print_preview/data/ticket_items/landscape.js

Issue 580203002: Set orientation to 'AUTO' if we hide orientation option from user. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Thu Sep 18 12:07:42 PDT 2014 Created 6 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
« no previous file with comments | « chrome/browser/resources/print_preview/data/print_ticket_store.js ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 cr.define('print_preview.ticket_items', function() { 5 cr.define('print_preview.ticket_items', function() {
6 'use strict'; 6 'use strict';
7 7
8 /** 8 /**
9 * Landscape ticket item whose value is a {@code boolean} that indicates 9 * Landscape ticket item whose value is a {@code boolean} that indicates
10 * whether the document should be printed in landscape orientation. 10 * whether the document should be printed in landscape orientation.
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 __proto__: print_preview.ticket_items.TicketItem.prototype, 50 __proto__: print_preview.ticket_items.TicketItem.prototype,
51 51
52 /** @override */ 52 /** @override */
53 wouldValueBeValid: function(value) { 53 wouldValueBeValid: function(value) {
54 return true; 54 return true;
55 }, 55 },
56 56
57 /** @override */ 57 /** @override */
58 isCapabilityAvailable: function() { 58 isCapabilityAvailable: function() {
59 var cap = this.getPageOrientationCapability_(); 59 var cap = this.getPageOrientationCapability_();
60 if (!cap) { 60 if (!cap)
61 return false; 61 return false;
62 }
63 var hasAutoOrPortraitOption = false; 62 var hasAutoOrPortraitOption = false;
64 var hasLandscapeOption = false; 63 var hasLandscapeOption = false;
65 cap.option.forEach(function(option) { 64 cap.option.forEach(function(option) {
66 hasAutoOrPortraitOption = hasAutoOrPortraitOption || 65 hasAutoOrPortraitOption = hasAutoOrPortraitOption ||
67 option.type == 'AUTO' || 66 option.type == 'AUTO' ||
68 option.type == 'PORTRAIT'; 67 option.type == 'PORTRAIT';
69 hasLandscapeOption = hasLandscapeOption || option.type == 'LANDSCAPE'; 68 hasLandscapeOption = hasLandscapeOption || option.type == 'LANDSCAPE';
70 }); 69 });
71 // TODO(rltoscano): Technically, the print destination can still change 70 // TODO(rltoscano): Technically, the print destination can still change
72 // the orientation of the print out (at least for cloud printers) if the 71 // the orientation of the print out (at least for cloud printers) if the
(...skipping 30 matching lines...) Expand all
103 this, value); 102 this, value);
104 if (updateMargins) { 103 if (updateMargins) {
105 // Reset the user set margins when page orientation changes. 104 // Reset the user set margins when page orientation changes.
106 this.marginsType_.updateValue( 105 this.marginsType_.updateValue(
107 print_preview.ticket_items.MarginsType.Value.DEFAULT); 106 print_preview.ticket_items.MarginsType.Value.DEFAULT);
108 this.customMargins_.updateValue(null); 107 this.customMargins_.updateValue(null);
109 } 108 }
110 }, 109 },
111 110
112 /** 111 /**
112 * @return {boolean} Whether capability contains the |value|.
113 * @param {string} value Option to check.
114 */
115 hasOption: function(value) {
116 var cap = this.getPageOrientationCapability_();
117 if (!cap)
118 return false;
119 return cap.option.some(function(option) {
120 return option.type == value;
121 });
122 },
123
124 /**
113 * @return {Object} Page orientation capability of the selected destination. 125 * @return {Object} Page orientation capability of the selected destination.
114 * @private 126 * @private
115 */ 127 */
116 getPageOrientationCapability_: function() { 128 getPageOrientationCapability_: function() {
117 var dest = this.getSelectedDestInternal(); 129 var dest = this.getSelectedDestInternal();
118 return (dest && 130 return (dest &&
119 dest.capabilities && 131 dest.capabilities &&
120 dest.capabilities.printer && 132 dest.capabilities.printer &&
121 dest.capabilities.printer.page_orientation) || 133 dest.capabilities.printer.page_orientation) ||
122 null; 134 null;
123 } 135 }
124 }; 136 };
125 137
126 // Export 138 // Export
127 return { 139 return {
128 Landscape: Landscape 140 Landscape: Landscape
129 }; 141 };
130 }); 142 });
OLDNEW
« no previous file with comments | « chrome/browser/resources/print_preview/data/print_ticket_store.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698