[Android WebView] Fix webview perf bot switchover to use org.chromium.webview_shell...
[chromium-blink-merge.git] / content / public / browser / render_frame_host.h
blob46f43913de34ba05e767a62669dd7dd09343492a
1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef CONTENT_PUBLIC_BROWSER_RENDER_FRAME_HOST_H_
6 #define CONTENT_PUBLIC_BROWSER_RENDER_FRAME_HOST_H_
8 #include <string>
10 #include "base/callback_forward.h"
11 #include "content/common/content_export.h"
12 #include "content/public/common/console_message_level.h"
13 #include "ipc/ipc_listener.h"
14 #include "ipc/ipc_sender.h"
15 #include "third_party/WebKit/public/platform/WebPageVisibilityState.h"
16 #include "ui/gfx/geometry/rect.h"
17 #include "ui/gfx/native_widget_types.h"
18 #include "url/gurl.h"
20 namespace base {
21 class Value;
24 namespace content {
25 class RenderProcessHost;
26 class RenderViewHost;
27 class ServiceRegistry;
28 class SiteInstance;
30 // The interface provides a communication conduit with a frame in the renderer.
31 class CONTENT_EXPORT RenderFrameHost : public IPC::Listener,
32 public IPC::Sender {
33 public:
34 // Returns the RenderFrameHost given its ID and the ID of its render process.
35 // Returns nullptr if the IDs do not correspond to a live RenderFrameHost.
36 static RenderFrameHost* FromID(int render_process_id, int render_frame_id);
38 ~RenderFrameHost() override {}
40 // Returns the route id for this frame.
41 virtual int GetRoutingID() = 0;
43 // Returns the SiteInstance grouping all RenderFrameHosts that have script
44 // access to this RenderFrameHost, and must therefore live in the same
45 // process.
46 virtual SiteInstance* GetSiteInstance() = 0;
48 // Returns the process for this frame.
49 virtual RenderProcessHost* GetProcess() = 0;
51 // Returns the current RenderFrameHost of the parent frame, or nullptr if
52 // there is no parent. The result may be in a different process than the
53 // current RenderFrameHost.
54 virtual RenderFrameHost* GetParent() = 0;
56 // Returns the assigned name of the frame, the name of the iframe tag
57 // declaring it. For example, <iframe name="framename">[...]</iframe>. It is
58 // quite possible for a frame to have no name, in which case GetFrameName will
59 // return an empty string.
60 virtual const std::string& GetFrameName() = 0;
62 // Returns true if the frame is out of process.
63 virtual bool IsCrossProcessSubframe() = 0;
65 // Returns the last committed URL of the frame.
66 virtual GURL GetLastCommittedURL() = 0;
68 // Returns the associated widget's native view.
69 virtual gfx::NativeView GetNativeView() = 0;
71 // Adds |message| to the DevTools console.
72 virtual void AddMessageToConsole(ConsoleMessageLevel level,
73 const std::string& message) = 0;
75 // Runs some JavaScript in this frame's context. If a callback is provided, it
76 // will be used to return the result, when the result is available.
77 typedef base::Callback<void(const base::Value*)> JavaScriptResultCallback;
78 virtual void ExecuteJavaScript(const base::string16& javascript) = 0;
79 virtual void ExecuteJavaScript(const base::string16& javascript,
80 const JavaScriptResultCallback& callback) = 0;
81 virtual void ExecuteJavaScriptInIsolatedWorld(
82 const base::string16& javascript,
83 const JavaScriptResultCallback& callback,
84 int world_id) = 0;
86 // ONLY FOR TESTS: Same as above but adds a fake UserGestureIndicator around
87 // execution. (crbug.com/408426)
88 virtual void ExecuteJavaScriptWithUserGestureForTests(
89 const base::string16& javascript) = 0;
91 // Accessibility actions - these send a message to the RenderFrame
92 // to trigger an action on an accessibility object.
93 virtual void AccessibilitySetFocus(int acc_obj_id) = 0;
94 virtual void AccessibilityDoDefaultAction(int acc_obj_id) = 0;
95 virtual void AccessibilityScrollToMakeVisible(
96 int acc_obj_id, const gfx::Rect& subfocus) = 0;
97 virtual void AccessibilityShowContextMenu(int acc_obj_id) = 0;
98 virtual void AccessibilitySetTextSelection(
99 int acc_obj_id, int start_offset, int end_offset) = 0;
101 // This is called when the user has committed to the given find in page
102 // request (e.g. by pressing enter or by clicking on the next / previous
103 // result buttons). It triggers sending a native accessibility event on
104 // the result object on the page, navigating assistive technology to that
105 // result.
106 virtual void ActivateFindInPageResultForAccessibility(int request_id) = 0;
108 // Roundtrips through the renderer and compositor pipeline to ensure that any
109 // changes to the contents resulting from operations executed prior to this
110 // call are visible on screen. The call completes asynchronously by running
111 // the supplied |callback| with a value of true upon successful completion and
112 // false otherwise (when the frame is destroyed, detached, etc..).
113 typedef base::Callback<void(bool)> VisualStateCallback;
114 virtual void InsertVisualStateCallback(
115 const VisualStateCallback& callback) = 0;
117 // Temporary until we get rid of RenderViewHost.
118 virtual RenderViewHost* GetRenderViewHost() = 0;
120 // Returns the ServiceRegistry for this frame.
121 virtual ServiceRegistry* GetServiceRegistry() = 0;
123 // Returns the visibility state of the frame. The different visibility states
124 // of a frame are defined in Blink.
125 virtual blink::WebPageVisibilityState GetVisibilityState() = 0;
127 private:
128 // This interface should only be implemented inside content.
129 friend class RenderFrameHostImpl;
130 RenderFrameHost() {}
133 } // namespace content
135 #endif // CONTENT_PUBLIC_BROWSER_RENDER_FRAME_HOST_H_