render_frame_host.h revision 116680a4aac90f2aa7413d9095a592090648e557
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.
4
5#ifndef CONTENT_PUBLIC_BROWSER_RENDER_FRAME_HOST_H_
6#define CONTENT_PUBLIC_BROWSER_RENDER_FRAME_HOST_H_
7
8#include <string>
9
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"
16#include "url/gurl.h"
17
18namespace base {
19class Value;
20}
21
22namespace content {
23class RenderProcessHost;
24class RenderViewHost;
25class ServiceRegistry;
26class SiteInstance;
27
28// The interface provides a communication conduit with a frame in the renderer.
29class CONTENT_EXPORT RenderFrameHost : public IPC::Listener,
30                                       public IPC::Sender {
31 public:
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);
35
36  virtual ~RenderFrameHost() {}
37
38  // Returns the route id for this frame.
39  virtual int GetRoutingID() = 0;
40
41  // Returns the SiteInstance grouping all RenderFrameHosts that have script
42  // access to this RenderFrameHost, and must therefore live in the same
43  // process.
44  virtual SiteInstance* GetSiteInstance() = 0;
45
46  // Returns the process for this frame.
47  virtual RenderProcessHost* GetProcess() = 0;
48
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
51  // RenderFrameHost.
52  virtual RenderFrameHost* GetParent() = 0;
53
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;
59
60  // Returns true if the frame is out of process.
61  virtual bool IsCrossProcessSubframe() = 0;
62
63  // Returns the last committed URL of the frame.
64  virtual GURL GetLastCommittedURL() = 0;
65
66  // Returns the associated widget's native view.
67  virtual gfx::NativeView GetNativeView() = 0;
68
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;
75
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;
83
84  // Temporary until we get rid of RenderViewHost.
85  virtual RenderViewHost* GetRenderViewHost() = 0;
86
87  // Returns the ServiceRegistry for this frame.
88  virtual ServiceRegistry* GetServiceRegistry() = 0;
89
90 private:
91  // This interface should only be implemented inside content.
92  friend class RenderFrameHostImpl;
93  RenderFrameHost() {}
94};
95
96}  // namespace content
97
98#endif  // CONTENT_PUBLIC_BROWSER_RENDER_FRAME_HOST_H_
99