device posture: Exit DisableDevicePostureOverrideForEmulation() early when there is no override

This matches the behavior in the spec more closely.

If we do not bail out earlier, all calls to
DisableDevicePostureOverrideForEmulation() will invoke
OnPostureChange(), which is suboptimal.

Change-Id: Icdcbace514ccf63eab7387e7bff75deab5530638
Bug: 330376761
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5424961
Auto-Submit: Raphael Kubo Da Costa <raphael.kubo.da.costa@intel.com>
Reviewed-by: Reilly Grant <reillyg@chromium.org>
Reviewed-by: Alexis Menard <alexis.menard@intel.com>
Commit-Queue: Raphael Kubo Da Costa <raphael.kubo.da.costa@intel.com>
Cr-Commit-Position: refs/heads/main@{#1283373}
diff --git a/content/browser/device_posture/device_posture_provider_impl.cc b/content/browser/device_posture/device_posture_provider_impl.cc
index df33e15..6ce8c665 100644
--- a/content/browser/device_posture/device_posture_provider_impl.cc
+++ b/content/browser/device_posture/device_posture_provider_impl.cc
@@ -64,6 +64,12 @@
 }
 
 void DevicePostureProviderImpl::DisableDevicePostureOverrideForEmulation() {
+  // If the posture is not being overridden, bail out earlier to avoid
+  // needlessly calling OnPostureChanged().
+  if (!is_posture_emulated_) {
+    return;
+  }
+
   // Restore the original posture from the platform.
   is_posture_emulated_ = false;
   for (auto& client : posture_clients_) {