[webnfc] Create NfcHost per-NFC Mojo connection rather than per-WebContentsImpl
The java object NfcHost is for tracking the Activity for a given
WebContents on behalf of NFCImpl (Impl of the NFC interface), previously
it's created per-WebContentsImpl, due to navigations happening on the
given WebContentsImpl it may end up in a state serving multiple NFCImpls
because NFCImpl exists per-Document, which breaks the assumption that
one NfcHost can only serve one client otherwise it can not work well
with WindowEventObserverManager of the WebContentsImpl.
This CL starts to create multiple NfcHosts for navigations on the same
WebContentsImpl rather than reusing just one instance of it.
BUG=520391
Change-Id: Ice15b70d5df705be0165620579586f1ff597af99
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1747859
Commit-Queue: Leon Han <[email protected]>
Reviewed-by: Leon Han <[email protected]>
Reviewed-by: Bo <[email protected]>
Reviewed-by: Reilly Grant <[email protected]>
Reviewed-by: Rijubrata Bhaumik <[email protected]>
Cr-Commit-Position: refs/heads/master@{#690258}
diff --git a/content/browser/web_contents/web_contents_impl.cc b/content/browser/web_contents/web_contents_impl.cc
index 0db5cf0..3acf8bb3 100644
--- a/content/browser/web_contents/web_contents_impl.cc
+++ b/content/browser/web_contents/web_contents_impl.cc
@@ -171,6 +171,7 @@
#if defined(OS_ANDROID)
#include "content/browser/android/date_time_chooser_android.h"
#include "content/browser/android/java_interfaces_impl.h"
+#include "content/browser/android/nfc_host.h"
#include "content/browser/web_contents/web_contents_android.h"
#include "services/device/public/mojom/nfc.mojom.h"
#else // !OS_ANDROID
@@ -3286,9 +3287,8 @@
#if defined(OS_ANDROID)
void WebContentsImpl::GetNFC(device::mojom::NFCRequest request) {
- if (!nfc_host_)
- nfc_host_.reset(new NFCHost(this));
- nfc_host_->GetNFC(std::move(request));
+ NFCHost nfc_host(this);
+ nfc_host.GetNFC(std::move(request));
}
#endif