Chromium Code Reviews

Side by Side Diff: chrome/browser/resources/pdf/navigator.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 tabId to Navigator() instead of browserApi_. Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff |
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 Navigator for navigating to links inside or outside the PDF. 8 * Creates a new Navigator for navigating to links inside or outside the PDF.
9 * @param {int} tabId of browser tab containing viewer, -1 if in <webview>
9 * @param {string} originalUrl The original page URL. 10 * @param {string} originalUrl The original page URL.
10 * @param {Object} viewport The viewport info of the page. 11 * @param {Object} viewport The viewport info of the page.
11 * @param {Object} paramsParser The object for URL parsing. 12 * @param {Object} paramsParser The object for URL parsing.
12 * @param {Function} navigateInCurrentTabCallback The Callback function that 13 * @param {Function} navigateInCurrentTabCallback The Callback function that
13 * gets called when navigation happens in the current tab. 14 * gets called when navigation happens in the current tab.
14 * @param {Function} navigateInNewTabCallback The Callback function that gets 15 * @param {Function} navigateInNewTabCallback The Callback function that gets
15 * called when navigation happens in the new tab. 16 * called when navigation happens in the new tab.
16 */ 17 */
17 function Navigator(originalUrl, 18 function Navigator(tabId,
19 originalUrl,
18 viewport, 20 viewport,
19 paramsParser, 21 paramsParser,
20 navigateInCurrentTabCallback, 22 navigateInCurrentTabCallback,
21 navigateInNewTabCallback) { 23 navigateInNewTabCallback) {
24 this.tabId_ = tabId;
22 this.originalUrl_ = originalUrl; 25 this.originalUrl_ = originalUrl;
23 this.viewport_ = viewport; 26 this.viewport_ = viewport;
24 this.paramsParser_ = paramsParser; 27 this.paramsParser_ = paramsParser;
25 this.navigateInCurrentTabCallback_ = navigateInCurrentTabCallback; 28 this.navigateInCurrentTabCallback_ = navigateInCurrentTabCallback;
26 this.navigateInNewTabCallback_ = navigateInNewTabCallback; 29 this.navigateInNewTabCallback_ = navigateInNewTabCallback;
27 } 30 }
28 31
29 Navigator.prototype = { 32 Navigator.prototype = {
30 /** 33 /**
31 * @private 34 * @private
(...skipping 126 matching lines...)
158 if (isRelative) { 161 if (isRelative) {
159 var slashIndex = this.originalUrl_.lastIndexOf('/'); 162 var slashIndex = this.originalUrl_.lastIndexOf('/');
160 var path = slashIndex != -1 ? 163 var path = slashIndex != -1 ?
161 this.originalUrl_.substr(0, slashIndex) : this.originalUrl_; 164 this.originalUrl_.substr(0, slashIndex) : this.originalUrl_;
162 return path + '/' + url; 165 return path + '/' + url;
163 } 166 }
164 167
165 return 'http://' + url; 168 return 'http://' + url;
166 } 169 }
167 }; 170 };
OLDNEW

Powered by Google App Engine