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

Side by Side Diff: chrome/browser/resources/print_preview/cloud_print_interface.js

Issue 387073002: Print preview changes for App Kiosk mode. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix PrintPreviewWebUITest.* Created 6 years, 5 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
« no previous file with comments | « no previous file | chrome/browser/resources/print_preview/data/destination_store.js » ('j') | 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('cloudprint', function() { 5 cr.define('cloudprint', function() {
6 'use strict'; 6 'use strict';
7 7
8 /** 8 /**
9 * API to the Google Cloud Print service. 9 * API to the Google Cloud Print service.
10 * @param {string} baseUrl Base part of the Google Cloud Print service URL 10 * @param {string} baseUrl Base part of the Google Cloud Print service URL
11 * with no trailing slash. For example, 11 * with no trailing slash. For example,
12 * 'https://www.google.com/cloudprint'. 12 * 'https://www.google.com/cloudprint'.
13 * @param {!print_preview.NativeLayer} nativeLayer Native layer used to get 13 * @param {!print_preview.NativeLayer} nativeLayer Native layer used to get
14 * Auth2 tokens. 14 * Auth2 tokens.
15 * @param {!print_preview.UserInfo} userInfo User information repository. 15 * @param {!print_preview.UserInfo} userInfo User information repository.
16 * @param {boolean} isInAppKioskMode Whether the print preview is in App
17 * Kiosk mode.
16 * @constructor 18 * @constructor
17 * @extends {cr.EventTarget} 19 * @extends {cr.EventTarget}
18 */ 20 */
19 function CloudPrintInterface(baseUrl, nativeLayer, userInfo) { 21 function CloudPrintInterface(
22 baseUrl, nativeLayer, userInfo, isInAppKioskMode) {
20 /** 23 /**
21 * The base URL of the Google Cloud Print API. 24 * The base URL of the Google Cloud Print API.
22 * @type {string} 25 * @type {string}
23 * @private 26 * @private
24 */ 27 */
25 this.baseUrl_ = baseUrl; 28 this.baseUrl_ = baseUrl;
26 29
27 /** 30 /**
28 * Used to get Auth2 tokens. 31 * Used to get Auth2 tokens.
29 * @type {!print_preview.NativeLayer} 32 * @type {!print_preview.NativeLayer}
30 * @private 33 * @private
31 */ 34 */
32 this.nativeLayer_ = nativeLayer; 35 this.nativeLayer_ = nativeLayer;
33 36
34 /** 37 /**
35 * User information repository. 38 * User information repository.
36 * @type {!print_preview.UserInfo} 39 * @type {!print_preview.UserInfo}
37 * @private 40 * @private
38 */ 41 */
39 this.userInfo_ = userInfo; 42 this.userInfo_ = userInfo;
40 43
41 /** 44 /**
45 * Whether Print Preview is in App Kiosk mode, basically, use only printers
46 * available for the device.
47 * @type {boolean}
48 * @private
49 */
50 this.isInAppKioskMode_ = isInAppKioskMode;
51
52 /**
42 * Currently logged in users (identified by email) mapped to the Google 53 * Currently logged in users (identified by email) mapped to the Google
43 * session index. 54 * session index.
44 * @type {!Object.<string, number>} 55 * @type {!Object.<string, number>}
45 * @private 56 * @private
46 */ 57 */
47 this.userSessionIndex_ = {}; 58 this.userSessionIndex_ = {};
48 59
49 /** 60 /**
50 * Stores last received XSRF tokens for each user account. Sent as 61 * Stores last received XSRF tokens for each user account. Sent as
51 * a parameter with every request. 62 * a parameter with every request.
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
172 * @param {string=} opt_account Account the search is sent for. When 183 * @param {string=} opt_account Account the search is sent for. When
173 * omitted, the search is done on behalf of the primary user. 184 * omitted, the search is done on behalf of the primary user.
174 * @param {print_preview.Destination.Origin=} opt_origin When specified, 185 * @param {print_preview.Destination.Origin=} opt_origin When specified,
175 * searches destinations for {@code opt_origin} only, otherwise starts 186 * searches destinations for {@code opt_origin} only, otherwise starts
176 * searches for all origins. 187 * searches for all origins.
177 */ 188 */
178 search: function(opt_account, opt_origin) { 189 search: function(opt_account, opt_origin) {
179 var account = opt_account || ''; 190 var account = opt_account || '';
180 var origins = 191 var origins =
181 opt_origin && [opt_origin] || CloudPrintInterface.CLOUD_ORIGINS_; 192 opt_origin && [opt_origin] || CloudPrintInterface.CLOUD_ORIGINS_;
193 if (this.isInAppKioskMode_) {
194 origins = origins.filter(function(origin) {
195 return origin != print_preview.Destination.Origin.COOKIES;
196 });
197 }
182 this.abortSearchRequests_(origins); 198 this.abortSearchRequests_(origins);
183 this.search_(true, account, origins); 199 this.search_(true, account, origins);
184 this.search_(false, account, origins); 200 this.search_(false, account, origins);
185 }, 201 },
186 202
187 /** 203 /**
188 * Sends Google Cloud Print search API requests. 204 * Sends Google Cloud Print search API requests.
189 * @param {boolean} isRecent Whether to search for only recently used 205 * @param {boolean} isRecent Whether to search for only recently used
190 * printers. 206 * printers.
191 * @param {string} account Account the search is sent for. It matters for 207 * @param {string} account Account the search is sent for. It matters for
(...skipping 526 matching lines...) Expand 10 before | Expand all | Expand 10 after
718 * @type {string} 734 * @type {string}
719 */ 735 */
720 this.value = value; 736 this.value = value;
721 }; 737 };
722 738
723 // Export 739 // Export
724 return { 740 return {
725 CloudPrintInterface: CloudPrintInterface 741 CloudPrintInterface: CloudPrintInterface
726 }; 742 };
727 }); 743 });
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/resources/print_preview/data/destination_store.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698