Pin Chrome's shortcut to the Win10 Start menu on install and OS upgrade.
[chromium-blink-merge.git] / content / public / browser / render_frame_host.h
blobe47441df9aebe577a4ae10dbc6e3e0dbf606797c
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 // Globally allows for injecting JavaScript into the main world. This feature
39 // is present only to support Android WebView and must not be used in other
40 // configurations.
41 static void AllowInjectingJavaScriptForAndroidWebView();
43 ~RenderFrameHost() override {}
45 // Returns the route id for this frame.
46 virtual int GetRoutingID() = 0;
48 // Returns the SiteInstance grouping all RenderFrameHosts that have script
49 // access to this RenderFrameHost, and must therefore live in the same
50 // process.
51 virtual SiteInstance* GetSiteInstance() = 0;
53 // Returns the process for this frame.
54 virtual RenderProcessHost* GetProcess() = 0;
56 // Returns the current RenderFrameHost of the parent frame, or nullptr if
57 // there is no parent. The result may be in a different process than the
58 // current RenderFrameHost.
59 virtual RenderFrameHost* GetParent() = 0;
61 // Returns the assigned name of the frame, the name of the iframe tag
62 // declaring it. For example, <iframe name="framename">[...]</iframe>. It is
63 // quite possible for a frame to have no name, in which case GetFrameName will
64 // return an empty string.
65 virtual const std::string& GetFrameName() = 0;
67 // Returns true if the frame is out of process.
68 virtual bool IsCrossProcessSubframe() = 0;
70 // Returns the last committed URL of the frame.
71 virtual GURL GetLastCommittedURL() = 0;
73 // Returns the associated widget's native view.
74 virtual gfx::NativeView GetNativeView() = 0;
76 // Adds |message| to the DevTools console.
77 virtual void AddMessageToConsole(ConsoleMessageLevel level,
78 const std::string& message) = 0;
80 // Runs some JavaScript in this frame's context. If a callback is provided, it
81 // will be used to return the result, when the result is available.
82 // This API can only be called on chrome:// or chrome-devtools:// URLs.
83 typedef base::Callback<void(const base::Value*)> JavaScriptResultCallback;
84 virtual void ExecuteJavaScript(const base::string16& javascript) = 0;
85 virtual void ExecuteJavaScript(const base::string16& javascript,
86 const JavaScriptResultCallback& callback) = 0;
88 // Runs some JavaScript in an isolated world of top of this frame's context.
89 virtual void ExecuteJavaScriptInIsolatedWorld(
90 const base::string16& javascript,
91 const JavaScriptResultCallback& callback,
92 int world_id) = 0;
94 // ONLY FOR TESTS: Same as above but without restrictions. Optionally, adds a
95 // fake UserGestureIndicator around execution. (crbug.com/408426)
96 virtual void ExecuteJavaScriptForTests(const base::string16& javascript) = 0;
97 virtual void ExecuteJavaScriptForTests(
98 const base::string16& javascript,
99 const JavaScriptResultCallback& callback) = 0;
100 virtual void ExecuteJavaScriptWithUserGestureForTests(
101 const base::string16& javascript) = 0;
103 // Accessibility actions - these send a message to the RenderFrame
104 // to trigger an action on an accessibility object.
105 virtual void AccessibilitySetFocus(int acc_obj_id) = 0;
106 virtual void AccessibilityDoDefaultAction(int acc_obj_id) = 0;
107 virtual void AccessibilityScrollToMakeVisible(
108 int acc_obj_id, const gfx::Rect& subfocus) = 0;
109 virtual void AccessibilityShowContextMenu(int acc_obj_id) = 0;
110 virtual void AccessibilitySetTextSelection(
111 int acc_obj_id, int start_offset, int end_offset) = 0;
113 // This is called when the user has committed to the given find in page
114 // request (e.g. by pressing enter or by clicking on the next / previous
115 // result buttons). It triggers sending a native accessibility event on
116 // the result object on the page, navigating assistive technology to that
117 // result.
118 virtual void ActivateFindInPageResultForAccessibility(int request_id) = 0;
120 // Roundtrips through the renderer and compositor pipeline to ensure that any
121 // changes to the contents resulting from operations executed prior to this
122 // call are visible on screen. The call completes asynchronously by running
123 // the supplied |callback| with a value of true upon successful completion and
124 // false otherwise (when the frame is destroyed, detached, etc..).
125 typedef base::Callback<void(bool)> VisualStateCallback;
126 virtual void InsertVisualStateCallback(
127 const VisualStateCallback& callback) = 0;
129 // Temporary until we get rid of RenderViewHost.
130 virtual RenderViewHost* GetRenderViewHost() = 0;
132 // Returns the ServiceRegistry for this frame.
133 virtual ServiceRegistry* GetServiceRegistry() = 0;
135 // Returns the visibility state of the frame. The different visibility states
136 // of a frame are defined in Blink.
137 virtual blink::WebPageVisibilityState GetVisibilityState() = 0;
139 // Returns whether the RenderFrame in the renderer process has been created
140 // and still has a connection. This is valid for all frames.
141 virtual bool IsRenderFrameLive() = 0;
143 private:
144 // This interface should only be implemented inside content.
145 friend class RenderFrameHostImpl;
146 RenderFrameHost() {}
149 } // namespace content
151 #endif // CONTENT_PUBLIC_BROWSER_RENDER_FRAME_HOST_H_