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

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
« no previous file with comments | « chrome/browser/resources/pdf/pdf.html ('k') | chrome/common/chrome_content_client.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 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
5 (function() {
6
7 var plugin;
8 var sizer;
9
10 function onScroll() {
11 var coordinates = [window.pageXOffset, window.pageYOffset];
12 plugin.postMessage(coordinates);
13 }
14
15 function handleMessage(message) {
16 if (message.data['type'] == 'document_dimensions') {
17 if (sizer.style.height != message.data['document_height'] + 'px') {
18 sizer.style.height = message.data['document_height'] + 'px';
19 sizer.style.width = message.data['document_width'] + 'px';
20 }
21 }
22 }
23
24 function load() {
25 window.addEventListener('scroll',
26 function() { webkitRequestAnimationFrame(onScroll); });
27
28 // The pdf location is passed in the document url in the format:
29 // http://<.../pdf.html>?<pdf location>.
30 var url = window.location.search.substring(1);
31 plugin = document.createElement('object');
32 plugin.setAttribute('width', '100%');
33 plugin.setAttribute('height', '100%');
34 plugin.setAttribute('type', 'application/x-google-chrome-pdf');
35 plugin.setAttribute('src', url);
36 plugin.style.zIndex = '1';
37 plugin.style.position = 'fixed';
38 plugin.addEventListener('message', handleMessage, false);
39 document.body.appendChild(plugin);
40
41 sizer = document.createElement('div');
42 sizer.style.zIndex = '0';
43 sizer.style.position = 'absolute';
44 sizer.style.width = '100%';
45 sizer.style.height = '100%';
46 document.body.appendChild(sizer);
47 }
48
49 load();
50
51 })();
OLDNEW
« 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