bluetooth: Scan Tab Indicator
This change adds a tab indicator that is visible when a Bluetooth scan
session is active. A scan session may be started through the Web
Bluetooth API's watchAdvertisements() method or through the Web
Bluetooth Scanning API's requestLEScan() method.
Design Doc:
https://docs.google.com/document/d/1h3uAVXJARHrNWaNACUPiQhLt7XI-fFFQoARSs1WgMDM
Bug: 1099914
Change-Id: Ieb1bc385b5da6d2c8a98bdf263751fe549c097a7
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2270815
Commit-Queue: Ovidio de Jesús Ruiz-Henríquez <[email protected]>
Reviewed-by: Carlos Pizano <[email protected]>
Reviewed-by: Scott Violet <[email protected]>
Reviewed-by: Yuri Wiitala <[email protected]>
Cr-Commit-Position: refs/heads/master@{#786137}
diff --git a/content/browser/web_contents/web_contents_impl.cc b/content/browser/web_contents/web_contents_impl.cc
index 2a2a7bb..790018a 100644
--- a/content/browser/web_contents/web_contents_impl.cc
+++ b/content/browser/web_contents/web_contents_impl.cc
@@ -1681,6 +1681,10 @@
return bluetooth_connected_device_count_ > 0;
}
+bool WebContentsImpl::IsScanningForBluetoothDevices() {
+ return bluetooth_scanning_sessions_count_ > 0;
+}
+
bool WebContentsImpl::IsConnectedToSerialPort() {
return serial_active_frame_count_ > 0;
}
@@ -7027,6 +7031,30 @@
}
}
+void WebContentsImpl::IncrementBluetoothScanningSessionsCount() {
+ // Trying to invalidate the tab state while being destroyed could result in a
+ // use after free.
+ if (IsBeingDestroyed())
+ return;
+
+ // Notify for UI updates if the state changes.
+ bluetooth_scanning_sessions_count_++;
+ if (bluetooth_scanning_sessions_count_ == 1)
+ NotifyNavigationStateChanged(INVALIDATE_TYPE_TAB);
+}
+
+void WebContentsImpl::DecrementBluetoothScanningSessionsCount() {
+ // Trying to invalidate the tab state while being destroyed could result in a
+ // use after free.
+ if (IsBeingDestroyed())
+ return;
+
+ DCHECK_NE(0u, bluetooth_scanning_sessions_count_);
+ bluetooth_scanning_sessions_count_--;
+ if (bluetooth_scanning_sessions_count_ == 0)
+ NotifyNavigationStateChanged(INVALIDATE_TYPE_TAB);
+}
+
void WebContentsImpl::IncrementSerialActiveFrameCount() {
// Trying to invalidate the tab state while being destroyed could result in a
// use after free.