зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1773043 - Remove flashblock from dom r=edgar
Differential Revision: https://phabricator.services.mozilla.com/D149128
This commit is contained in:
Родитель
a8c8f73787
Коммит
b86284ee81
|
@ -1442,7 +1442,6 @@ Document::Document(const char* aContentType)
|
|||
mViewportFit(ViewportFitType::Auto),
|
||||
mSubDocuments(nullptr),
|
||||
mHeaderData(nullptr),
|
||||
mFlashClassification(FlashClassification::Unknown),
|
||||
mServoRestyleRootDirtyBits(0),
|
||||
mThrowOnDynamicMarkupInsertionCounter(0),
|
||||
mIgnoreOpensDuringUnloadCounter(0),
|
||||
|
@ -4302,11 +4301,6 @@ bool Document::GetAllowPlugins() {
|
|||
}
|
||||
}
|
||||
|
||||
FlashClassification classification = DocumentFlashClassification();
|
||||
if (classification == FlashClassification::Denied) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -16610,52 +16604,6 @@ bool Document::IsExtensionPage() const {
|
|||
BasePrincipal::Cast(NodePrincipal())->AddonPolicy();
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the classification of the Flash plugins in the document based on
|
||||
* the classification lists. For more information, see
|
||||
* toolkit/components/url-classifier/flash-block-lists.rst
|
||||
*/
|
||||
FlashClassification Document::DocumentFlashClassification() {
|
||||
// Disable flash blocking when fission is enabled(See Bug 1584931).
|
||||
const auto fnIsFlashBlockingEnabled = [] {
|
||||
return StaticPrefs::plugins_flashBlock_enabled() && !FissionAutostart();
|
||||
};
|
||||
|
||||
// If neither pref is on, skip the null-principal and principal URI checks.
|
||||
if (!StaticPrefs::plugins_http_https_only() && !fnIsFlashBlockingEnabled()) {
|
||||
return FlashClassification::Unknown;
|
||||
}
|
||||
|
||||
if (!NodePrincipal()->GetIsContentPrincipal()) {
|
||||
return FlashClassification::Denied;
|
||||
}
|
||||
|
||||
if (StaticPrefs::plugins_http_https_only()) {
|
||||
// Only allow plugins for documents from an HTTP/HTTPS origin. This should
|
||||
// allow dependent data: URIs to load plugins, but not:
|
||||
// * chrome documents
|
||||
// * "bare" data: loads
|
||||
// * FTP/gopher/file
|
||||
|
||||
if (!(NodePrincipal()->SchemeIs("http") ||
|
||||
NodePrincipal()->SchemeIs("https"))) {
|
||||
return FlashClassification::Denied;
|
||||
}
|
||||
}
|
||||
|
||||
// If flash blocking is disabled, it is equivalent to all sites being
|
||||
// on neither list.
|
||||
if (!fnIsFlashBlockingEnabled()) {
|
||||
return FlashClassification::Unknown;
|
||||
}
|
||||
|
||||
if (mFlashClassification == FlashClassification::Unknown) {
|
||||
mFlashClassification = DocumentFlashClassificationInternal();
|
||||
}
|
||||
|
||||
return mFlashClassification;
|
||||
}
|
||||
|
||||
void Document::AddResizeObserver(ResizeObserver& aObserver) {
|
||||
if (!mResizeObserverController) {
|
||||
mResizeObserverController = MakeUnique<ResizeObserverController>(this);
|
||||
|
@ -16692,123 +16640,6 @@ void Document::ScheduleResizeObserversNotification() const {
|
|||
mResizeObserverController->ScheduleNotification();
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes |mIsThirdPartyForFlashClassifier| if necessary and returns its
|
||||
* value. The value returned represents whether this document should be
|
||||
* considered Third-Party.
|
||||
*
|
||||
* A top-level document cannot be a considered Third-Party; only subdocuments
|
||||
* may. For a subdocument to be considered Third-Party, it must meet ANY ONE
|
||||
* of the following requirements:
|
||||
* - The document's parent is Third-Party
|
||||
* - The document has a different scheme (http/https) than its parent document
|
||||
* - The document's domain and subdomain do not match those of its parent
|
||||
* document.
|
||||
*
|
||||
* If there is an error in determining whether the document is Third-Party,
|
||||
* it will be assumed to be Third-Party for security reasons.
|
||||
*/
|
||||
bool Document::IsThirdPartyForFlashClassifier() {
|
||||
if (mIsThirdPartyForFlashClassifier.isSome()) {
|
||||
return mIsThirdPartyForFlashClassifier.value();
|
||||
}
|
||||
|
||||
BrowsingContext* browsingContext = this->GetBrowsingContext();
|
||||
if (!browsingContext) {
|
||||
mIsThirdPartyForFlashClassifier.emplace(true);
|
||||
return mIsThirdPartyForFlashClassifier.value();
|
||||
}
|
||||
|
||||
if (browsingContext->IsTop()) {
|
||||
mIsThirdPartyForFlashClassifier.emplace(false);
|
||||
return mIsThirdPartyForFlashClassifier.value();
|
||||
}
|
||||
|
||||
nsCOMPtr<Document> parentDocument = GetInProcessParentDocument();
|
||||
if (!parentDocument) {
|
||||
// Failure
|
||||
mIsThirdPartyForFlashClassifier.emplace(true);
|
||||
return mIsThirdPartyForFlashClassifier.value();
|
||||
}
|
||||
|
||||
if (parentDocument->IsThirdPartyForFlashClassifier()) {
|
||||
mIsThirdPartyForFlashClassifier.emplace(true);
|
||||
return mIsThirdPartyForFlashClassifier.value();
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIPrincipal> principal = NodePrincipal();
|
||||
nsCOMPtr<nsIPrincipal> parentPrincipal = parentDocument->GetPrincipal();
|
||||
|
||||
bool principalsMatch = false;
|
||||
nsresult rv = principal->Equals(parentPrincipal, &principalsMatch);
|
||||
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
// Failure
|
||||
mIsThirdPartyForFlashClassifier.emplace(true);
|
||||
return mIsThirdPartyForFlashClassifier.value();
|
||||
}
|
||||
|
||||
if (!principalsMatch) {
|
||||
mIsThirdPartyForFlashClassifier.emplace(true);
|
||||
return mIsThirdPartyForFlashClassifier.value();
|
||||
}
|
||||
|
||||
// Fall-through. Document is not a Third-Party Document.
|
||||
mIsThirdPartyForFlashClassifier.emplace(false);
|
||||
return mIsThirdPartyForFlashClassifier.value();
|
||||
}
|
||||
|
||||
FlashClassification Document::DocumentFlashClassificationInternal() {
|
||||
FlashClassification classification = FlashClassification::Unknown;
|
||||
|
||||
nsCOMPtr<nsIHttpChannel> httpChannel = do_QueryInterface(GetChannel());
|
||||
if (httpChannel) {
|
||||
nsIHttpChannel::FlashPluginState state = nsIHttpChannel::FlashPluginUnknown;
|
||||
httpChannel->GetFlashPluginState(&state);
|
||||
|
||||
// Allow unknown children to inherit allowed status from parent, but do not
|
||||
// allow denied children to do so.
|
||||
|
||||
if (state == nsIHttpChannel::FlashPluginDeniedInSubdocuments &&
|
||||
IsThirdPartyForFlashClassifier()) {
|
||||
return FlashClassification::Denied;
|
||||
}
|
||||
|
||||
if (state == nsIHttpChannel::FlashPluginDenied) {
|
||||
return FlashClassification::Denied;
|
||||
}
|
||||
|
||||
if (state == nsIHttpChannel::FlashPluginAllowed) {
|
||||
classification = FlashClassification::Allowed;
|
||||
}
|
||||
}
|
||||
|
||||
if (IsTopLevelContentDocument()) {
|
||||
return classification;
|
||||
}
|
||||
|
||||
Document* parentDocument = GetInProcessParentDocument();
|
||||
if (!parentDocument) {
|
||||
return FlashClassification::Denied;
|
||||
}
|
||||
|
||||
FlashClassification parentClassification =
|
||||
parentDocument->DocumentFlashClassification();
|
||||
|
||||
if (parentClassification == FlashClassification::Denied) {
|
||||
return FlashClassification::Denied;
|
||||
}
|
||||
|
||||
// Allow unknown children to inherit allowed status from parent, but
|
||||
// do not allow denied children to do so.
|
||||
if (classification == FlashClassification::Unknown &&
|
||||
parentClassification == FlashClassification::Allowed) {
|
||||
return FlashClassification::Allowed;
|
||||
}
|
||||
|
||||
return classification;
|
||||
}
|
||||
|
||||
void Document::ClearStaleServoData() {
|
||||
DocumentStyleRootIterator iter(this);
|
||||
while (Element* root = iter.GetNextStyleRoot()) {
|
||||
|
|
|
@ -3757,10 +3757,6 @@ class Document : public nsINode,
|
|||
// determine if it belongs to a tracker.
|
||||
bool IsScriptTracking(JSContext* aCx) const;
|
||||
|
||||
// For more information on Flash classification, see
|
||||
// toolkit/components/url-classifier/flash-block-lists.rst
|
||||
FlashClassification DocumentFlashClassification();
|
||||
|
||||
// ResizeObserver usage.
|
||||
void AddResizeObserver(ResizeObserver&);
|
||||
void RemoveResizeObserver(ResizeObserver&);
|
||||
|
@ -3886,11 +3882,7 @@ class Document : public nsINode,
|
|||
// stored in parent iframe or container's browsingContext (cross process)
|
||||
already_AddRefed<mozilla::dom::FeaturePolicy> GetParentFeaturePolicy();
|
||||
|
||||
FlashClassification DocumentFlashClassificationInternal();
|
||||
|
||||
public:
|
||||
bool IsThirdPartyForFlashClassifier();
|
||||
|
||||
const OriginTrials& Trials() const { return mTrials; }
|
||||
|
||||
private:
|
||||
|
@ -5089,14 +5081,6 @@ class Document : public nsINode,
|
|||
class HeaderData;
|
||||
UniquePtr<HeaderData> mHeaderData;
|
||||
|
||||
// For determining if this is a flash document which should be
|
||||
// blocked based on its principal.
|
||||
FlashClassification mFlashClassification;
|
||||
|
||||
// Do not use this value directly. Call the |IsThirdPartyForFlashClassifier()|
|
||||
// method, which caches its result here.
|
||||
Maybe<bool> mIsThirdPartyForFlashClassifier;
|
||||
|
||||
nsRevocableEventPtr<nsRunnableMethod<Document, void, false>>
|
||||
mPendingTitleChangeEvent;
|
||||
|
||||
|
|
|
@ -606,18 +606,6 @@ partial interface Document {
|
|||
[ChromeOnly] readonly attribute DOMString cspJSON;
|
||||
};
|
||||
|
||||
// For more information on Flash classification, see
|
||||
// toolkit/components/url-classifier/flash-block-lists.rst
|
||||
enum FlashClassification {
|
||||
"unknown", // Site is not on the whitelist or blacklist
|
||||
"allowed", // Site is on the Flash whitelist
|
||||
"denied" // Site is on the Flash blacklist
|
||||
};
|
||||
partial interface Document {
|
||||
[ChromeOnly]
|
||||
readonly attribute FlashClassification documentFlashClassification;
|
||||
};
|
||||
|
||||
partial interface Document {
|
||||
[Func="Document::DocumentSupportsL10n"] readonly attribute DocumentL10n? l10n;
|
||||
};
|
||||
|
|
Загрузка…
Ссылка в новой задаче