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

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

Issue 726343002: OOP PDF: Add whether a resource is embedded to StreamInfo. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@embedded-pdfs
Patch Set: address comment Created 6 years, 1 month 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
« no previous file with comments | « chrome/browser/resources/pdf/main.js ('k') | chrome/common/extensions/api/streams_private.idl » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/resources/pdf/pdf.js
diff --git a/chrome/browser/resources/pdf/pdf.js b/chrome/browser/resources/pdf/pdf.js
index 0ca054f9059e8a300f5d05c4ce8f4a4a648bf0d4..7ae5ee31feb1d4f0b9fd4c0e477aac3e3c919013 100644
--- a/chrome/browser/resources/pdf/pdf.js
+++ b/chrome/browser/resources/pdf/pdf.js
@@ -84,7 +84,7 @@ function PDFViewer(streamDetails) {
}
this.plugin_.setAttribute('headers', headers);
- if (window.top == window)
+ if (!this.streamDetails.embedded)
this.plugin_.setAttribute('full-frame', '');
document.body.appendChild(this.plugin_);
@@ -113,7 +113,7 @@ function PDFViewer(streamDetails) {
document.onkeydown = this.handleKeyEvent_.bind(this);
// Set up the zoom API.
- if (chrome.tabs) {
+ if (this.shouldManageZoom_()) {
chrome.tabs.setZoomSettings(this.streamDetails.tabId,
{mode: 'manual', scope: 'per-tab'},
this.afterZoom_.bind(this));
@@ -422,7 +422,7 @@ PDFViewer.prototype = {
afterZoom_: function() {
var position = this.viewport_.position;
var zoom = this.viewport_.zoom;
- if (chrome.tabs && !this.setZoomInProgress_) {
+ if (this.shouldManageZoom_() && !this.setZoomInProgress_) {
this.setZoomInProgress_ = true;
chrome.tabs.setZoom(this.streamDetails.tabId, zoom,
this.setZoomComplete_.bind(this, zoom));
@@ -574,6 +574,17 @@ PDFViewer.prototype = {
},
/**
+ * @private
+ * Return whether this PDFViewer should manage zoom for its containing page.
+ * @return {boolean} Whether this PDFViewer should manage zoom for its
+ * containing page.
+ */
+ shouldManageZoom_: function() {
+ return !!(chrome.tabs && !this.streamDetails.embedded &&
+ this.streamDetails.tabId != -1);
+ },
+
+ /**
* @type {Viewport} the viewport of the PDF viewer.
*/
get viewport() {
« no previous file with comments | « chrome/browser/resources/pdf/main.js ('k') | chrome/common/extensions/api/streams_private.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698