Closed Bug 572605 Opened 10 years ago Closed 10 years ago

Handle intents/links from other apps while Fennec is already running

Categories

(Core :: Widget: Android, defect)

All
Android
defect
Not set

Tracking

()

RESOLVED FIXED

People

(Reporter: mbrubeck, Assigned: mbrubeck)

References

Details

Attachments

(1 file, 4 obsolete files)

Attached patch WIP (obsolete) — Splinter Review
We need to implement Activity.onNewIntent so that we can handle intents sent while our activity is already running.

The attached patch is incomplete, more is coming.
Attached patch patch (obsolete) — Splinter Review
Here's a working patch that handles the ACTION_VIEW intent.  Still need to add and test ACTION_WEB_SEARCH.
Attachment #451819 - Attachment is obsolete: true
Comment on attachment 451946 [details] [diff] [review]
patch

ACTION_WEB_SEARCH looks like it will require totally different logic.  Let's go ahead and land this and add that one separately.
Attachment #451946 - Attachment description: WIP 2 → patch
Attachment #451946 - Flags: review?(mwu)
Comment on attachment 451946 [details] [diff] [review]
patch

Please use the existing string field (mCharacters). The fields change meaning depending on event type. Also, add a new constructor for GeckoEvent which automatically sets the right event type and string.

The event posting stuff on the java wrapper side will be fixed eventually - the current event handling is an artifact of the old java wrapper code which put the event queue in the java wrapper.
Attachment #451946 - Flags: review?(mwu) → review-
Attached patch patch v2 (obsolete) — Splinter Review
- Use the existing mCharacters field.
- Add a new GeckoEvent(String uri) constructor.
Attachment #451946 - Attachment is obsolete: true
Attachment #452050 - Flags: review?(mwu)
Comment on attachment 452050 [details] [diff] [review]
patch v2

>-AndroidGeckoEvent::ReadCharactersField(JNIEnv *jenv)
>+AndroidGeckoEvent::ReadStringField(JNIEnv *jenv, jfieldID field, nsString &str)
> {
>-    jstring s = (jstring) jenv->GetObjectField(wrapped_obj, jCharactersField);
>+    jstring s = (jstring) jenv->GetObjectField(wrapped_obj, field);
>     if (!s) {
>-        mCharacters.SetIsVoid(PR_TRUE);
>+        str.SetIsVoid(PR_TRUE);
>         return;
>     }
> 
>     int len = jenv->GetStringLength(s);
>-    mCharacters.SetLength(len);
>-    jenv->GetStringRegion(s, 0, len, mCharacters.BeginWriting());
>+    str.SetLength(len);
>+    jenv->GetStringRegion(s, 0, len, str.BeginWriting());
> }
These changes can mostly be reverted now, though feel free to keep the rename to ReadStringField if you prefer that name.

>+    case AndroidGeckoEvent::LOAD_URI: {
>+        nsCOMPtr<nsICommandLineRunner> cmdline
>+            (do_CreateInstance("@mozilla.org/toolkit/command-line;1"));
>+        if (cmdline) {
Break early if there's no cmdline.

>+            char* argv[3] = {
>+                "dummyappname",
>+                "-remote",
>+                ToNewUTF8String(curEvent->Characters())
>+            };
>+            nsresult rv = cmdline->Init(3, argv, nsnull, nsICommandLine::STATE_REMOTE_AUTO);
>+            if (NS_SUCCEEDED(rv))
>+                cmdline->Run();
>+        }
>+        break;
>+    }
>+
Leak. Free the new string with nsMemory::Free.

Looks pretty close now! r+ with these issues fixed.
Attachment #452050 - Flags: review?(mwu) → review+
Attached patch patch v3 (obsolete) — Splinter Review
- Revert the GetStringField changes.
- nsMemory::Free the allocated string.
Attachment #452050 - Attachment is obsolete: true
Attachment #452133 - Flags: review?(mwu)
Attached patch patch v4Splinter Review
Same patch, rebased against latest mozilla-central.  But with the latest m-c, I am now getting NS_ERROR_UNEXPECTED in nsINavBookmarksService.getBookmarkIdsForURI, PlacesUtils.jsm:953 when opening a link from another apps, and the content of the new tab does not render.

This is triggered at http://mxr.mozilla.org/mobile-browser/source/chrome/content/browser-ui.js#592 - when I wrap updateStar in a try/catch block then the new tab renders correctly (but the star is not updated).  I'm not sure what caused this, still investigating.
Attachment #452133 - Attachment is obsolete: true
Attachment #452282 - Flags: review?(mwu)
Attachment #452133 - Flags: review?(mwu)
I switched to using an early break and added a null check for the converted string.

http://hg.mozilla.org/mozilla-central/rev/b0db6edc6d67
Status: ASSIGNED → RESOLVED
Closed: 10 years ago
Resolution: --- → FIXED
Attachment #452282 - Flags: review?(mwu) → review+
Depends on: 573153
You need to log in before you can comment on or make changes to this bug.