| Index: chrome/browser/resources/pdf/pdf.js
|
| diff --git a/chrome/browser/resources/pdf/pdf.js b/chrome/browser/resources/pdf/pdf.js
|
| index 309886fde637a343d583d44f3d367064a374c317..1d78c3ec86f121fcab88e43a30080b130d83dffe 100644
|
| --- a/chrome/browser/resources/pdf/pdf.js
|
| +++ b/chrome/browser/resources/pdf/pdf.js
|
| @@ -190,7 +190,8 @@ function PDFViewer(streamDetails) {
|
| }
|
|
|
| // Parse open pdf parameters.
|
| - this.paramsParser_ = new OpenPDFParamsParser();
|
| + this.paramsParser_ =
|
| + new OpenPDFParamsParser(this.getNamedDestination_.bind(this));
|
| this.navigator_ = new Navigator(this.streamDetails_.originalUrl,
|
| this.viewport_, this.paramsParser_, onNavigateInCurrentTab,
|
| onNavigateInNewTab);
|
| @@ -350,13 +351,29 @@ PDFViewer.prototype = {
|
| * @private
|
| * Notify the plugin to print.
|
| */
|
| - print_: function() { this.plugin_.postMessage({type: 'print'}); },
|
| + print_: function() {
|
| + this.plugin_.postMessage({
|
| + type: 'print'});
|
| + },
|
|
|
| /**
|
| * @private
|
| * Notify the plugin to save.
|
| */
|
| - save_: function() { this.plugin_.postMessage({type: 'save'}); },
|
| + save_: function() {
|
| + this.plugin_.postMessage({
|
| + type: 'save'});
|
| + },
|
| +
|
| + /**
|
| + * Callback to fetch namedDestination from plugin.
|
| + */
|
| + getNamedDestination_: function(name) {
|
| + this.plugin_.postMessage({
|
| + type: 'getNamedDestination',
|
| + namedDestination: name
|
| + });
|
| + },
|
|
|
| /**
|
| * @private
|
| @@ -365,20 +382,20 @@ PDFViewer.prototype = {
|
| * important as later actions can override the effects of previous actions.
|
| */
|
| handleURLParams_: function() {
|
| - var urlParams =
|
| - this.paramsParser_.getViewportFromUrlParams(
|
| - this.streamDetails_.originalUrl);
|
| - if (urlParams.page)
|
| - this.viewport_.goToPage(urlParams.page);
|
| - if (urlParams.position) {
|
| - // Make sure we don't cancel effect of page parameter.
|
| - this.viewport_.position = {
|
| - x: this.viewport_.position.x + urlParams.position.x,
|
| - y: this.viewport_.position.y + urlParams.position.y
|
| - };
|
| - }
|
| - if (urlParams.zoom)
|
| - this.viewport_.setZoom(urlParams.zoom);
|
| + this.parmsParser_.getViewportFromUrlParams(
|
| + this.streamDetails_.originalUrl, function(initialViewport) {
|
| + if (initialViewport.page != undefined)
|
| + this.viewport_.goToPage(initialViewport.page);
|
| + if (initialViewport.position) {
|
| + // Make sure we don't cancel effect of page parameter.
|
| + this.viewport_.position = {
|
| + x: this.viewport_.position.x + initialViewport.position.x,
|
| + y: this.viewport_.position.y + initialViewport.position.y
|
| + };
|
| + }
|
| + if (initialViewport.zoom)
|
| + this.viewport_.setZoom(initialViewport.zoom);
|
| + }.bind(this));
|
| },
|
|
|
| /**
|
| @@ -486,9 +503,6 @@ PDFViewer.prototype = {
|
| else
|
| this.navigator_.navigate(message.data.url, message.data.newTab);
|
| break;
|
| - case 'setNamedDestinations':
|
| - this.paramsParser_.namedDestinations = message.data.namedDestinations;
|
| - break;
|
| case 'setScrollPosition':
|
| var position = this.viewport_.position;
|
| if (message.data.x !== undefined)
|
| @@ -519,6 +533,10 @@ PDFViewer.prototype = {
|
| case 'setIsSelecting':
|
| this.viewportScroller_.setEnableScrolling(message.data.isSelecting);
|
| break;
|
| + case 'getNamedDestinationReply':
|
| + this.paramsParser_.onNamedDestinationReceived(
|
| + message.data.namedDestinationPageNumber);
|
| + break;
|
| }
|
| },
|
|
|
|
|