Commit 268b7a72 authored by Francois Beaufort's avatar Francois Beaufort Committed by Commit Bot

[WebNFC] Remove focused requirement.

Following Web NFC spec change at https://github.com/w3c/web-nfc/pull/303,
this CL makes sure NFC is not suspended when frame loses focus.

http://crrev.com/c/1862475 added a focused test but it wasn't working.
Later http://crrev.com/c/186439 fixed it and added a timeout test expectation.
This CL removes it as focus is not a requirement anymore.

Bug: 996250, 520391
Change-Id: I6b5d14796dc00c8d3c8634dd9caac6da337df10d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1764132
Commit-Queue: François Beaufort <beaufort.francois@gmail.com>
Reviewed-by: default avatarRijubrata Bhaumik <rijubrata.bhaumik@intel.com>
Reviewed-by: default avatarMike West <mkwst@chromium.org>
Cr-Commit-Position: refs/heads/master@{#708182}
parent f346c65c
...@@ -115,7 +115,7 @@ interface NFC { ...@@ -115,7 +115,7 @@ interface NFC {
CancelAllWatches () => (NDEFError? error); CancelAllWatches () => (NDEFError? error);
// Suspends all pending NFC operations. Could be used when web page // Suspends all pending NFC operations. Could be used when web page
// visibility or focus is lost. // visibility is lost.
SuspendNFCOperations(); SuspendNFCOperations();
// Resumes all suspended NFC operations. // Resumes all suspended NFC operations.
......
...@@ -7,7 +7,6 @@ ...@@ -7,7 +7,6 @@
#include <utility> #include <utility>
#include "third_party/blink/public/common/browser_interface_broker_proxy.h" #include "third_party/blink/public/common/browser_interface_broker_proxy.h"
#include "third_party/blink/renderer/core/page/focus_controller.h"
#include "third_party/blink/renderer/modules/nfc/ndef_reader.h" #include "third_party/blink/renderer/modules/nfc/ndef_reader.h"
#include "third_party/blink/renderer/modules/nfc/ndef_writer.h" #include "third_party/blink/renderer/modules/nfc/ndef_writer.h"
#include "third_party/blink/renderer/modules/nfc/nfc_type_converters.h" #include "third_party/blink/renderer/modules/nfc/nfc_type_converters.h"
...@@ -36,7 +35,6 @@ NFCProxy* NFCProxy::From(Document& document) { ...@@ -36,7 +35,6 @@ NFCProxy* NFCProxy::From(Document& document) {
// NFCProxy // NFCProxy
NFCProxy::NFCProxy(Document& document) NFCProxy::NFCProxy(Document& document)
: PageVisibilityObserver(document.GetPage()), : PageVisibilityObserver(document.GetPage()),
FocusChangedObserver(document.GetPage()),
Supplement<Document>(document), Supplement<Document>(document),
client_receiver_(this) {} client_receiver_(this) {}
...@@ -50,7 +48,6 @@ void NFCProxy::Trace(blink::Visitor* visitor) { ...@@ -50,7 +48,6 @@ void NFCProxy::Trace(blink::Visitor* visitor) {
visitor->Trace(writers_); visitor->Trace(writers_);
visitor->Trace(readers_); visitor->Trace(readers_);
PageVisibilityObserver::Trace(visitor); PageVisibilityObserver::Trace(visitor);
FocusChangedObserver::Trace(visitor);
Supplement<Document>::Trace(visitor); Supplement<Document>::Trace(visitor);
} }
...@@ -147,14 +144,6 @@ void NFCProxy::OnReaderRegistered(NDEFReader* reader, ...@@ -147,14 +144,6 @@ void NFCProxy::OnReaderRegistered(NDEFReader* reader,
} }
void NFCProxy::PageVisibilityChanged() { void NFCProxy::PageVisibilityChanged() {
UpdateSuspendedStatus();
}
void NFCProxy::FocusedFrameChanged() {
UpdateSuspendedStatus();
}
void NFCProxy::UpdateSuspendedStatus() {
// If service is not initialized, there cannot be any pending NFC activities. // If service is not initialized, there cannot be any pending NFC activities.
if (!nfc_remote_) if (!nfc_remote_)
return; return;
...@@ -163,28 +152,12 @@ void NFCProxy::UpdateSuspendedStatus() { ...@@ -163,28 +152,12 @@ void NFCProxy::UpdateSuspendedStatus() {
// https://w3c.github.io/web-nfc/#nfc-suspended // https://w3c.github.io/web-nfc/#nfc-suspended
// TODO(https://crbug.com/520391): Suspend/Resume NFC in the browser process // TODO(https://crbug.com/520391): Suspend/Resume NFC in the browser process
// instead to prevent a compromised renderer from using NFC in the background. // instead to prevent a compromised renderer from using NFC in the background.
if (ShouldSuspendNFC()) if (!GetPage()->IsPageVisible())
nfc_remote_->SuspendNFCOperations(); nfc_remote_->SuspendNFCOperations();
else else
nfc_remote_->ResumeNFCOperations(); nfc_remote_->ResumeNFCOperations();
} }
bool NFCProxy::ShouldSuspendNFC() const {
if (!GetPage()->IsPageVisible())
return true;
LocalFrame* focused_frame = GetPage()->GetFocusController().FocusedFrame();
LocalFrame* this_frame = GetSupplementable()->GetFrame();
if (!focused_frame || !this_frame)
return true;
if (focused_frame != this_frame)
return true;
return false;
}
void NFCProxy::EnsureMojoConnection() { void NFCProxy::EnsureMojoConnection() {
if (nfc_remote_) if (nfc_remote_)
return; return;
......
...@@ -9,7 +9,6 @@ ...@@ -9,7 +9,6 @@
#include "mojo/public/cpp/bindings/remote.h" #include "mojo/public/cpp/bindings/remote.h"
#include "services/device/public/mojom/nfc.mojom-blink.h" #include "services/device/public/mojom/nfc.mojom-blink.h"
#include "third_party/blink/renderer/core/dom/document.h" #include "third_party/blink/renderer/core/dom/document.h"
#include "third_party/blink/renderer/core/page/focus_changed_observer.h"
#include "third_party/blink/renderer/core/page/page_visibility_observer.h" #include "third_party/blink/renderer/core/page/page_visibility_observer.h"
#include "third_party/blink/renderer/modules/modules_export.h" #include "third_party/blink/renderer/modules/modules_export.h"
#include "third_party/blink/renderer/platform/wtf/hash_map.h" #include "third_party/blink/renderer/platform/wtf/hash_map.h"
...@@ -25,7 +24,6 @@ class NDEFWriter; ...@@ -25,7 +24,6 @@ class NDEFWriter;
// to implementation of device::mojom::blink::NFC interface. // to implementation of device::mojom::blink::NFC interface.
class MODULES_EXPORT NFCProxy final : public GarbageCollected<NFCProxy>, class MODULES_EXPORT NFCProxy final : public GarbageCollected<NFCProxy>,
public PageVisibilityObserver, public PageVisibilityObserver,
public FocusChangedObserver,
public Supplement<Document>, public Supplement<Document>,
public device::mojom::blink::NFCClient { public device::mojom::blink::NFCClient {
USING_GARBAGE_COLLECTED_MIXIN(NFCProxy); USING_GARBAGE_COLLECTED_MIXIN(NFCProxy);
...@@ -68,12 +66,6 @@ class MODULES_EXPORT NFCProxy final : public GarbageCollected<NFCProxy>, ...@@ -68,12 +66,6 @@ class MODULES_EXPORT NFCProxy final : public GarbageCollected<NFCProxy>,
// Implementation of PageVisibilityObserver. // Implementation of PageVisibilityObserver.
void PageVisibilityChanged() override; void PageVisibilityChanged() override;
// Implementation of FocusChangedObserver.
void FocusedFrameChanged() override;
void UpdateSuspendedStatus();
bool ShouldSuspendNFC() const;
void EnsureMojoConnection(); void EnsureMojoConnection();
// This could only happen when the embedder does not implement NFC interface. // This could only happen when the embedder does not implement NFC interface.
......
...@@ -5764,7 +5764,6 @@ crbug.com/1014950 [ Mac ] virtual/threaded/http/tests/devtools/tracing/timeline- ...@@ -5764,7 +5764,6 @@ crbug.com/1014950 [ Mac ] virtual/threaded/http/tests/devtools/tracing/timeline-
crbug.com/1015187 [ Linux Mac ] virtual/cross-origin-embedder-policy/external/wpt/html/cross-origin-embedder-policy/none.https.html [ Pass Failure ] crbug.com/1015187 [ Linux Mac ] virtual/cross-origin-embedder-policy/external/wpt/html/cross-origin-embedder-policy/none.https.html [ Pass Failure ]
# Sheriff 2019-10-18 # Sheriff 2019-10-18
crbug.com/996250 external/wpt/web-nfc/NDEFReader_scan_iframe.https.html [ Timeout ]
crbug.com/1015254 [ Mac ] external/wpt/pointerevents/extension/pointerevent_coalesced_events_attributes.html [ Pass Failure ] crbug.com/1015254 [ Mac ] external/wpt/pointerevents/extension/pointerevent_coalesced_events_attributes.html [ Pass Failure ]
crbug.com/1015859 [ Linux ] http/tests/devtools/a11y-axe-core/performance/landing-page-a11y-test.js [ Pass Failure ] crbug.com/1015859 [ Linux ] http/tests/devtools/a11y-axe-core/performance/landing-page-a11y-test.js [ Pass Failure ]
crbug.com/1015975 media/video-currentTime.html [ Pass Failure ] crbug.com/1015975 media/video-currentTime.html [ Pass Failure ]
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment