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

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

Issue 476733003: OOP PDF - Add support for "page" open pdf parameter (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Review feedback (nit fixes) Created 6 years, 4 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 | pdf/out_of_process_instance.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 <include src="../../../../ui/webui/resources/js/util.js"> 7 <include src="../../../../ui/webui/resources/js/util.js">
8 <include src="pdf_scripting_api.js"> 8 <include src="pdf_scripting_api.js">
9 <include src="viewport.js"> 9 <include src="viewport.js">
10 10
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after
258 * Notify the plugin to print. 258 * Notify the plugin to print.
259 */ 259 */
260 print_: function() { 260 print_: function() {
261 this.plugin_.postMessage({ 261 this.plugin_.postMessage({
262 type: 'print', 262 type: 'print',
263 }); 263 });
264 }, 264 },
265 265
266 /** 266 /**
267 * @private 267 * @private
268 * Handle open PDF parameters. These parameters are mentioned in the URL
269 * and specify actions to be performed when opening PDF files.
270 * See http://crbug.com/64309 for details.
271 */
272 handleOpenPDFParams_: function() {
273 var originalUrl = this.streamDetails.originalUrl;
274 var hasParams = originalUrl.search('#');
Lei Zhang 2014/08/18 23:53:32 hasParams -> paramIndex?
Nikhil 2014/08/19 05:28:08 Done.
275 if (hasParams == -1)
276 return;
277
278 var paramTokens = originalUrl.substring(hasParams + 1).split('&');
279 var paramsDictionary = {};
280 for (var i = 0; i < paramTokens.length; ++i) {
281 var keyValueSplit = paramTokens[i].split('=');
282 if (keyValueSplit.length != 2)
283 continue;
284 paramsDictionary[keyValueSplit[0]] = keyValueSplit[1];
285 }
286
287 // Order is important as later actions can override the effects
288 // of previous actions.
289 if ('page' in paramsDictionary) {
290 // value is 1-based.
291 this.viewport_.goToPage(paramsDictionary['page'] - 1);
Lei Zhang 2014/08/18 23:53:32 The current instance.cc code skips this if the pag
Nikhil 2014/08/19 05:28:08 Please let me know how do you think this should be
292 }
293 },
294
295 /**
296 * @private
268 * Update the loading progress of the document in response to a progress 297 * Update the loading progress of the document in response to a progress
269 * message being received from the plugin. 298 * message being received from the plugin.
270 * @param {number} progress the progress as a percentage. 299 * @param {number} progress the progress as a percentage.
271 */ 300 */
272 updateProgress_: function(progress) { 301 updateProgress_: function(progress) {
273 this.progressBar_.progress = progress; 302 this.progressBar_.progress = progress;
274 if (progress == -1) { 303 if (progress == -1) {
275 // Document load failed. 304 // Document load failed.
276 this.errorScreen_.style.visibility = 'visible'; 305 this.errorScreen_.style.visibility = 'visible';
277 this.sizer_.style.display = 'none'; 306 this.sizer_.style.display = 'none';
278 this.toolbar_.style.visibility = 'hidden'; 307 this.toolbar_.style.visibility = 'hidden';
279 if (this.passwordScreen_.active) { 308 if (this.passwordScreen_.active) {
280 this.passwordScreen_.deny(); 309 this.passwordScreen_.deny();
281 this.passwordScreen_.active = false; 310 this.passwordScreen_.active = false;
282 } 311 }
283 } else if (progress == 100) { 312 } else if (progress == 100) {
284 // Document load complete. 313 // Document load complete.
314 this.handleOpenPDFParams_();
285 this.loaded = true; 315 this.loaded = true;
286 var loadEvent = new Event('pdfload'); 316 var loadEvent = new Event('pdfload');
287 window.dispatchEvent(loadEvent); 317 window.dispatchEvent(loadEvent);
288 this.sendScriptingMessage_({ 318 this.sendScriptingMessage_({
289 type: 'documentLoaded' 319 type: 'documentLoaded'
290 }); 320 });
291 if (this.lastViewportPosition_) 321 if (this.lastViewportPosition_)
292 this.viewport_.position = this.lastViewportPosition_; 322 this.viewport_.position = this.lastViewportPosition_;
293 } 323 }
294 }, 324 },
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after
539 569
540 /** 570 /**
541 * @type {Viewport} the viewport of the PDF viewer. 571 * @type {Viewport} the viewport of the PDF viewer.
542 */ 572 */
543 get viewport() { 573 get viewport() {
544 return this.viewport_; 574 return this.viewport_;
545 } 575 }
546 }; 576 };
547 577
548 var viewer = new PDFViewer(); 578 var viewer = new PDFViewer();
OLDNEW
« no previous file with comments | « no previous file | pdf/out_of_process_instance.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698