Skip to content
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

Disable/handle chrome PDF viewer link/anchor #4915

Closed
AndryBray opened this issue May 30, 2016 · 23 comments
Closed

Disable/handle chrome PDF viewer link/anchor #4915

AndryBray opened this issue May 30, 2016 · 23 comments
Assignees
Labels

Comments

@AndryBray
Copy link

I have a problem with PDF viewer and link click event:
if I try to load some pdf as preview (iframe or embed) and there is some link inside the document, when I click the link I loose the main viewport of app because the browser is loading the linked url/resource.

Usually I use a kind of sandbox for iframe (html based content) which scans for every or href and handles onclick event bypassing it to Shell api openExternal (with OS browser).

How can I accomplish to this sandox with PDF viewer?

@AndryBray
Copy link
Author

@rogerwang
I see there is a pdf.js file https://github.com/nwjs/chromium.src/blob/nw13/chrome/browser/resources/pdf/pdf.js which maybe could be responsible of navigation inside the pdf through the method "handlePluginMessage_" .

Please, could you confirm?
How to override this with custom method?
If this is not possible I think it could be a good default / standard override for nwjs to open every link with OS default browser instead of nwjs, do you agree?

@AndryBray
Copy link
Author

AndryBray commented May 31, 2016

@rogerwang I'm even thinking about the possibility to intercept url change / link navigation e allow it only if this match a custom rule (url pattern for ex.). Of course the best solution would be to sandbox everything and forward navigation outside of app, this is important because it's dangerous to allow to navigate inside app and anyway navigation inside the app will "break" the user experience inside the app.

@AndryBray
Copy link
Author

Bump.
@rogerwang do you think is something doable? (just to know if I have to handle it by myself)
thank you

@AndryBray
Copy link
Author

AndryBray commented Jun 5, 2016

Bump

@AndryBray
Copy link
Author

@ghostoy @rogerwang
Don't you think this issue is enough dangerous about security / injection of unwanted website navigation?

@AndryBray
Copy link
Author

hi @rogerwang any news about that?

@rogerwang
Copy link
Member

I'll try to fix it before the next release. Currently busy with GN
migration which is happening in upstream.

On Sun, Jun 12, 2016, 4:55 PM AndryBray notifications@github.com wrote:

hi @rogerwang https://github.com/rogerwang any news about that?


You are receiving this because you were mentioned.

Reply to this email directly, view it on GitHub
#4915 (comment), or mute
the thread
https://github.com/notifications/unsubscribe/AAKGGWAxtjRuumLwpHhtlDcfRU427LMfks5qK8mHgaJpZM4IqBPc
.

@rogerwang
Copy link
Member

I fixed it in git. It will open a mini browser for links in PDF. I'll add a custom handler for this later.

@AndryBray
Copy link
Author

@rogerwang thank you.
It would be nice to have something to work at global scope like window.on('locationchange', function(target) {...})

@rogerwang
Copy link
Member

@AndryBray
Copy link
Author

@rogerwang thank you! is this applied even on 0.14?

@rogerwang
Copy link
Member

Yeah. It was applied to 0.14 branch. Do you need a build?

On Tue, Jun 14, 2016 at 4:04 PM AndryBray notifications@github.com wrote:

@rogerwang https://github.com/rogerwang thank you! is this applied even
on 0.14?


You are receiving this because you were mentioned.

Reply to this email directly, view it on GitHub
#4915 (comment), or mute
the thread
https://github.com/notifications/unsubscribe/AAKGGUBC_bbudlcRHOXS8qRKJoL0QtwPks5qLmCEgaJpZM4IqBPc
.

@AndryBray
Copy link
Author

Yes, I will use it for XP and MacOS 10.6.x

@AndryBray
Copy link
Author

@rogerwang I've tested and it works well.
There is just a little problem with "mailto:email@test.com" links... this will open a blank page than the default mail client... I hope we'll have possibility to handle this actions/avents asap.

thank you

@AndryBray
Copy link
Author

@rogerwang on v 0.16 (latest at the moment of writing) there is a regression with mini-browser window opening.

If I try to open a link from a pdf embed view I see a chrome window with "chrome-extension://invalid" url loaded.

@rogerwang rogerwang self-assigned this Aug 4, 2016
@rogerwang
Copy link
Member

what do you mean by "pdf embed view"? it works for me.

@AndryBray
Copy link
Author

AndryBray commented Aug 4, 2016

I mean when you include a pdf inside the <iframe> tag.
E.g. <iframe src="data:application/pdf;base64...."> or <iframe src="yourpdfurl">
Tested on MacOS and Windows, when I click a link I see the same problem of chrome-extension://invalid

@rogerwang
Copy link
Member

Could you please submit a full case? It works well when I was testing a iframe with src pointing to a local pdf file.

@AndryBray
Copy link
Author

Ok, I just realized that it's not a "real link" but simple text starting with "www." so I suppose chrome is trying to recognize it as a link.

Test case:
Build a PDF with some text and put this text somewhere: www.google.com (no anchor/link)
Open it with iframe src inside a page
The 'www.google.com' text will become a link
Click on link and you will see the error

@AndryBray
Copy link
Author

AndryBray commented Aug 16, 2016

@rogerwang please, could you confirm my last post? Just to know if it's something wrong with my pdfs. Thank you

@rogerwang
Copy link
Member

I tried building a PDF as you said, but it still works for me.

@Christywl
Copy link
Contributor

I don't see any error. I test on Windows with nwjs-sdk-v0.24.4 according to the steps in #4915 (comment):
When I click www.google.com in my pdf, it opens a google window with nwjs.
Please try the latest nwjs build.

@Christywl
Copy link
Contributor

close until there is more information

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants