Commit Graph

19 Commits

Author SHA1 Message Date
Mark Banner
2e9ae50a3a Use eslint-plugin-mozilla and the webextensions environment to avoid defining globals in each file. 2017-05-17 10:30:46 +01:00
Jonas Jenwald
4046d67fde Enable the no-else-return ESLint rule
Using `else` after `return` is not necessary, and can often lead to unnecessarily cluttered code. By using the `no-else-return` rule in ESLint we can avoid this pattern, see http://eslint.org/docs/rules/no-else-return.
2017-01-09 20:27:39 +01:00
Jonas Jenwald
28e50cfa21 Fix errors reported by the space-infix-ops ESLint rule
http://eslint.org/docs/rules/space-infix-ops
2016-12-12 20:36:00 +01:00
Jonas Jenwald
ad915f8af1 Fix errors reported by the comma-spacing ESLint rule
http://eslint.org/docs/rules/comma-spacing
2016-12-12 20:35:53 +01:00
Rob Wu
ae74e1bbd6 Deduct file type from content-disposition
A user encountered a response that looks like:

URL: some gibberish
Headers:

    Content-Type: application/octet-stream
    Content-Disposition: attachment; filename="something.pdf"

In the Chrome extension, the "attachment" content disposition is almost
always ignored (i.e. the PDF Viewer will try to view it anyway). So we
need to fall back to the Content-Disposition header if the URL check is
inconclusive.
2016-09-17 22:34:18 -07:00
Rob Wu
9394fc133c Remove support for frames in old Chromium versions
Frames are only supported (via redirectUrl) in Chrome 35.0.1911.0+
2016-05-10 22:40:07 +02:00
Rob Wu
0ec82d4a50 Allow local PDF files to be viewed in local frames
The Chrome extension enforces that local files cannot be embedded in
non-local web pages. The previous check was too strict (because the
origin of a file:-URL is "null"), and prevented local PDF from being
viewed in local files).

This patch fixes that problem, by querying the actual tab URL via the
background page.

Steps to verify:
1. Create a HTML file: `<iframe src=test.pdf width=100% height=100%>`
2. Build and load the extension.
3. Allow file access to the extension at `chrome://extensions`
4. Open the HTML file from a file:// URL.
5. VERIFY: The extension should attempt to load the PDF file.

6. Now open the following (replace ID with the extension ID, which you
   can find at `chrome://extensions`):
  `data:text/html,<iframe src="chrome-extension://ID/file:///test.pdf">`
7. VERIFY: The next error should be displayed:
   "Refused to load a local file in a non-local page for security reasons."
2016-02-10 14:52:54 +01:00
Manas
a2ba1b8189 Uses editorconfig to maintain consistent coding styles
Removes the following as they unnecessary
/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */
2015-11-14 07:32:18 +05:30
Jonas Jenwald
421289c7bc Merge pull request #6233 from Rob--W/crx-local-files
Improve support for viewing PDFs from file://-URLs in the Chrome extension
2015-08-15 14:15:36 +02:00
Rob Wu
775d4e69cf Teach users how to enable access to local files. 2015-08-14 18:59:30 +02:00
Rob Wu
ffbe669730 [CRX] Respect download requests in main frame
When the URL contains "=download", respect the Content-Disposition
header in the Chrome extension.
2015-07-06 17:13:44 +02:00
Rob Wu
adb2f8ae21 [CRX] Add Referer request header if needed
This patch adds the Referer request header to PDF requests if
the original PDF request included the Referer header.
2015-06-05 23:24:40 +02:00
Tim van der Meij
c29faaa22d Use strict equalities in make.js, external/* and extensions/* 2014-08-01 22:27:00 +02:00
Rob Wu
ae32f31eb4 Use redirectUrl at onHeadersReceived if available.
http://crbug.com/280464 has been resolved, so we can now use redirectUrl at
onHeadersReceived.
For backwards-compatibility, the code for the original method has not been
removed, and a feature detection script was added that detects whether the
desired feature is available.
2014-03-30 00:25:37 +01:00
Rob Wu
d04f81b964 Improved FTP support for Chromium extension 2014-03-30 00:08:02 +01:00
Tim van der Meij
c29350219e Making extensions/chromium/pdfHandler.js adhere to the style guide 2014-03-09 23:12:12 +01:00
Rob Wu
e9cb91de39 [CRX] split:incognito is used, so update file:-handler
The current stable Chromium version is 29. Since the critical
bug that prevented use of incognito:split has been fixed, and
incognito:split is actually used, it's safe to drop the code
that disables the extension in incognito mode.

( fixed bug = http:/crbug.com/224094 )
2013-10-16 23:14:43 +02:00
Rob Wu
edd4bae903 [CRX] Change Viewer insertion method
And use split incognito mode

Previous method:
- Rewrite content type to XHTML, followed by a content script
  to cancel and replace the document with the viewer.
  ( https://github.com/mozilla/pdf.js/pull/3017 )

New method:
- Cancel loading of the document, followed by a redirect to the viewer

Disadvantage of new method:
- URLs are no longer "nice". This will be addressed by cherry-picking
  a commit from the crx-using-streams-api branch.

Advantages of new method:
- Idle time is minimal. In some cases (with large documents),
  it took too much time before the content script was activated.
  During this period, the page looked blank, and the contents of
  the PDF file were still retrieved and **discarded**.
  With the new method, the idle time is minimal, because the request
  is immediately cancelled.
- No FOUXEP (Flash of unhidden XML error page), because the XHTML
  Content-Type hack is no longer used.
2013-10-16 23:14:16 +02:00
Andreas Bovens
f2ad0f73d7 Renaming of extensions/chrome folder to extensions/chromium, and small tweak to manifest.json description as per #3600 2013-08-21 18:11:35 +02:00