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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4 (function() {
5
6 var plugin;
7 var sizer;
8
9 function onScroll() {
10 var coordinates = [window.pageXOffset, window.pageYOffset];
11 plugin.postMessage(coordinates);
12 }
13
14 function handleMessage(message) {
15 if (message.data['type'] == 'document_dimensions') {
16 if (sizer.style.height != message.data['document_height'] + 'px') {
17 sizer.style.height = message.data['document_height'] + 'px';
18 sizer.style.width = message.data['document_width'] + 'px';
19 }
20 }
21 }
22
23 function load() {
24 window.addEventListener('scroll',
25 function() { webkitRequestAnimationFrame(onScroll); });
26
27 // The pdf location is passed in the document url in the format:
28 // http://<.../pdf.html>?<pdf location>.
29 var url = window.location.search.substring(1);
30 plugin = document.createElement('object');
31 plugin.setAttribute('width', '100%');
32 plugin.setAttribute('height', '100%');
33 plugin.setAttribute('type', 'application/x-google-chrome-pdf');
34 plugin.setAttribute('src', url);
35 plugin.style.zIndex = '1';
36 plugin.style.position = 'fixed';
37 plugin.addEventListener('message', handleMessage, false);
38 document.body.appendChild(plugin);
39
40 sizer = document.createElement('div');
41 sizer.style.zIndex = '0';
42 sizer.style.position = 'absolute';
43 sizer.style.width = '100%';
44 sizer.style.height = '100%';
45 document.body.appendChild(sizer);
46 }
47
48 load();
49
50 })();
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698