Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-60668

Ability to get originating view from QWebEngineUrlRequestInfo

    XMLWordPrintable

Details

    • Suggestion
    • Resolution: Fixed
    • P3: Somewhat important
    • None
    • None
    • WebEngine
    • None

    Description

      It'd be nice if there was a way to find out from which QWebEngineView a intercepted request came from.

      Looking at Chromium's sources, there are various getters which sound promising - though I'm not sure which one allows Qt to get the corresponding view:

        // Returns the associated RenderFrame for a given process. Returns false, if
        // there is no associated RenderFrame. This method does not rely on the
        // request being allocated by the ResourceDispatcherHost, but works for all
        // URLRequests that are associated with a RenderFrame.
        CONTENT_EXPORT static bool GetRenderFrameForRequest(
            const net::URLRequest* request,
            int* render_process_id,
            int* render_frame_id);
      
        // Returns the associated RenderFrame for a given process. Returns false, if
        // there is no associated RenderFrame. This method does not rely on the
        // request being allocated by the ResourceDispatcherHost, but works for all
        // URLRequests that are associated with a RenderFrame.
        CONTENT_EXPORT static bool GetRenderFrameForRequest(
            const net::URLRequest* request,
            int* render_process_id,
            int* render_frame_id);
      
        // Returns true if the request originated from a Service Worker.
        CONTENT_EXPORT static bool OriginatedFromServiceWorker(
            const net::URLRequest* request);
      
        // A callback that returns a pointer to a WebContents. The callback can
        // always be used, but it may return nullptr: if the info used to
        // instantiate the callback can no longer be used to return a WebContents,
        // nullptr will be returned instead.
        // The callback should only run on the UI thread and it should always be
        // non-null.
        using WebContentsGetter = base::Callback<WebContents*(void)>;
      
        // A callback that returns a frame tree node id . The callback can always
        // be used, but it may return -1 if no id is found. The callback should only
        // run on the UI thread.
        using FrameTreeNodeIdGetter = base::Callback<int(void)>;
      
        // Returns a callback that returns a pointer to the WebContents this request
        // is associated with, or nullptr if it no longer exists or the request is
        // not associated with a WebContents. The callback should only run on the UI
        // thread.
        // Note: Not all resource requests will be owned by a WebContents. For
        // example, requests made by a ServiceWorker.
        virtual WebContentsGetter GetWebContentsGetterForRequest() const = 0;
      
        // Returns a callback that returns an int with the frame tree node id
        //   associated with this request, or -1 if it no longer exists. This
        //   callback should only be run on the UI thread.
        // Note: Not all resource requests will be associated with a frame. For
        // example, requests made by a ServiceWorker.
        virtual FrameTreeNodeIdGetter GetFrameTreeNodeIdGetterForRequest() const = 0;
      
        // Returns the FrameTreeNode ID for this frame. This ID is browser-global and
        // uniquely identifies a frame that hosts content.
        // Note: Returns -1 for all requests except PlzNavigate requests.
        virtual int GetFrameTreeNodeId() const = 0;
      
        // The IPC route identifier of the RenderFrame.
        // To get a WebContents, use GetWebContentsGetterForRequest instead.
        // TODO(jam): once all navigation and resource requests are sent between
        // frames and RenderView/RenderViewHost aren't involved we can remove this and
        // just use GetRouteID above.
        virtual int GetRenderFrameID() const = 0;
      
        // Returns false if there is NOT an associated render frame.
        virtual bool GetAssociatedRenderFrame(int* render_process_id,
                                              int* render_frame_id) const = 0;
      

      Attachments

        Issue Links

          No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

              qt_webengine_team Qt WebEngine Team
              the compiler Florian Bruhin
              Votes:
              1 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes