1
    2
    3
    4
    5
    6
    7
    8
    9
   10
   11
   12
   13
   14
   15
   16
   17
   18
   19
   20
   21
   22
   23
   24
   25
   26
   27
   28
   29
   30
   31
   32
   33
   34
   35
   36
   37
   38
   39
   40
   41
   42
   43
   44
   45
   46
   47
   48
   49
   50
   51
   52
   53
   54
   55
   56
   57
   58
   59
   60
   61
   62
   63
   64
   65
   66
   67
   68
   69
   70
   71
   72
   73
   74
   75
   76
   77
   78
   79
   80
   81
   82
   83
   84
   85
   86
   87
   88
   89
   90
   91
   92
   93
   94
   95
   96
   97
   98
   99
  100
  101
  102
  103
  104
  105
  106
  107
  108
  109
  110
  111
  112
  113
  114
  115
  116
  117
  118
  119
  120
  121
  122
  123
  124
  125
  126
  127
  128
  129
  130
  131
  132
  133
  134
  135

content / browser / renderer_host / render_frame_host_owner.h [blame]

// Copyright 2022 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef CONTENT_BROWSER_RENDERER_HOST_RENDER_FRAME_HOST_OWNER_H_
#define CONTENT_BROWSER_RENDERER_HOST_RENDER_FRAME_HOST_OWNER_H_

#include <memory>
#include <vector>

#include "build/build_config.h"
#include "content/public/browser/frame_type.h"
#include "services/network/public/mojom/referrer_policy.mojom-forward.h"
#include "third_party/blink/public/mojom/frame/user_activation_update_types.mojom-forward.h"
#include "third_party/blink/public/mojom/loader/referrer.mojom-forward.h"
#include "ui/base/page_transition_types.h"

class GURL;

namespace net {
class IsolationInfo;
}  // namespace net

namespace url {
class Origin;
}  // namespace url

namespace content {

class CrossOriginEmbedderPolicyReporter;
class NavigationRequest;
class Navigator;
class RenderFrameHostManager;
class RenderFrameHostImpl;

// An interface for RenderFrameHostImpl to communicate with FrameTreeNode owning
// it (e.g. to initiate or cancel a navigation in the frame).
//
// As main RenderFrameHostImpl can be moved between different FrameTreeNodes
// (i.e.during prerender activations), RenderFrameHostImpl should not reference
// FrameTreeNode directly to prevent accident violation of implicit "associated
// FTN stays the same" assumptions. Instead, a targeted interface is exposed
// instead.
//
// If you need to store information which should persist during prerender
// activations and same-BrowsingContext navigations, consider using
// BrowsingContextState instead.
class RenderFrameHostOwner {
 public:
  RenderFrameHostOwner() = default;
  virtual ~RenderFrameHostOwner() = default;

  // A RenderFrameHost started loading.
  virtual void DidStartLoading(
      LoadingState previous_frame_tree_loading_state) = 0;

  // A RenderFrameHost in this owner stopped loading.
  virtual void DidStopLoading() = 0;

  virtual void RestartNavigationAsCrossDocument(
      std::unique_ptr<NavigationRequest> navigation_request) = 0;

  // Reload the current document in this frame again. Return whether an actual
  // navigation request was created or not.
  virtual bool Reload() = 0;

  virtual Navigator& GetCurrentNavigator() = 0;

  virtual RenderFrameHostManager& GetRenderFrameHostManager() = 0;

  virtual FrameTreeNode* GetOpener() const = 0;

  virtual void SetFocusedFrame(SiteInstanceGroup* source) = 0;

  // Called when the referrer policy changes.
  virtual void DidChangeReferrerPolicy(
      network::mojom::ReferrerPolicy referrer_policy) = 0;

  virtual bool UpdateUserActivationState(
      blink::mojom::UserActivationUpdateType update_type,
      blink::mojom::UserActivationNotificationType notification_type) = 0;

  // Called to notify all frames of a page that the history user activation
  // has been consumed, in response to an event in the renderer process.
  virtual void DidConsumeHistoryUserActivation() = 0;

  // Called when document.open occurs, which causes the frame to no longer be in
  // an initial empty document state.
  virtual void DidOpenDocumentInputStream() = 0;

  // Creates a NavigationRequest  for a synchronous navigation that has
  // committed in the renderer process. Those are:
  // - same-document renderer-initiated navigations.
  // - synchronous about:blank navigations.
  virtual std::unique_ptr<NavigationRequest>
  CreateNavigationRequestForSynchronousRendererCommit(
      RenderFrameHostImpl* render_frame_host,
      bool is_same_document,
      const GURL& url,
      const url::Origin& origin,
      const std::optional<GURL>& initiator_base_url,
      const net::IsolationInfo& isolation_info_for_subresources,
      blink::mojom::ReferrerPtr referrer,
      const ui::PageTransition& transition,
      bool should_replace_current_entry,
      const std::string& method,
      bool has_transient_activation,
      bool is_overriding_user_agent,
      const std::vector<GURL>& redirects,
      const GURL& original_url,
      std::unique_ptr<CrossOriginEmbedderPolicyReporter> coep_reporter,
      int http_response_code) = 0;

  // Cancels the navigation owned by the FrameTreeNode.
  // Note: this does not cancel navigations that are owned by the current or
  // speculative RenderFrameHosts.
  virtual void CancelNavigation(NavigationDiscardReason reason) = 0;

  // Reset every non-speculative navigation in this frame, and its descendants.
  // This is called after outermost main frame has been discarded.
  //
  // This takes into account:
  // - Non-pending commit NavigationRequest owned by the FrameTreeNode
  // - Pending commit NavigationRequest owned by the current RenderFrameHost
  virtual void ResetNavigationsForDiscard() = 0;

  // Return the iframe.credentialless attribute value.
  virtual bool Credentialless() const = 0;

  virtual FrameType GetCurrentFrameType() const = 0;
};

}  // namespace content

#endif  // CONTENT_BROWSER_RENDERER_HOST_RENDER_FRAME_HOST_OWNER_H_