diff --git a/index.html b/index.html
index 07e1fb6..6bee8db 100644
--- a/index.html
+++ b/index.html
@@ -283,87 +283,64 @@
- Launching a Web App
+ Launching a Web App with Handling
- When launching a web app via any means the trigger of the launch
- should run the steps to [=launch a web app=] with a {{LaunchParams}}
- containing relevant launch information (e.g. share data in the event
- of a share target launch).
+ This specification replaces the existing algorithm to [=launch a web
+ application=] to include the behavior of [=manifest/launch_handler=]
+ by replacing it with the steps to [=launch a web application with
+ handling=].
-
- Examples of different web app launch triggers:
-
-
- The steps to launch a web app are given by the following
- algorithm and takes an optional {{LaunchParams}}
- |params:LaunchParams|.
+ The steps to
+ launch a web application with handling are given by the
+ following algorithm. The algorithm takes a [=Document/processed
+ manifest=] |manifest:processed manifest|, an optional [=URL=] or
+ {{LaunchParams}} |params|, an optional [=POST resource=] |POST
+ resource| and returns an [=application context=].
- - If |params| is null, set |params| to a new {{LaunchParams}} with
- {{LaunchParams/targetURL}} set to [=manifest/start_url=].
+
- If |params| is not given, set |params| to
+ |manifest|.[=manifest/start_url=].
- - Set |client| to the result of running the steps to
- [=prepare a web app launch client=] passing the web app's
- processed
- manifest and |params|.{{LaunchParams/targetURL}}.
+
- If |params| is a [=URL=], set |params| to a new {{LaunchParams}}
+ with {{LaunchParams/targetURL}} set to |params|.
+
+ - Assert: |params|.{{LaunchParams/targetURL}} is [=manifest/within
+ scope=] of |manifest|.
+
+ - Set |application context| to the result of running the steps to
+ [=prepare an application context=] passing |manifest|, |params|
+ and |POST resource|.
- Append |params| to the [=unconsumed launch params=] of the
- |client|'s document's {{Window/launchQueue}}.
+ |application context|'s document's {{Window/launchQueue}}.
- Run the steps to [=process unconsumed launch params=] on the
- |client|'s document's {{Window/launchQueue}}.
+ |application context|'s [=navigable/active document=]'s
+ {{Window/launchQueue}}.
- |client| may be an existing window client with an
+ |application context| may be an existing instance with an
[=assigned launch consumer=] hence it is necessary to process
- the newly appended |params|.
+ the newly appended {{LaunchParams}}.
-
-
-
- Preparing a [=Web App Launch Client=]
-
- A web app launch client is a
- [=top-level browsing context=] associated with the web app.
-
-
- The exact form of this association is up to the user agent e.g. a
- dedicated app window separate UI presentation from general hyperlink
- browsing.
-
-
- To prepare a web app launch client given a
- processed
- manifest |manifest| and |target URL: URL|, run the following
- steps:
+ The steps to prepare an application context are given by
+ the following algorithm. The algorithm takes a
+ [=Document/processed manifest=] |manifest:processed manifest|, a
+ {{LaunchParams}} |launch params|, an optional [=POST
+ resource=] |POST resource| and returns an [=application context=].
- Let [=client mode target=] |client_mode| be
- |manifest|["launch_handler"]["client_mode"].
+ |manifest|.[=manifest/launch_handler=].[=manifest/client_mode=].
- - If |client_mode| is [=client mode/auto=], set |client_mode| to either
- [=client mode/navigate-new=] or [=client mode/navigate-existing=]
- according to the user agent's decision for which is most
- appropriate.
+
- If |client_mode| is [=client mode/auto=], set |client_mode| to
+ either [=client mode/navigate-new=] or
+ [=client mode/navigate-existing=] according to the user agent's
+ decision for which is most appropriate.
-
Switching on |client mode|, run the following substeps:
@@ -371,57 +348,43 @@
- [=client mode/navigate-new=]
-
- - Return the result of running the steps to [=prepare a new
- web app launch client=] passing |manifest| and
- |target URL|.
+
- Return the result of running the steps to [=create a new
+ application context=] passing |manifest|, |launch
+ params|.{{LaunchParams/targetURL}} and |POST resource|.
- [=client mode/navigate-existing=] or
[=client mode/focus-existing=]
-
- - If there is no [=top-level browsing context=] for
- the web app, return the result of the result of
- [=prepare a new web app launch client=] passing |manifest|
- and |target URL|.
+
- If there is no [=application context=] that has |manifest|
+ [=applied=], return the result of running the steps to
+ [=create a new application context=] passing |manifest|,
+ |launch params|.{{LaunchParams/targetURL}} and |POST
+ resource|.
- - Let |client| be a [=top-level browsing context=]
- for the web app, the exact selection algorithm is decided
- by the user agent.
+
- Let |application context| be an [=application context=]
+ that has |manifest| [=applied=], the user agent selects
+ the most appropriate one if there are multiple.
+
+ An appropriate selection strategy would be to pick the
+ one that was most recently in focus.
+
+
+ - Bring |application context|'s viewport into focus.
- If |client mode| is [=client mode/navigate-existing=],
- run the steps to [=navigate=] |client| to |target URL|.
+ [=navigate=] |application context| to |launch
+ params|.{{LaunchParams/targetURL}} passing |POST
+ resource|.
- - Return |client|.
+
- Return |application context|.
-
-
- Preparing a new [=Web App Launch Client=]
-
-
- To prepare a new web app launch client given a
- processed
- manifest |manifest| and |target URL:URL|, run the following steps:
-
-
- - Let |client| be the result of
-
- creating a new top-level browsing context.
-
- - Apply |manifest| to
- |client|.
-
- - Run the steps to [=navigate=] |client| passing |target URL|.
-
- - Return |client|.
-
-
-
Processing [=unconsumed launch params=]