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

Side by Side Diff: chrome/browser/resources/pdf/open_pdf_params_parser.js

Issue 830433002: Navigation to relative fragments does not work correctly for OOP pdf. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Changes as per review comments. Created 5 years, 11 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 | « no previous file | chrome/browser/resources/pdf/pdf.js » ('j') | chrome/browser/resources/pdf/pdf.js » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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.
11 */ 11 */
12 function OpenPDFParamsParser(url) { 12 function OpenPDFParamsParser(url) {
13 this.url_ = url; 13 this.url_ = url;
14 this.namedDest;
raymes 2015/01/13 01:59:31 I don't think you need to store this as an instanc
Deepak 2015/01/13 08:29:07 agreed
14 this.urlParams = {}; 15 this.urlParams = {};
16 // This will have name of all the nameddest from the loaded PDF.
17 this.namedDestinations = {};
15 this.parseOpenPDFParams_(); 18 this.parseOpenPDFParams_();
16 } 19 }
17 20
18 OpenPDFParamsParser.prototype = { 21 OpenPDFParamsParser.prototype = {
19 /** 22 /**
20 * @private 23 * @private
21 * Parse zoom parameter of open PDF parameters. If this 24 * Parse zoom parameter of open PDF parameters. If this
22 * parameter is passed while opening PDF then PDF should be opened 25 * parameter is passed while opening PDF then PDF should be opened
23 * at the specified zoom level. 26 * at the specified zoom level.
24 * @param {number} zoom value. 27 * @param {number} zoom value.
(...skipping 28 matching lines...) Expand all
53 * See http://www.adobe.com/content/dam/Adobe/en/devnet/acrobat/ 56 * See http://www.adobe.com/content/dam/Adobe/en/devnet/acrobat/
54 * pdfs/pdf_open_parameters.pdf for details. 57 * pdfs/pdf_open_parameters.pdf for details.
55 */ 58 */
56 parseOpenPDFParams_: function() { 59 parseOpenPDFParams_: function() {
57 var originalUrl = this.url_; 60 var originalUrl = this.url_;
58 var paramIndex = originalUrl.search('#'); 61 var paramIndex = originalUrl.search('#');
59 if (paramIndex == -1) 62 if (paramIndex == -1)
60 return; 63 return;
61 64
62 var paramTokens = originalUrl.substring(paramIndex + 1).split('&'); 65 var paramTokens = originalUrl.substring(paramIndex + 1).split('&');
66 if ((paramTokens.length == 1) && (paramTokens[0].search('=') == -1)) {
67 this.namedDest = paramTokens[0];
68 return;
69 }
70
63 var paramsDictionary = {}; 71 var paramsDictionary = {};
64 for (var i = 0; i < paramTokens.length; ++i) { 72 for (var i = 0; i < paramTokens.length; ++i) {
65 var keyValueSplit = paramTokens[i].split('='); 73 var keyValueSplit = paramTokens[i].split('=');
66 if (keyValueSplit.length != 2) 74 if (keyValueSplit.length != 2)
67 continue; 75 continue;
68 paramsDictionary[keyValueSplit[0]] = keyValueSplit[1]; 76 paramsDictionary[keyValueSplit[0]] = keyValueSplit[1];
69 } 77 }
70 78
71 if ('page' in paramsDictionary) { 79 if ('page' in paramsDictionary) {
72 // |pageNumber| is 1-based, but goToPage() take a zero-based page number. 80 // |pageNumber| is 1-based, but goToPage() take a zero-based page number.
73 var pageNumber = parseInt(paramsDictionary['page']); 81 var pageNumber = parseInt(paramsDictionary['page']);
74 if (!isNaN(pageNumber)) 82 if (!isNaN(pageNumber))
75 this.urlParams['page'] = pageNumber - 1; 83 this.urlParams['page'] = pageNumber - 1;
76 } 84 }
77 85
78 if ('zoom' in paramsDictionary) 86 if ('zoom' in paramsDictionary)
79 this.parseZoomParam_(paramsDictionary['zoom']); 87 this.parseZoomParam_(paramsDictionary['zoom']);
88
89 if ('nameddest' in paramsDictionary)
90 this.namedDest = paramsDictionary['nameddest'];
80 } 91 }
81 }; 92 };
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/resources/pdf/pdf.js » ('j') | chrome/browser/resources/pdf/pdf.js » ('J')

Powered by Google App Engine
This is Rietveld 408576698