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

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

Issue 1350073002: PDFs viewed inside a <webview> should navigate the same as PDFs in tabs. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Pass boolean instead of tabId. Created 5 years, 2 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
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 /** 7 /**
8 * @return {number} Width of a scrollbar in pixels 8 * @return {number} Width of a scrollbar in pixels
9 */ 9 */
10 function getScrollbarWidth() { 10 function getScrollbarWidth() {
(...skipping 23 matching lines...) Expand all
34 return decodeURIComponent(filename); 34 return decodeURIComponent(filename);
35 } catch (e) { 35 } catch (e) {
36 if (e instanceof URIError) 36 if (e instanceof URIError)
37 return filename; 37 return filename;
38 throw e; 38 throw e;
39 } 39 }
40 } 40 }
41 41
42 /** 42 /**
43 * Called when navigation happens in the current tab. 43 * Called when navigation happens in the current tab.
44 * @param {boolean} isInTab Indicates if the PDF viewer is displayed in a tab.
44 * @param {string} url The url to be opened in the current tab. 45 * @param {string} url The url to be opened in the current tab.
45 */ 46 */
46 function onNavigateInCurrentTab(url) { 47 function onNavigateInCurrentTab(isInTab, url) {
47 // Prefer the tabs API because it can navigate from one file:// URL to 48 // When the PDFviewer is inside a browser tab, prefer the tabs API because
48 // another. 49 // it can navigate from one file:// URL to another.
49 if (chrome.tabs) 50 if (chrome.tabs && isInTab)
50 chrome.tabs.update({url: url}); 51 chrome.tabs.update({url: url});
51 else 52 else
52 window.location.href = url; 53 window.location.href = url;
53 } 54 }
54 55
55 /** 56 /**
56 * Called when navigation happens in the new tab. 57 * Called when navigation happens in the new tab.
57 * @param {string} url The url to be opened in the new tab. 58 * @param {string} url The url to be opened in the new tab.
58 */ 59 */
59 function onNavigateInNewTab(url) { 60 function onNavigateInNewTab(url) {
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
250 this.zoomManager_.onBrowserZoomChange.bind(this.zoomManager_)); 251 this.zoomManager_.onBrowserZoomChange.bind(this.zoomManager_));
251 252
252 // Setup the keyboard event listener. 253 // Setup the keyboard event listener.
253 document.addEventListener('keydown', this.handleKeyEvent_.bind(this)); 254 document.addEventListener('keydown', this.handleKeyEvent_.bind(this));
254 document.addEventListener('mousemove', this.handleMouseEvent_.bind(this)); 255 document.addEventListener('mousemove', this.handleMouseEvent_.bind(this));
255 document.addEventListener('mouseout', this.handleMouseEvent_.bind(this)); 256 document.addEventListener('mouseout', this.handleMouseEvent_.bind(this));
256 257
257 // Parse open pdf parameters. 258 // Parse open pdf parameters.
258 this.paramsParser_ = 259 this.paramsParser_ =
259 new OpenPDFParamsParser(this.getNamedDestination_.bind(this)); 260 new OpenPDFParamsParser(this.getNamedDestination_.bind(this));
261 var isInTab = this.browserApi_.getStreamInfo().tabId != -1;
260 this.navigator_ = new Navigator(this.browserApi_.getStreamInfo().originalUrl, 262 this.navigator_ = new Navigator(this.browserApi_.getStreamInfo().originalUrl,
261 this.viewport_, this.paramsParser_, 263 this.viewport_, this.paramsParser_,
262 onNavigateInCurrentTab, onNavigateInNewTab); 264 onNavigateInCurrentTab.bind(undefined,
265 isInTab),
Dan Beam 2015/09/29 22:38:26 function() { onNavigateInCurrentTab(isInTab); },
Dan Beam 2015/09/29 22:38:58 function(url) { onNavigateInCurrentTab(isInTab, ur
266 onNavigateInNewTab);
263 this.viewportScroller_ = 267 this.viewportScroller_ =
264 new ViewportScroller(this.viewport_, this.plugin_, window); 268 new ViewportScroller(this.viewport_, this.plugin_, window);
265 269
266 // Request translated strings. 270 // Request translated strings.
267 if (!this.isPrintPreview_) 271 if (!this.isPrintPreview_)
268 chrome.resourcesPrivate.getStrings('pdf', this.handleStrings_.bind(this)); 272 chrome.resourcesPrivate.getStrings('pdf', this.handleStrings_.bind(this));
269 } 273 }
270 274
271 PDFViewer.prototype = { 275 PDFViewer.prototype = {
272 /** 276 /**
(...skipping 653 matching lines...) Expand 10 before | Expand all | Expand 10 after
926 * Each bookmark is an Object containing a: 930 * Each bookmark is an Object containing a:
927 * - title 931 * - title
928 * - page (optional) 932 * - page (optional)
929 * - array of children (themselves bookmarks) 933 * - array of children (themselves bookmarks)
930 * @type {Array} the top-level bookmarks of the PDF. 934 * @type {Array} the top-level bookmarks of the PDF.
931 */ 935 */
932 get bookmarks() { 936 get bookmarks() {
933 return this.bookmarks_; 937 return this.bookmarks_;
934 } 938 }
935 }; 939 };
OLDNEW
« no previous file with comments | « chrome/browser/apps/guest_view/web_view_browsertest.cc ('k') | extensions/browser/guest_view/web_view/web_view_guest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698