2019-02-16 01:20:51 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
|
|
|
/* 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 nsFrameLoaderOwner_h_
|
|
|
|
#define nsFrameLoaderOwner_h_
|
|
|
|
|
2020-10-19 15:18:01 +03:00
|
|
|
#include <functional>
|
2020-11-23 19:07:21 +03:00
|
|
|
#include "nsFrameLoader.h"
|
2019-04-29 23:06:22 +03:00
|
|
|
#include "nsISupports.h"
|
|
|
|
|
2019-03-14 04:25:07 +03:00
|
|
|
namespace mozilla {
|
|
|
|
class ErrorResult;
|
|
|
|
namespace dom {
|
2019-04-08 19:27:28 +03:00
|
|
|
class BrowsingContext;
|
2020-10-19 15:18:01 +03:00
|
|
|
class BrowsingContextGroup;
|
2019-10-22 16:57:00 +03:00
|
|
|
class BrowserBridgeChild;
|
2020-10-19 15:18:01 +03:00
|
|
|
class ContentParent;
|
2019-03-14 04:25:07 +03:00
|
|
|
struct RemotenessOptions;
|
2021-03-02 12:44:09 +03:00
|
|
|
struct RemotenessChangeState;
|
2019-04-08 19:27:28 +03:00
|
|
|
} // namespace dom
|
2019-03-14 04:25:07 +03:00
|
|
|
} // namespace mozilla
|
2019-02-16 01:20:51 +03:00
|
|
|
|
|
|
|
// IID for the FrameLoaderOwner interface
|
|
|
|
#define NS_FRAMELOADEROWNER_IID \
|
|
|
|
{ \
|
|
|
|
0x1b4fd25c, 0x2e57, 0x11e9, { \
|
|
|
|
0x9e, 0x5a, 0x5b, 0x86, 0xe9, 0x89, 0xa5, 0xc0 \
|
|
|
|
} \
|
|
|
|
}
|
|
|
|
|
|
|
|
// Mixin that handles ownership of nsFrameLoader for Frame elements
|
|
|
|
// (XULFrameElement, HTMLI/FrameElement, etc...). Manages information when doing
|
|
|
|
// FrameLoader swaps.
|
|
|
|
//
|
|
|
|
// This class is considered an XPCOM mixin. This means that while we inherit
|
|
|
|
// from ISupports in order to be QI'able, we expect the classes that inherit
|
|
|
|
// nsFrameLoaderOwner to actually implement ISupports for us.
|
|
|
|
class nsFrameLoaderOwner : public nsISupports {
|
|
|
|
public:
|
|
|
|
NS_DECLARE_STATIC_IID_ACCESSOR(NS_FRAMELOADEROWNER_IID)
|
|
|
|
|
|
|
|
nsFrameLoaderOwner() = default;
|
|
|
|
already_AddRefed<nsFrameLoader> GetFrameLoader();
|
|
|
|
void SetFrameLoader(nsFrameLoader* aNewFrameLoader);
|
2019-02-16 22:20:37 +03:00
|
|
|
|
2020-02-22 00:03:54 +03:00
|
|
|
mozilla::dom::BrowsingContext* GetBrowsingContext();
|
2020-06-12 13:22:56 +03:00
|
|
|
mozilla::dom::BrowsingContext* GetExtantBrowsingContext();
|
2019-04-08 19:27:28 +03:00
|
|
|
|
2019-03-14 04:25:07 +03:00
|
|
|
// Destroy (if it exists) and recreate our frameloader, based on new
|
2020-06-16 02:23:43 +03:00
|
|
|
// remoteness requirements.
|
|
|
|
//
|
|
|
|
// This method is called by frontend code when it wants to perform a
|
|
|
|
// remoteness update, and allows for behaviour such as preserving
|
|
|
|
// BrowsingContexts across process switches during navigation.
|
|
|
|
//
|
|
|
|
// See the WebIDL definition for more details.
|
2019-03-14 04:25:07 +03:00
|
|
|
void ChangeRemoteness(const mozilla::dom::RemotenessOptions& aOptions,
|
|
|
|
mozilla::ErrorResult& rv);
|
|
|
|
|
2020-06-16 02:23:43 +03:00
|
|
|
// Like `ChangeRemoteness` but switches to an already-created
|
|
|
|
// `BrowserBridgeChild`. This method is used when performing remote subframe
|
|
|
|
// process switches.
|
2019-10-22 16:57:00 +03:00
|
|
|
void ChangeRemotenessWithBridge(mozilla::dom::BrowserBridgeChild* aBridge,
|
|
|
|
mozilla::ErrorResult& rv);
|
2019-10-15 19:19:16 +03:00
|
|
|
|
2020-06-16 02:23:43 +03:00
|
|
|
// Like `ChangeRemoteness`, but switches into an already-created
|
|
|
|
// `ContentParent`. This method is used when performing toplevel process
|
|
|
|
// switches. If `aContentParent` is nullptr, switches into the parent process.
|
|
|
|
//
|
|
|
|
// If `aReplaceBrowsingContext` is set, BrowsingContext preservation will be
|
|
|
|
// disabled for this process switch.
|
2021-03-02 12:44:09 +03:00
|
|
|
void ChangeRemotenessToProcess(
|
|
|
|
mozilla::dom::ContentParent* aContentParent,
|
|
|
|
const mozilla::dom::RemotenessChangeState& aState,
|
|
|
|
mozilla::dom::BrowsingContextGroup* aGroup, mozilla::ErrorResult& rv);
|
2020-06-16 02:23:43 +03:00
|
|
|
|
2020-04-29 12:58:50 +03:00
|
|
|
void SubframeCrashed();
|
|
|
|
|
2019-06-10 16:06:46 +03:00
|
|
|
private:
|
|
|
|
bool UseRemoteSubframes();
|
2020-04-17 14:29:13 +03:00
|
|
|
|
|
|
|
// The enum class for determine how to handle previous BrowsingContext during
|
|
|
|
// the change remoteness. It could be followings
|
|
|
|
// 1. DONT_PRESERVE
|
|
|
|
// Create a whole new BrowsingContext.
|
2020-06-17 05:59:29 +03:00
|
|
|
// 2. PRESERVE
|
2020-04-17 14:29:13 +03:00
|
|
|
// Preserve the previous BrowsingContext.
|
|
|
|
enum class ChangeRemotenessContextType {
|
|
|
|
DONT_PRESERVE = 0,
|
2020-06-17 05:59:29 +03:00
|
|
|
PRESERVE = 1,
|
2020-04-17 14:29:13 +03:00
|
|
|
};
|
2020-06-16 02:23:43 +03:00
|
|
|
ChangeRemotenessContextType ShouldPreserveBrowsingContext(
|
|
|
|
bool aIsRemote, bool aReplaceBrowsingContext);
|
|
|
|
|
2020-04-17 14:29:13 +03:00
|
|
|
void ChangeRemotenessCommon(const ChangeRemotenessContextType& aContextType,
|
2021-03-02 12:44:09 +03:00
|
|
|
const mozilla::dom::RemotenessChangeState& aState,
|
2020-06-16 02:23:43 +03:00
|
|
|
bool aSwitchingInProgressLoad, bool aIsRemote,
|
2020-07-06 23:10:43 +03:00
|
|
|
mozilla::dom::BrowsingContextGroup* aGroup,
|
2019-10-15 19:19:16 +03:00
|
|
|
std::function<void()>& aFrameLoaderInit,
|
|
|
|
mozilla::ErrorResult& aRv);
|
2019-06-10 16:06:46 +03:00
|
|
|
|
2019-02-16 01:20:51 +03:00
|
|
|
protected:
|
|
|
|
virtual ~nsFrameLoaderOwner() = default;
|
|
|
|
RefPtr<nsFrameLoader> mFrameLoader;
|
|
|
|
};
|
|
|
|
|
|
|
|
NS_DEFINE_STATIC_IID_ACCESSOR(nsFrameLoaderOwner, NS_FRAMELOADEROWNER_IID)
|
|
|
|
|
|
|
|
#endif // nsFrameLoaderOwner_h_
|