cordova-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Andrew Grieve <agri...@chromium.org>
Subject Re: InAppBrowser api questions
Date Tue, 13 Nov 2012 03:29:06 GMT
On Mon, Nov 12, 2012 at 2:11 PM, Shazron <shazron@gmail.com> wrote:

> Bump. These questions below still need some discussion and consensus before
> the InAppBrowser implementation can be complete.
>
>
> On Fri, Nov 9, 2012 at 9:43 AM, Shazron <shazron@gmail.com> wrote:
>
> > WIki page: http://wiki.apache.org/cordova/InAppBrowser
> > Some questions brought up by Jesse in JIRA (replicated below):
> > http://goo.gl/cZe84
> >
> > ----------------------------------------------------
> > Jesse MacFadyen:
> >
> > I have some open questions about the wiki defined 'spec'
> >
> > 1. window.open('http://random-url.com', '_self'); // loads in
> InAppBrowser
> >     so even though the random-url is not whitelisted, it is permitted to
> > load within the application, inside the InAppBrowser. This is currently
> not
> > trivial on iOS.
>
>
> > 2. How can I open a whitelisted url in the native browser? ie. mobile
> > safari
> >     there is no clear path to targeting ALL 3 possibilities or a)the app
> > page, b) the InAppBrowser, c) the system browser ( for a whitelisted URL
> )
> >     it makes sense that you cannot open a file:// url in the system
> > browser + you cannot open a non-whitelisted url in the app.
> >
> > ----------------------------------------------------
> >
> > My comments:
> >
> > 1. This as Jesse points out, is not trivial on iOS. The "easy way" would
> > be to not allow this, but kick it out to the system browser (Mobile
> > Safari), and have that as a general rule, any non-whitelisted URLs for
> the
> > InAppBrowser are kicked out to the system browser. I don't know how hard
> it
> > is for Android.
> >
> > If we were to do this, we would have to temporarily allow the url to
> > bypass the whitelist which could be kludgy (since we can't know what
> other
> > URLs that URL will load) -- essentially this issue
> > http://issues.cordova.io/1695 would totally solve this correctly, but we
> > don't have a solution yet for that issue.
>

I spent some time playing with how to do this.
1 - Use referer header - Too many situations result in no header, so this
is out!
2 - Use Cookies - if there were a way to have UIWebViews use separate
cookie jars, this might be feasible. Don't think that's possible.
3 - Use User-Agent - this is already suggested in CB-1695. I also found
this:
http://stackoverflow.com/questions/12180224/unique-tab-id-appended-to-user-agent-string-in-chrome-for-ios,
which suggests that this is what Chrome for iOS uses to implement incognito
mode. If they can make it work, then we should be able to as well!

So, this is looking like it's non-trivial but not impossible! As long as
it's possible, let's implement it :)


>  >
> > 2. This case has not been addressed. I would think _blank would be the
> > case but this is specified as the InAppBrowser here. How about this case,
> > we could use _parent for InAppBrowser, but _blank for system browser?
> > However, this would not be consistent with how the other calls are
> > specified (unless we change the others to be consistent).
> >
> > Another possible solution is to kick out to the system browser if an
> > unknown value is used (some random value), that will use the system
> > browser, which is consistent with how window.open works.
> >
>

I don't think the semantics of _parent and _blank really map well to what
we're doing. My vote is to create a new special value: _system, and only
this target kicks you out to the system browser.

Also: on the wiki we have:
[F]  window.open('http://random-url.com', '_blank'); // native browser

It seems weird to me that the effect of _blank changes based on whether the
URL is in the whitelist. I'd think this case would also open in the
InAppBrowser.


Summary of what I think:
_self or no target --> open in cordova webview if it's in the Whitelist,
InAppBrowser otherwise
_system --> open in system browser
anything else --> open in InAppBrowser

Also, I like Simon's idea of using the options in window.open to specify
whether to show URL bar etc. :)

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message