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

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

Issue 806633003: Implement basic toolbar with Material Design and loading progress. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Adjust viewport_test.js Created 5 years, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/resources/pdf/index-material.html ('k') | chrome/browser/resources/pdf/viewport.js » ('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 cb4c9ac9912d5810841fc39e690339208cc8a7f1..c9b50d9d9c72eda9eee4a42f1cf9e631ee3c64a1 100644
--- a/chrome/browser/resources/pdf/pdf.js
+++ b/chrome/browser/resources/pdf/pdf.js
@@ -50,6 +50,7 @@ function PDFViewer(streamDetails) {
this.isPrintPreview_ =
this.streamDetails_.originalUrl.indexOf('chrome://print') == 0;
+ this.isMaterial_ = location.pathname.substring(1) == 'index-material.html';
// The sizer element is placed behind the plugin element to cause scrollbars
// to be displayed in the window. It is sized according to the document size
@@ -62,6 +63,7 @@ function PDFViewer(streamDetails) {
this.passwordScreen_.addEventListener('password-submitted',
this.onPasswordSubmitted_.bind(this));
this.errorScreen_ = $('error-screen');
+ this.toolbarHeight_ = this.isMaterial_ ? $('pdf-toolbar').clientHeight : 0;
// Create the viewport.
this.viewport_ = new Viewport(window,
@@ -69,7 +71,8 @@ function PDFViewer(streamDetails) {
this.viewportChanged_.bind(this),
this.beforeZoom_.bind(this),
this.afterZoom_.bind(this),
- getScrollbarWidth());
+ getScrollbarWidth(),
+ this.toolbarHeight_);
// Create the plugin object dynamically so we can set its src. The plugin
// element is sized to fill the entire window and is set to be fixed
// positioning, acting as a viewport. The plugin renders into this viewport
@@ -81,6 +84,11 @@ function PDFViewer(streamDetails) {
this.plugin_.type = 'application/x-google-chrome-pdf';
this.plugin_.addEventListener('message', this.handlePluginMessage_.bind(this),
false);
+ if (this.isMaterial_) {
+ this.plugin_.style.height =
+ (window.innerHeight - this.toolbarHeight_) + 'px';
+ this.plugin_.style.width = window.innerWidth + 'px';
+ }
// Handle scripting messages from outside the extension that wish to interact
// with it. We also send a message indicating that extension has loaded and
@@ -89,6 +97,8 @@ function PDFViewer(streamDetails) {
false);
document.title = getFilenameFromURL(this.streamDetails_.originalUrl);
+ if (this.isMaterial_)
+ $('title').textContent = document.title;
this.plugin_.setAttribute('src', this.streamDetails_.originalUrl);
this.plugin_.setAttribute('stream-url', this.streamDetails_.streamUrl);
var headers = '';
@@ -310,7 +320,11 @@ PDFViewer.prototype = {
* @param {number} progress the progress as a percentage.
*/
updateProgress_: function(progress) {
- this.progressBar_.progress = progress;
+ if (this.isMaterial_)
+ this.progressBar_.value = progress;
+ else
+ this.progressBar_.progress = progress;
+
if (progress == -1) {
// Document load failed.
this.errorScreen_.style.visibility = 'visible';
@@ -543,6 +557,12 @@ PDFViewer.prototype = {
if (!this.documentDimensions_)
return;
+ if (this.isMaterial_) {
+ this.plugin_.style.height =
+ (window.innerHeight - this.toolbarHeight_) + 'px';
+ this.plugin_.style.width = window.innerWidth + 'px';
+ }
+
// Update the buttons selected.
$('fit-to-page-button').classList.remove('polymer-selected');
$('fit-to-width-button').classList.remove('polymer-selected');
« no previous file with comments | « chrome/browser/resources/pdf/index-material.html ('k') | chrome/browser/resources/pdf/viewport.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698