зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1268889 - Implement Clear-Site-Data header - part 3 - reload contexts, r=smaug
This commit is contained in:
Родитель
aae23cc727
Коммит
1f52a1bed1
|
@ -941,6 +941,10 @@ nsGlobalWindowInner::nsGlobalWindowInner(nsGlobalWindowOuter *aOuterWindow)
|
|||
false);
|
||||
|
||||
os->AddObserver(mObserver, MEMORY_PRESSURE_OBSERVER_TOPIC, false);
|
||||
|
||||
if (aOuterWindow->IsTopLevelWindow()) {
|
||||
os->AddObserver(mObserver, "clear-site-data-reload-needed", false);
|
||||
}
|
||||
}
|
||||
|
||||
Preferences::AddStrongObserver(mObserver, "intl.accept_languages");
|
||||
|
@ -1268,6 +1272,11 @@ nsGlobalWindowInner::FreeInnerObjects()
|
|||
if (os) {
|
||||
os->RemoveObserver(mObserver, NS_IOSERVICE_OFFLINE_STATUS_TOPIC);
|
||||
os->RemoveObserver(mObserver, MEMORY_PRESSURE_OBSERVER_TOPIC);
|
||||
|
||||
if (GetOuterWindowInternal() &&
|
||||
GetOuterWindowInternal()->IsTopLevelWindow()) {
|
||||
os->RemoveObserver(mObserver, "clear-site-data-reload-needed");
|
||||
}
|
||||
}
|
||||
|
||||
RefPtr<StorageNotifierService> sns = StorageNotifierService::GetOrCreate();
|
||||
|
@ -5818,6 +5827,13 @@ nsGlobalWindowInner::Observe(nsISupports* aSubject, const char* aTopic,
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
if (!nsCRT::strcmp(aTopic, "clear-site-data-reload-needed")) {
|
||||
// The reload is propagated from the top-level window only.
|
||||
NS_ConvertUTF16toUTF8 otherOrigin(aData);
|
||||
PropagateClearSiteDataReload(otherOrigin);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
if (!nsCRT::strcmp(aTopic, OBSERVER_TOPIC_IDLE)) {
|
||||
mCurrentlyIdle = true;
|
||||
if (IsFrozen()) {
|
||||
|
@ -8053,6 +8069,39 @@ nsPIDOMWindowInner::MaybeCreateDoc()
|
|||
}
|
||||
}
|
||||
|
||||
void
|
||||
nsGlobalWindowInner::PropagateClearSiteDataReload(const nsACString& aOrigin)
|
||||
{
|
||||
nsIPrincipal* principal = GetPrincipal();
|
||||
if (!principal) {
|
||||
return;
|
||||
}
|
||||
|
||||
nsAutoCString origin;
|
||||
nsresult rv = principal->GetOrigin(origin);
|
||||
NS_ENSURE_SUCCESS_VOID(rv);
|
||||
|
||||
// If the URL of this window matches, let's refresh this window only.
|
||||
// We don't need to traverse the DOM tree.
|
||||
if (origin.Equals(aOrigin)) {
|
||||
nsCOMPtr<nsIDocShell> docShell = GetDocShell();
|
||||
nsCOMPtr<nsIWebNavigation> webNav(do_QueryInterface(docShell));
|
||||
if (NS_WARN_IF(!webNav)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// We don't need any special reload flags, because this notification is
|
||||
// dispatched by Clear-Site-Data header, which should have already cleaned
|
||||
// up all the needed data.
|
||||
rv = webNav->Reload(nsIWebNavigation::LOAD_FLAGS_NONE);
|
||||
NS_ENSURE_SUCCESS_VOID(rv);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
CallOnChildren(&nsGlobalWindowInner::PropagateClearSiteDataReload, aOrigin);
|
||||
}
|
||||
|
||||
mozilla::dom::DocGroup*
|
||||
nsPIDOMWindowInner::GetDocGroup() const
|
||||
{
|
||||
|
|
|
@ -979,6 +979,8 @@ public:
|
|||
|
||||
bool ShouldReportForServiceWorkerScope(const nsAString& aScope);
|
||||
|
||||
void PropagateClearSiteDataReload(const nsACString& aOrigin);
|
||||
|
||||
already_AddRefed<mozilla::dom::InstallTriggerImpl> GetInstallTrigger();
|
||||
|
||||
void UpdateTopInnerWindow();
|
||||
|
|
|
@ -2589,6 +2589,18 @@ ContentChild::RecvUpdateRequestedLocales(nsTArray<nsCString>&& aRequestedLocales
|
|||
return IPC_OK();
|
||||
}
|
||||
|
||||
mozilla::ipc::IPCResult
|
||||
ContentChild::RecvClearSiteDataReloadNeeded(const nsString& aOrigin)
|
||||
{
|
||||
// Rebroadcast "clear-site-data-reload-needed".
|
||||
nsCOMPtr<nsIObserverService> obs = mozilla::services::GetObserverService();
|
||||
if (obs) {
|
||||
obs->NotifyObservers(nullptr, "clear-site-data-reload-needed",
|
||||
aOrigin.get());
|
||||
}
|
||||
return IPC_OK();
|
||||
}
|
||||
|
||||
mozilla::ipc::IPCResult
|
||||
ContentChild::RecvAddPermission(const IPC::Permission& permission)
|
||||
{
|
||||
|
|
|
@ -405,6 +405,8 @@ public:
|
|||
virtual mozilla::ipc::IPCResult RecvUpdateAppLocales(nsTArray<nsCString>&& aAppLocales) override;
|
||||
virtual mozilla::ipc::IPCResult RecvUpdateRequestedLocales(nsTArray<nsCString>&& aRequestedLocales) override;
|
||||
|
||||
virtual mozilla::ipc::IPCResult RecvClearSiteDataReloadNeeded(const nsString& aOrigin) override;
|
||||
|
||||
virtual mozilla::ipc::IPCResult RecvAddPermission(const IPC::Permission& permission) override;
|
||||
|
||||
virtual mozilla::ipc::IPCResult RecvFlushMemory(const nsString& reason) override;
|
||||
|
|
|
@ -594,6 +594,7 @@ static const char* sObserverTopics[] = {
|
|||
"intl:requested-locales-changed",
|
||||
"cookie-changed",
|
||||
"private-cookie-changed",
|
||||
"clear-site-data-reload-needed",
|
||||
};
|
||||
|
||||
// PreallocateProcess is called by the PreallocatedProcessManager.
|
||||
|
@ -3012,6 +3013,9 @@ ContentParent::Observe(nsISupports* aSubject,
|
|||
(!nsCRT::strcmp(aData, u"changed"))) {
|
||||
cs->AddCookie(xpcCookie);
|
||||
}
|
||||
} else if (!strcmp(aTopic, "clear-site-data-reload-needed")) {
|
||||
// Rebroadcast "clear-site-data-reload-needed".
|
||||
Unused << SendClearSiteDataReloadNeeded(nsString(aData));
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
|
@ -455,6 +455,8 @@ child:
|
|||
async UpdateAppLocales(nsCString[] appLocales);
|
||||
async UpdateRequestedLocales(nsCString[] requestedLocales);
|
||||
|
||||
async ClearSiteDataReloadNeeded(nsString origin);
|
||||
|
||||
// nsIPermissionManager messages
|
||||
async AddPermission(Permission permission);
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче