зеркало из https://github.com/mozilla/gecko-dev.git
Bug 781018 - Collect telemetry information about the number of websites a user visits with Mixed Active/Passive Content. r=smaug
--HG-- extra : rebase_source : d06dd4b07cb68c7dc5b36ab05f6bf8d6bb2a1924
This commit is contained in:
Родитель
06d9864f6d
Коммит
e7e6c19e81
|
@ -22,6 +22,7 @@
|
|||
#include "plstr.h"
|
||||
#include "prprf.h"
|
||||
|
||||
#include "mozilla/Telemetry.h"
|
||||
#include "nsIInterfaceRequestor.h"
|
||||
#include "nsIInterfaceRequestorUtils.h"
|
||||
#include "nsDocument.h"
|
||||
|
@ -1420,6 +1421,46 @@ nsDocument::~nsDocument()
|
|||
|
||||
NS_ASSERTION(!mIsShowing, "Destroying a currently-showing document");
|
||||
|
||||
if (IsTopLevelContentDocument()) {
|
||||
//don't report for about: pages
|
||||
nsCOMPtr<nsIPrincipal> principal = GetPrincipal();
|
||||
nsCOMPtr<nsIURI> uri;
|
||||
principal->GetURI(getter_AddRefs(uri));
|
||||
bool isAboutScheme = true;
|
||||
if (uri) {
|
||||
uri->SchemeIs("about", &isAboutScheme);
|
||||
}
|
||||
|
||||
if (!isAboutScheme) {
|
||||
// Record the mixed content status of the docshell in Telemetry
|
||||
enum {
|
||||
NO_MIXED_CONTENT = 0, // There is no Mixed Content on the page
|
||||
MIXED_DISPLAY_CONTENT = 1, // The page attempted to load Mixed Display Content
|
||||
MIXED_ACTIVE_CONTENT = 2, // The page attempted to load Mixed Active Content
|
||||
MIXED_DISPLAY_AND_ACTIVE_CONTENT = 3 // The page attempted to load Mixed Display & Mixed Active Content
|
||||
};
|
||||
|
||||
bool mixedActiveLoaded = GetHasMixedActiveContentLoaded();
|
||||
bool mixedActiveBlocked = GetHasMixedActiveContentBlocked();
|
||||
|
||||
bool mixedDisplayLoaded = GetHasMixedDisplayContentLoaded();
|
||||
bool mixedDisplayBlocked = GetHasMixedDisplayContentBlocked();
|
||||
|
||||
bool hasMixedDisplay = (mixedDisplayBlocked || mixedDisplayLoaded);
|
||||
bool hasMixedActive = (mixedActiveBlocked || mixedActiveLoaded);
|
||||
|
||||
uint32_t mixedContentLevel = NO_MIXED_CONTENT;
|
||||
if (hasMixedDisplay && hasMixedActive) {
|
||||
mixedContentLevel = MIXED_DISPLAY_AND_ACTIVE_CONTENT;
|
||||
} else if (hasMixedActive){
|
||||
mixedContentLevel = MIXED_ACTIVE_CONTENT;
|
||||
} else if (hasMixedDisplay) {
|
||||
mixedContentLevel = MIXED_DISPLAY_CONTENT;
|
||||
}
|
||||
Accumulate(Telemetry::MIXED_CONTENT_PAGE_LOAD, mixedContentLevel);
|
||||
}
|
||||
}
|
||||
|
||||
mInDestructor = true;
|
||||
mInUnlinkOrDeletion = true;
|
||||
|
||||
|
@ -4113,6 +4154,23 @@ nsIDocument::SetContainer(nsISupports* aContainer)
|
|||
{
|
||||
mDocumentContainer = do_GetWeakReference(aContainer);
|
||||
EnumerateFreezableElements(NotifyActivityChanged, nullptr);
|
||||
// Get the Docshell
|
||||
nsCOMPtr<nsIDocShell> docShell = do_QueryInterface(aContainer);
|
||||
if (docShell) {
|
||||
int32_t itemType;
|
||||
docShell->GetItemType(&itemType);
|
||||
// check itemtype
|
||||
if (itemType == nsIDocShellTreeItem::typeContent) {
|
||||
// check if same type root
|
||||
nsCOMPtr<nsIDocShellTreeItem> sameTypeRoot;
|
||||
docShell->GetSameTypeRootTreeItem(getter_AddRefs(sameTypeRoot));
|
||||
NS_ASSERTION(sameTypeRoot, "No document shell root tree item from document shell tree item!");
|
||||
|
||||
if (sameTypeRoot == docShell) {
|
||||
static_cast<nsDocument*>(this)->SetIsTopLevelContentDocument(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -4243,6 +4301,18 @@ nsDocument::SetScriptHandlingObject(nsIScriptGlobalObject* aScriptObject)
|
|||
}
|
||||
}
|
||||
|
||||
bool
|
||||
nsDocument::IsTopLevelContentDocument()
|
||||
{
|
||||
return mIsTopLevelContentDocument;
|
||||
}
|
||||
|
||||
void
|
||||
nsDocument::SetIsTopLevelContentDocument(bool aIsTopLevelContentDocument)
|
||||
{
|
||||
mIsTopLevelContentDocument = aIsTopLevelContentDocument;
|
||||
}
|
||||
|
||||
nsPIDOMWindow *
|
||||
nsDocument::GetWindowInternal() const
|
||||
{
|
||||
|
|
|
@ -1121,6 +1121,12 @@ public:
|
|||
|
||||
static void XPCOMShutdown();
|
||||
|
||||
bool mIsTopLevelContentDocument:1;
|
||||
|
||||
bool IsTopLevelContentDocument();
|
||||
|
||||
void SetIsTopLevelContentDocument(bool aIsTopLevelContentDocument);
|
||||
|
||||
js::ExpandoAndGeneration mExpandoAndGeneration;
|
||||
|
||||
protected:
|
||||
|
|
|
@ -18,7 +18,6 @@
|
|||
#include "mozilla/Services.h"
|
||||
#include "mozilla/StartupTimeline.h"
|
||||
#include "mozilla/Telemetry.h"
|
||||
#include "mozilla/Telemetry.h"
|
||||
#include "mozilla/unused.h"
|
||||
#include "mozilla/Util.h"
|
||||
#include "mozilla/VisualEventTracer.h"
|
||||
|
|
|
@ -3633,5 +3633,10 @@
|
|||
"BROWSER_IS_USER_DEFAULT": {
|
||||
"kind": "boolean",
|
||||
"description": "The result of the startup default desktop browser check."
|
||||
},
|
||||
"MIXED_CONTENT_PAGE_LOAD": {
|
||||
"kind": "enumerated",
|
||||
"n_values": 4,
|
||||
"description": "Accumulates type of content (mixed, mixed passive, unmixed) per page load"
|
||||
}
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче