-
Notifications
You must be signed in to change notification settings - Fork 965
Allow downloading PDFs instead of opening them in Brave. #941
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
afce7b0
to
359075c
Compare
a9b15c2
to
c0ce5c8
Compare
aefe129
to
1c2c7af
Compare
emerick
reviewed
Dec 4, 2018
34dbfa5
to
7487150
Compare
Fixes brave/brave-browser#1531 The fix does the following: 1. Makes the initial decision on whether to load PDFJS extension based on the value of kPluginsAlwaysOpenPdfExternally profile preference in addition to the command line switch. 2. Watches profile preference value kPluginsAlwaysOpenPdfExternally and adds/removes PDFJS component when the value changes. 3. Modifies js behind the chrome://settings/content/pdfDocuments so that if the PDFJS extension is disabled from the command line the option to download PDF files instead of opening them in Brave is set to ON and the toggle is disabled. 4. Adds an alternative call for whitelisted extensions in extensions/common/manifest_handlers/mime_types_handler.h that removes Chrome's PDF Extension ID from whitelisted IDs and patches chrome/browser/plugins/plugin_utils.cc to use the alternative call. This is done because on Linux that extension is not removed from profile enabled extensions (because there is no extensions install verification) and it ends up being picked as a handler for PDFs. If our PDFJS extension is disabled via command line, this causes a PDF to be neither displayed nor downloaded. Note, that this fix doesn't address being able to turn off opening PDFs in Brave in Guest/Tor profiles. The web ui setting to do so is not available in these profiles. The command line switch to not load PDFJS already applies to all profile types. Adds browser tests to check that Chromium's PDF extension is not considered for handling PDFs and if the PDFJS extension is not loaded or disabled from command line a download is initiated when navigating to a PDF URL. Also adds test to verify that when PDF download preference is toggled the component loader will take an appropriate action (add or remove PDFJS extension).
7487150
to
06c2c83
Compare
emerick
approved these changes
Dec 10, 2018
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
bbondy
approved these changes
Dec 14, 2018
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks good!
mkarolin
added a commit
that referenced
this pull request
Dec 14, 2018
Allow downloading PDFs instead of opening them in Brave.
mkarolin
added a commit
that referenced
this pull request
Dec 14, 2018
Allow downloading PDFs instead of opening them in Brave.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes brave/brave-browser#1531
The fix does the following:
Makes the initial decision on whether to load PDFJS extension based
on the value of kPluginsAlwaysOpenPdfExternally profile preference in
addition to the command line switch.
Watches profile preference value kPluginsAlwaysOpenPdfExternally and
adds/removes PDFJS component when the value changes.
Modifies js behind the chrome://settings/content/pdfDocuments so that
if the PDFJS extension is disabled from the command line the option to
download PDF files instead of opening them in Brave is set to ON and the
toggle is disabled.
Adds an alternative call for whitelisted extensions in
extensions/common/manifest_handlers/mime_types_handler.h that removes
Chrome's PDF Extension ID from whitelisted IDs and patches
chrome/browser/plugins/plugin_utils.cc to use the alternative call. This
is done because on Linux that extension is not removed from profile
enabled extensions (because there is no extensions install verification)
and it ends up being picked as a handler for PDFs. If our PDFJS extension
is disabled via command line, this causes a PDF to be neither displayed
nor downloaded.
Note, that this fix doesn't address being able to turn off opening PDFs
in Brave in Guest/Tor profiles. The web ui setting to do so is not
available in these profiles.
The command line switch to not load PDFJS already applies to all profile
types.
Adds browser tests to check that Chromium's PDF extension is not
considered for handling PDFs and if the PDFJS extension is not loaded or
disabled from command line a download is initiated when navigating to a
PDF URL. Also adds test to verify that when PDF download preference is
toggled the component loader will take an appropriate action (add or
remove PDFJS extension).
Submitter Checklist:
npm test brave_unit_tests && npm test brave_browser_tests
) ongit rebase master
(if needed).git rebase -i
to squash commits (if needed).Test Plan:
Automated testing
npm run test -- brave_browser_tests --filter=BravePDFDownloadTest.*
npm run test -- brave_browser_tests --filter=BravePDFExtensionTest.ToggleDownloadPDFs
npm run test -- brave_browser_tests --filter=BravePDFExtensionDisabledTest.ToggleDownloadPDFs
Manual testing
Download PDF files...
setting is turned onchrome://settings/content/pdfDocuments
,Download PDF files...
setting to ON,--disable-pdfjs-extension
switch,chrome://settings/content/pdfDocuments
and verify that theDownload PDF files...
setting is set to ON and is disabled,Reviewer Checklist: