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

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

Issue 96233002: Add a PDF component extension (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years 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/pdf.html ('k') | chrome/common/chrome_content_client.cc » ('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
new file mode 100644
index 0000000000000000000000000000000000000000..039e67a39ae6115332bc1cced56ff22550a4b387
--- /dev/null
+++ b/chrome/browser/resources/pdf/pdf.js
@@ -0,0 +1,51 @@
+// Copyright (c) 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+(function() {
+
+var plugin;
+var sizer;
+
+function onScroll() {
+ var coordinates = [window.pageXOffset, window.pageYOffset];
+ plugin.postMessage(coordinates);
+}
+
+function handleMessage(message) {
+ if (message.data['type'] == 'document_dimensions') {
+ if (sizer.style.height != message.data['document_height'] + 'px') {
+ sizer.style.height = message.data['document_height'] + 'px';
+ sizer.style.width = message.data['document_width'] + 'px';
+ }
+ }
+}
+
+function load() {
+ window.addEventListener('scroll',
+ function() { webkitRequestAnimationFrame(onScroll); });
+
+ // The pdf location is passed in the document url in the format:
+ // http://<.../pdf.html>?<pdf location>.
+ var url = window.location.search.substring(1);
+ plugin = document.createElement('object');
+ plugin.setAttribute('width', '100%');
+ plugin.setAttribute('height', '100%');
+ plugin.setAttribute('type', 'application/x-google-chrome-pdf');
+ plugin.setAttribute('src', url);
+ plugin.style.zIndex = '1';
+ plugin.style.position = 'fixed';
+ plugin.addEventListener('message', handleMessage, false);
+ document.body.appendChild(plugin);
+
+ sizer = document.createElement('div');
+ sizer.style.zIndex = '0';
+ sizer.style.position = 'absolute';
+ sizer.style.width = '100%';
+ sizer.style.height = '100%';
+ document.body.appendChild(sizer);
+}
+
+load();
+
+})();
« no previous file with comments | « chrome/browser/resources/pdf/pdf.html ('k') | chrome/common/chrome_content_client.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698