OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 'use strict'; | 5 'use strict'; |
6 | 6 |
7 /** | 7 /** |
8 * Creates a new OpenPDFParamsParser. This parses the open pdf parameters | 8 * Creates a new OpenPDFParamsParser. This parses the open pdf parameters |
9 * passed in the url to set initial viewport settings for opening the pdf. | 9 * passed in the url to set initial viewport settings for opening the pdf. |
10 * @param {Object} getNamedDestinationsFunction The function called to fetch | 10 * @param {!Function} getNamedDestinationsFunction The function called to fetch |
11 * the page number for a named destination. | 11 * the page number for a named destination. |
12 * @constructor | 12 * @constructor |
13 */ | 13 */ |
14 function OpenPDFParamsParser(getNamedDestinationsFunction) { | 14 function OpenPDFParamsParser(getNamedDestinationsFunction) { |
15 this.outstandingRequests_ = []; | 15 this.outstandingRequests_ = []; |
16 this.getNamedDestinationsFunction_ = getNamedDestinationsFunction; | 16 this.getNamedDestinationsFunction_ = getNamedDestinationsFunction; |
17 } | 17 } |
18 | 18 |
19 OpenPDFParamsParser.prototype = { | 19 OpenPDFParamsParser.prototype = { |
20 /** | 20 /** |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
139 * @param {number} pageNumber The page corresponding to the named destination | 139 * @param {number} pageNumber The page corresponding to the named destination |
140 * requested. | 140 * requested. |
141 */ | 141 */ |
142 onNamedDestinationReceived: function(pageNumber) { | 142 onNamedDestinationReceived: function(pageNumber) { |
143 var outstandingRequest = this.outstandingRequests_.shift(); | 143 var outstandingRequest = this.outstandingRequests_.shift(); |
144 if (pageNumber != -1) | 144 if (pageNumber != -1) |
145 outstandingRequest.viewportPosition.page = pageNumber; | 145 outstandingRequest.viewportPosition.page = pageNumber; |
146 outstandingRequest.callback(outstandingRequest.viewportPosition); | 146 outstandingRequest.callback(outstandingRequest.viewportPosition); |
147 }, | 147 }, |
148 }; | 148 }; |
OLD | NEW |