diff --git a/docshell/base/BrowsingContext.cpp b/docshell/base/BrowsingContext.cpp index e7ab9ef7340d..6fcff1c28cab 100644 --- a/docshell/base/BrowsingContext.cpp +++ b/docshell/base/BrowsingContext.cpp @@ -43,6 +43,7 @@ #include "xpcprivate.h" #include "AutoplayPolicy.h" +#include "GVAutoplayRequestStatusIPC.h" extern mozilla::LazyLogModule gAutoplayPermissionLog; @@ -1229,6 +1230,26 @@ void BrowsingContext::StartDelayedAutoplayMediaComponents() { mDocShell->StartDelayedAutoplayMediaComponents(); } +void BrowsingContext::ResetGVAutoplayRequestStatus() { + MOZ_ASSERT(!GetParent(), + "Should only set GVAudibleAutoplayRequestStatus in the top-level " + "browsing context"); + SetGVAudibleAutoplayRequestStatus(GVAutoplayRequestStatus::eUNKNOWN); + SetGVInaudibleAutoplayRequestStatus(GVAutoplayRequestStatus::eUNKNOWN); +} + +void BrowsingContext::DidSetGVAudibleAutoplayRequestStatus() { + MOZ_ASSERT(!GetParent(), + "Should only set GVAudibleAutoplayRequestStatus in the top-level " + "browsing context"); +} + +void BrowsingContext::DidSetGVInaudibleAutoplayRequestStatus() { + MOZ_ASSERT(!GetParent(), + "Should only set GVAudibleAutoplayRequestStatus in the top-level " + "browsing context"); +} + void BrowsingContext::DidSetUserActivationState() { MOZ_ASSERT_IF(!mIsInProcess, mUserGestureStart.IsNull()); USER_ACTIVATION_LOG("Set user gesture activation %" PRIu8 diff --git a/docshell/base/BrowsingContext.h b/docshell/base/BrowsingContext.h index 6d1cac6e7c39..7ce359288aa8 100644 --- a/docshell/base/BrowsingContext.h +++ b/docshell/base/BrowsingContext.h @@ -7,6 +7,7 @@ #ifndef mozilla_dom_BrowsingContext_h #define mozilla_dom_BrowsingContext_h +#include "GVAutoplayRequestUtils.h" #include "mozilla/Maybe.h" #include "mozilla/RefPtr.h" #include "mozilla/Tuple.h" @@ -391,6 +392,8 @@ class BrowsingContext : public nsISupports, void StartDelayedAutoplayMediaComponents(); + void ResetGVAutoplayRequestStatus(); + /** * Transaction object. This object is used to specify and then commit * modifications to synchronized fields in BrowsingContexts. @@ -553,6 +556,9 @@ class BrowsingContext : public nsISupports, void DidSetIsPopupSpam(); + void DidSetGVAudibleAutoplayRequestStatus(); + void DidSetGVInaudibleAutoplayRequestStatus(); + // Type of BrowsingContent const Type mType; diff --git a/docshell/base/BrowsingContextFieldList.h b/docshell/base/BrowsingContextFieldList.h index ac676c53b2d7..7dd422de2b1e 100644 --- a/docshell/base/BrowsingContextFieldList.h +++ b/docshell/base/BrowsingContextFieldList.h @@ -46,4 +46,10 @@ MOZ_BC_FIELD(HistoryID, nsID) MOZ_BC_FIELD(InRDMPane, bool) +// These field are used to store the states of autoplay media request on +// GeckoView only, and it would only be modified on the top level browsing +// context. +MOZ_BC_FIELD(GVAudibleAutoplayRequestStatus, GVAutoplayRequestStatus) +MOZ_BC_FIELD(GVInaudibleAutoplayRequestStatus, GVAutoplayRequestStatus) + #undef MOZ_BC_FIELD diff --git a/dom/media/GVAutoplayRequestStatusIPC.h b/dom/media/GVAutoplayRequestStatusIPC.h new file mode 100644 index 000000000000..d3b36d171dbf --- /dev/null +++ b/dom/media/GVAutoplayRequestStatusIPC.h @@ -0,0 +1,23 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef DOM_MEDIA_GVAUTOPLAYREQUESTSTATUSIPC_H_ +#define DOM_MEDIA_GVAUTOPLAYREQUESTSTATUSIPC_H_ + +#include "ipc/IPCMessageUtils.h" + +#include "GVAutoplayRequestUtils.h" + +namespace IPC { + +template <> +struct ParamTraits + : public ContiguousEnumSerializerInclusive< + mozilla::dom::GVAutoplayRequestStatus, + mozilla::dom::GVAutoplayRequestStatus::eUNKNOWN, + mozilla::dom::GVAutoplayRequestStatus::ePENDING> {}; + +} // namespace IPC + +#endif // DOM_MEDIA_GVAUTOPLAYREQUESTSTATUSIPC_H_ diff --git a/dom/media/moz.build b/dom/media/moz.build index 1d75fb57ad0c..972a961a81e8 100644 --- a/dom/media/moz.build +++ b/dom/media/moz.build @@ -133,6 +133,7 @@ EXPORTS += [ 'ForwardedInputTrack.h', 'FrameStatistics.h', 'GVAutoplayPermissionRequest.h', + 'GVAutoplayRequestStatusIPC.h', 'GVAutoplayRequestUtils.h', 'ImageToI420.h', 'Intervals.h',