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 {string} url to be parsed. | 10 * @param {string} url to be parsed. |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
53 * See http://www.adobe.com/content/dam/Adobe/en/devnet/acrobat/ | 53 * See http://www.adobe.com/content/dam/Adobe/en/devnet/acrobat/ |
54 * pdfs/pdf_open_parameters.pdf for details. | 54 * pdfs/pdf_open_parameters.pdf for details. |
55 */ | 55 */ |
56 parseOpenPDFParams_: function() { | 56 parseOpenPDFParams_: function() { |
57 var originalUrl = this.url_; | 57 var originalUrl = this.url_; |
58 var paramIndex = originalUrl.search('#'); | 58 var paramIndex = originalUrl.search('#'); |
59 if (paramIndex == -1) | 59 if (paramIndex == -1) |
60 return; | 60 return; |
61 | 61 |
62 var paramTokens = originalUrl.substring(paramIndex + 1).split('&'); | 62 var paramTokens = originalUrl.substring(paramIndex + 1).split('&'); |
63 // Handle the case of http://foo.com/bar#NAMEDDEST. This is not explicitly | |
64 // mentioned except by example in the Adobe "PDF Open Parameters" document. | |
raymes
2015/01/13 01:59:31
How come you removed this?
| |
65 if ((paramTokens.length == 1) && (paramTokens[0].search('=') == -1)) { | |
66 this.urlParams['nameddest'] = paramTokens[0]; | |
raymes
2015/01/11 23:08:41
We don't actually want to store nameddest in urlPa
Deepak
2015/01/12 09:21:43
Done.
raymes
2015/01/13 01:59:31
Please take a look at the comment above again, in
| |
67 return; | |
68 } | |
69 | |
63 var paramsDictionary = {}; | 70 var paramsDictionary = {}; |
64 for (var i = 0; i < paramTokens.length; ++i) { | 71 for (var i = 0; i < paramTokens.length; ++i) { |
65 var keyValueSplit = paramTokens[i].split('='); | 72 var keyValueSplit = paramTokens[i].split('='); |
66 if (keyValueSplit.length != 2) | 73 if (keyValueSplit.length != 2) |
67 continue; | 74 continue; |
68 paramsDictionary[keyValueSplit[0]] = keyValueSplit[1]; | 75 paramsDictionary[keyValueSplit[0]] = keyValueSplit[1]; |
69 } | 76 } |
70 | 77 |
71 if ('page' in paramsDictionary) { | 78 if ('page' in paramsDictionary) { |
72 // |pageNumber| is 1-based, but goToPage() take a zero-based page number. | 79 // |pageNumber| is 1-based, but goToPage() take a zero-based page number. |
73 var pageNumber = parseInt(paramsDictionary['page']); | 80 var pageNumber = parseInt(paramsDictionary['page']); |
74 if (!isNaN(pageNumber)) | 81 if (!isNaN(pageNumber)) |
75 this.urlParams['page'] = pageNumber - 1; | 82 this.urlParams['page'] = pageNumber - 1; |
76 } | 83 } |
77 | 84 |
78 if ('zoom' in paramsDictionary) | 85 if ('zoom' in paramsDictionary) |
79 this.parseZoomParam_(paramsDictionary['zoom']); | 86 this.parseZoomParam_(paramsDictionary['zoom']); |
80 } | 87 } |
88 | |
89 if ('nameddest' in paramsDictionary) | |
90 this.urlParams['nameddest'] = paramsDictionary['nameddest']; | |
81 }; | 91 }; |
OLD | NEW |