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

Unified Diff: chrome/browser/resources/pdf/open_pdf_params_parser.js

Issue 918953002: Fix for PDFs with lots of named destinations take a long time to load. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 10 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/resources/pdf/open_pdf_params_parser.js
diff --git a/chrome/browser/resources/pdf/open_pdf_params_parser.js b/chrome/browser/resources/pdf/open_pdf_params_parser.js
index c0f4b19d1c8889d979221cc19009aa17f7e8a080..7d4cc82e294b4d69f70b3dcbfa255403b4188dcf 100644
--- a/chrome/browser/resources/pdf/open_pdf_params_parser.js
+++ b/chrome/browser/resources/pdf/open_pdf_params_parser.js
@@ -52,10 +52,15 @@ OpenPDFParamsParser.prototype = {
* See http://www.adobe.com/content/dam/Adobe/en/devnet/acrobat/
* pdfs/pdf_open_parameters.pdf for details.
* @param {string} url that needs to be parsed.
+ * @param {Object} namedDestCallback Callback to be called to fetch page
+ * number for namedDestination.
+ * @param {boolean} isNavigate Tells weather this call happen for navigation
+ * as we need url for navigation case when we don't have page number for
+ * namedDestionation.
* @return {Object} A dictionary containing the viewport which should be
* displayed based on the URL.
*/
- getViewportFromUrlParams: function(url) {
+ getViewportFromUrlParams: function(url, namedDestCallback, isNavigate) {
raymes 2015/02/12 22:19:05 -None of the isNavigate stuff should be here, see
var viewportPosition = {};
var paramIndex = url.search('#');
if (paramIndex == -1)
@@ -67,6 +72,14 @@ OpenPDFParamsParser.prototype = {
// explicitlymentioned except by example in the Adobe
// "PDF Open Parameters" document.
viewportPosition['page'] = this.namedDestinations[paramTokens[0]];
raymes 2015/02/12 22:19:05 This is where we need to call into the plugin. We
+ if (viewportPosition['page'] == undefined) {
+ // -1 value indicates that we are going to get page number from plugin.
+ viewportPosition['page'] = -1;
+ if (isNavigate)
+ namedDestCallback(paramTokens[0], url);
+ else
+ namedDestCallback(paramTokens[0]);
+ }
return viewportPosition;
raymes 2015/02/12 22:19:05 callback(viewportPosition) return;
}
@@ -80,8 +93,16 @@ OpenPDFParamsParser.prototype = {
if ('nameddest' in paramsDictionary) {
var page = this.namedDestinations[paramsDictionary['nameddest']];
- if (page != undefined)
+ if (page == undefined) {
+ // -1 value indicates that we are going to get page number from plugin.
+ viewportPosition['page'] = -1;
+ if (isNavigate)
+ namedDestCallback(paramsDictionary['nameddest'], url);
+ else
+ namedDestCallback(paramsDictionary['nameddest']);
+ } else {
raymes 2015/02/12 22:19:05 The same thing here. We should shift this code thi
viewportPosition['page'] = page;
+ }
}
if ('page' in paramsDictionary) {

Powered by Google App Engine
This is Rietveld 408576698