Closed
Bug 575750
Opened 14 years ago
Closed 14 years ago
Implement support for OS protocol handlers on Android
Categories
(Core Graveyard :: Widget: Android, defect)
Tracking
(fennec2.0a1+)
RESOLVED
FIXED
Tracking | Status | |
---|---|---|
fennec | 2.0a1+ | --- |
People
(Reporter: blassey, Assigned: blassey)
References
Details
Attachments
(1 file, 2 obsolete files)
17.62 KB,
patch
|
mwu
:
review+
bzbarsky
:
review+
|
Details | Diff | Splinter Review |
We currently don't implement any of functions used to query the OS about protocol handlers. Most of the functionality for this already exists for querying handlers for mime types. Mwu, could you please review the widget parts of this patch and Benjamin the uriloader and xpcom parts? Thanks.
Attachment #454933 -
Flags: review?(mwu)
Attachment #454933 -
Flags: review?(benjamin)
Assignee | ||
Comment 1•14 years ago
|
||
please disregard lines 94 and 95 of nsAndroidHandlerApp.cpp, I will delete them before pushing
Assignee | ||
Updated•14 years ago
|
tracking-fennec: --- → 2.0+
Assignee | ||
Comment 2•14 years ago
|
||
with function names per mwu's request
Assignee: nobody → blassey.bugs
Attachment #454933 -
Attachment is obsolete: true
Attachment #454942 -
Flags: review?(mwu)
Attachment #454942 -
Flags: review?(benjamin)
Attachment #454933 -
Flags: review?(mwu)
Attachment #454933 -
Flags: review?(benjamin)
Comment 3•14 years ago
|
||
Comment on attachment 454942 [details] [diff] [review] patch >@@ -280,10 +306,17 @@ class GeckoAppShell > return android.webkit.MimeTypeMap.getSingleton().getMimeTypeFromExtension(aFileExt); > } > >- static boolean openUriExternal(String aUriSpec, String aMimeType) { >+ static boolean openUriExternal(String aUriSpec, String aMimeType, >+ String aPackageName, String aClassName) { > // XXX: It's not clear if we should set the action to view or leave it open > Intent intent = new Intent(Intent.ACTION_VIEW); >- intent.setDataAndType(android.net.Uri.parse(aUriSpec), aMimeType); >+ if (aMimeType.length() > 0) >+ intent.setDataAndType(android.net.Uri.parse(aUriSpec), aMimeType); >+ else >+ intent.setData(android.net.Uri.parse(aUriSpec)); >+ if (aPackageName.length() > 0 && aClassName.length() > 0) >+ intent.setClassName(aPackageName, aClassName); >+ > intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); > try { > GeckoApp.surfaceView.getContext().startActivity(intent); Looks like android.net.Uri is used enough that you should just import it. >diff -r 5298bae2eb91 -r 70022c7d6d48 uriloader/exthandler/android/nsOSHelperAppService.cpp >--- a/uriloader/exthandler/android/nsOSHelperAppService.cpp Mon Jun 28 03:12:07 2010 -0400 >+++ b/uriloader/exthandler/android/nsOSHelperAppService.cpp Tue Jun 29 16:35:31 2010 -0400 >@@ -37,6 +37,7 @@ > > #include "nsOSHelperAppService.h" > #include "nsMIMEInfoAndroid.h" >+#include "AndroidBridge.h" > > nsOSHelperAppService::nsOSHelperAppService() : nsExternalHelperAppService() > { >@@ -66,6 +67,20 @@ nsresult > nsOSHelperAppService::OSProtocolHandlerExists(const char* aScheme, > PRBool* aExists) > { >- *aExists = PR_FALSE; >+ mozilla::AndroidBridge* bridge = mozilla::AndroidBridge::Bridge(); >+ nsStringArray stringArray; >+ bridge->GetHandlersForProtocol(nsCAutoString(aScheme).get(), &stringArray); >+ >+ nsString empty = EmptyString(); >+ PRInt32 len = stringArray.Count(); >+ *aExists = len != 0; > return NS_OK; > } Can we have GetHandlersForProtocol return true/false if there are any handlers? Then there will be no need to create a stringArray that ends up just getting counted and thrown away. Also, nsCAutoString should not be needed here.. >diff -r 5298bae2eb91 -r 70022c7d6d48 widget/src/android/AndroidBridge.h >--- a/widget/src/android/AndroidBridge.h Mon Jun 28 03:12:07 2010 -0400 >+++ b/widget/src/android/AndroidBridge.h Tue Jun 29 16:35:31 2010 -0400 >@@ -104,9 +104,12 @@ public: > void SetSurfaceView(jobject jobj); > AndroidGeckoSurfaceView& SurfaceView() { return mSurfaceView; } > >+ void GetHandlersForProtocol(const char *aScheme, nsStringArray* aStringArray); >+ > void GetHandlersForMimeType(const char *aMimeType, nsStringArray* aStringArray); > >- PRBool OpenUriExternal(nsCString& aUriSpec, nsCString& aMimeType); >+ PRBool OpenUriExternal(const nsCString& aUriSpec, const nsCString& aMimeType, >+ const nsString& aPackageName, const nsString& aClassName); > > void GetMimeTypeFromExtension(const nsCString& aFileExt, nsCString& aMimeType); > Can we set defaults for aPackageName and aClassName? Also, aren't we suppose to use the abstract string classes? That will let us use nsAutoString in the callers or whatever concrete string class the caller would prefer to use.
Assignee | ||
Comment 4•14 years ago
|
||
Attachment #454942 -
Attachment is obsolete: true
Attachment #455053 -
Flags: review?(mwu)
Attachment #455053 -
Flags: review?(benjamin)
Attachment #454942 -
Flags: review?(mwu)
Attachment #454942 -
Flags: review?(benjamin)
Comment 5•14 years ago
|
||
Comment on attachment 455053 [details] [diff] [review] patch The NS_PRECONDITION in GetHandlersForProtocol is probably not needed anymore. I'm not too familiar with what the code needs to do but it looks reasonable enough.
Attachment #455053 -
Flags: review?(mwu) → review+
Assignee | ||
Comment 6•14 years ago
|
||
(In reply to comment #5) > (From update of attachment 455053 [details] [diff] [review]) > The NS_PRECONDITION in GetHandlersForProtocol is probably not needed anymore. > I'm not too familiar with what the code needs to do but it looks reasonable > enough. Ah yes, that should definitely go. Thanks for catching it.
Assignee | ||
Comment 7•14 years ago
|
||
Comment on attachment 455053 [details] [diff] [review] patch bsmedberg suggested that bz would be a better reviewer or could suggest a better reviewer
Attachment #455053 -
Flags: review?(benjamin) → review?(bzbarsky)
Assignee | ||
Updated•14 years ago
|
tracking-fennec: 2.0+ → 2.0a1+
Comment 8•14 years ago
|
||
Comment on attachment 455053 [details] [diff] [review] patch >+ nsString empty = EmptyString(); >+ nsCString emptyC = EmptyCString(); Make those const refs; no need to construct separate objects. > + // the chooser dialog currently causes a crash on Android, avoid this by returning false here > + // but be sure to return mAlwaysAsk when that gets fixed This comment should contain a bug number. Note that not asking when you need to is a likely security issue, since it leads to automatic handling of content by possibly-insecure apps... > + mMimeType(aMIMEType), mAlwaysAsk(PR_FALSE), Why this change? I don't think we should change that. r=me with those fixed.
Attachment #455053 -
Flags: review?(bzbarsky) → review+
Comment 10•14 years ago
|
||
pushed with nits from comment 8 fixed: http://hg.mozilla.org/mozilla-central/rev/aeaac11e5c73
Status: NEW → RESOLVED
Closed: 14 years ago
Resolution: --- → FIXED
Updated•3 years ago
|
Product: Core → Core Graveyard
You need to log in
before you can comment on or make changes to this bug.
Description
•