Extract the code related to postMessage out of CustomTabActivity and DynamicModuleCoordinator into a CustomTabsPostMessageController. It should track the tab changes using CustomTabActivityNavigationController (https://crbug/916518) and reset the postMessage handler accordingly, and provide the API for the clients. It shouldn't know about particular clients though; e.g. there shouldn't be mentions of the dynamic module.
See CustomTabsPostMessageController.java here for a rough idea how this class may look like: https://chromium-review.googlesource.com/c/chromium/src/+/1382496
Make DynamicModuleCoordinator and TrustedWebActivityCoordinator use
CustomTabsPostMessageController. In TWAs there's a couple of postMessage-related lines of code in TrustedWebActivityVerifier - move them into TrustedWebActivityCoordinator and make them use the new class.
Ensure the class is testable, write tests if there are any non-trivial edge-cases.
This is a part of CustomTabActivity refactoring plan described in
https://docs.google.com/document/d/1E9u-9eSFjLwVnUUIekhurmKk-8vsSDxek7cZiFd6ToY
Extract the code related to postMessage out of CustomTabActivity and DynamicModuleCoordinator into a CustomTabsPostMessageController. It should track the tab changes using CustomTabActivityNavigationController (https://crbug/916518) and reset the postMessage handler accordingly, and provide the API for the clients. It shouldn't know about particular clients though; e.g. there shouldn't be mentions of the dynamic module.
See CustomTabsPostMessageController.java in https://crrev.com/1371805 for a rough idea how this class may look like.
Make DynamicModuleCoordinator and TrustedWebActivityCoordinator use
CustomTabsPostMessageController. In TWAs there's a couple of postMessage-related lines of code in TrustedWebActivityVerifier - move them into TrustedWebActivityCoordinator and make them use the new class.
Ensure the class is testable, write tests if there are any non-trivial edge-cases.
This is a part of CustomTabActivity refactoring plan described in
https://docs.google.com/document/d/1E9u-9eSFjLwVnUUIekhurmKk-8vsSDxek7cZiFd6ToY
Comment 1 by pshmakov@google.com
, Dec 19