ozone: evdev: Sync caps lock LED state to evdev
[chromium-blink-merge.git] / content / public / browser / render_frame_host.h
blobd868430705e66e9724257bdf941424870ae9f7a2
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 "ipc/ipc_listener.h"
13 #include "ipc/ipc_sender.h"
14 #include "third_party/WebKit/public/platform/WebPageVisibilityState.h"
15 #include "ui/gfx/geometry/rect.h"
16 #include "ui/gfx/native_widget_types.h"
17 #include "url/gurl.h"
19 namespace base {
20 class Value;
23 namespace content {
24 class RenderProcessHost;
25 class RenderViewHost;
26 class ServiceRegistry;
27 class SiteInstance;
29 // The interface provides a communication conduit with a frame in the renderer.
30 class CONTENT_EXPORT RenderFrameHost : public IPC::Listener,
31 public IPC::Sender {
32 public:
33 // Returns the RenderFrameHost given its ID and the ID of its render process.
34 // Returns nullptr if the IDs do not correspond to a live RenderFrameHost.
35 static RenderFrameHost* FromID(int render_process_id, int render_frame_id);
37 ~RenderFrameHost() override {}
39 // Returns the route id for this frame.
40 virtual int GetRoutingID() = 0;
42 // Returns the SiteInstance grouping all RenderFrameHosts that have script
43 // access to this RenderFrameHost, and must therefore live in the same
44 // process.
45 virtual SiteInstance* GetSiteInstance() = 0;
47 // Returns the process for this frame.
48 virtual RenderProcessHost* GetProcess() = 0;
50 // Returns the current RenderFrameHost of the parent frame, or nullptr if
51 // there is no parent. The result may be in a different process than the
52 // current RenderFrameHost.
53 virtual RenderFrameHost* GetParent() = 0;
55 // Returns the assigned name of the frame, the name of the iframe tag
56 // declaring it. For example, <iframe name="framename">[...]</iframe>. It is
57 // quite possible for a frame to have no name, in which case GetFrameName will
58 // return an empty string.
59 virtual const std::string& GetFrameName() = 0;
61 // Returns true if the frame is out of process.
62 virtual bool IsCrossProcessSubframe() = 0;
64 // Returns the last committed URL of the frame.
65 virtual GURL GetLastCommittedURL() = 0;
67 // Returns the associated widget's native view.
68 virtual gfx::NativeView GetNativeView() = 0;
70 // Runs some JavaScript in this frame's context. If a callback is provided, it
71 // will be used to return the result, when the result is available.
72 typedef base::Callback<void(const base::Value*)> JavaScriptResultCallback;
73 virtual void ExecuteJavaScript(const base::string16& javascript) = 0;
74 virtual void ExecuteJavaScript(const base::string16& javascript,
75 const JavaScriptResultCallback& callback) = 0;
77 // ONLY FOR TESTS: Same as above but adds a fake UserGestureIndicator around
78 // execution. (crbug.com/408426)
79 virtual void ExecuteJavaScriptForTests(const base::string16& javascript) = 0;
81 // Accessibility actions - these send a message to the RenderFrame
82 // to trigger an action on an accessibility object.
83 virtual void AccessibilitySetFocus(int acc_obj_id) = 0;
84 virtual void AccessibilityDoDefaultAction(int acc_obj_id) = 0;
85 virtual void AccessibilityScrollToMakeVisible(
86 int acc_obj_id, const gfx::Rect& subfocus) = 0;
87 virtual void AccessibilitySetTextSelection(
88 int acc_obj_id, int start_offset, int end_offset) = 0;
90 // This is called when the user has committed to the given find in page
91 // request (e.g. by pressing enter or by clicking on the next / previous
92 // result buttons). It triggers sending a native accessibility event on
93 // the result object on the page, navigating assistive technology to that
94 // result.
95 virtual void ActivateFindInPageResultForAccessibility(int request_id) = 0;
97 // Roundtrips through the renderer and compositor pipeline to ensure that any
98 // changes to the contents resulting from operations executed prior to this
99 // call are visible on screen. The call completes asynchronously by running
100 // the supplied |callback| with a value of true upon successful completion and
101 // false otherwise (when the frame is destroyed, detached, etc..).
102 typedef base::Callback<void(bool)> VisualStateCallback;
103 virtual void InsertVisualStateCallback(
104 const VisualStateCallback& callback) = 0;
106 // Temporary until we get rid of RenderViewHost.
107 virtual RenderViewHost* GetRenderViewHost() = 0;
109 // Returns the ServiceRegistry for this frame.
110 virtual ServiceRegistry* GetServiceRegistry() = 0;
112 // Returns the visibility state of the frame. The different visibility states
113 // of a frame are defined in Blink.
114 virtual blink::WebPageVisibilityState GetVisibilityState() = 0;
116 private:
117 // This interface should only be implemented inside content.
118 friend class RenderFrameHostImpl;
119 RenderFrameHost() {}
122 } // namespace content
124 #endif // CONTENT_PUBLIC_BROWSER_RENDER_FRAME_HOST_H_