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_
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 "ui/gfx/native_widget_types.h"
15 #include "ui/gfx/rect.h"
23 class RenderProcessHost;
25 class ServiceRegistry;
28 // The interface provides a communication conduit with a frame in the renderer.
29 class CONTENT_EXPORT RenderFrameHost : public IPC::Listener,
32 // Returns the RenderFrameHost given its ID and the ID of its render process.
33 // Returns NULL if the IDs do not correspond to a live RenderFrameHost.
34 static RenderFrameHost* FromID(int render_process_id, int render_frame_id);
36 virtual ~RenderFrameHost() {}
38 // Returns the route id for this frame.
39 virtual int GetRoutingID() = 0;
41 // Returns the SiteInstance grouping all RenderFrameHosts that have script
42 // access to this RenderFrameHost, and must therefore live in the same
44 virtual SiteInstance* GetSiteInstance() = 0;
46 // Returns the process for this frame.
47 virtual RenderProcessHost* GetProcess() = 0;
49 // Returns the current RenderFrameHost of the parent frame, or NULL if there
50 // is no parent. The result may be in a different process than the current
52 virtual RenderFrameHost* GetParent() = 0;
54 // Returns the assigned name of the frame, the name of the iframe tag
55 // declaring it. For example, <iframe name="framename">[...]</iframe>. It is
56 // quite possible for a frame to have no name, in which case GetFrameName will
57 // return an empty string.
58 virtual const std::string& GetFrameName() = 0;
60 // Returns true if the frame is out of process.
61 virtual bool IsCrossProcessSubframe() = 0;
63 // Returns the last committed URL of the frame.
64 virtual GURL GetLastCommittedURL() = 0;
66 // Returns the associated widget's native view.
67 virtual gfx::NativeView GetNativeView() = 0;
69 // Runs some JavaScript in this frame's context. If a callback is provided, it
70 // will be used to return the result, when the result is available.
71 typedef base::Callback<void(const base::Value*)> JavaScriptResultCallback;
72 virtual void ExecuteJavaScript(const base::string16& javascript) = 0;
73 virtual void ExecuteJavaScript(const base::string16& javascript,
74 const JavaScriptResultCallback& callback) = 0;
76 // Accessibility actions.
77 virtual void AccessibilitySetFocus(int acc_obj_id) = 0;
78 virtual void AccessibilityDoDefaultAction(int acc_obj_id) = 0;
79 virtual void AccessibilityScrollToMakeVisible(
80 int acc_obj_id, const gfx::Rect& subfocus) = 0;
81 virtual void AccessibilitySetTextSelection(
82 int acc_obj_id, int start_offset, int end_offset) = 0;
84 // Temporary until we get rid of RenderViewHost.
85 virtual RenderViewHost* GetRenderViewHost() = 0;
87 // Returns the ServiceRegistry for this frame.
88 virtual ServiceRegistry* GetServiceRegistry() = 0;
91 // This interface should only be implemented inside content.
92 friend class RenderFrameHostImpl;
96 } // namespace content
98 #endif // CONTENT_PUBLIC_BROWSER_RENDER_FRAME_HOST_H_