render_view.h revision a1401311d1ab56c4ed0a474bd38c108f75cb0cd9
1// Copyright (c) 2012 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_RENDERER_RENDER_VIEW_H_
6#define CONTENT_PUBLIC_RENDERER_RENDER_VIEW_H_
7
8#include <string>
9
10#include "base/basictypes.h"
11#include "base/strings/string16.h"
12#include "content/common/content_export.h"
13#include "content/public/common/top_controls_state.h"
14#include "ipc/ipc_sender.h"
15#include "third_party/WebKit/public/web/WebPageVisibilityState.h"
16#include "ui/gfx/native_widget_types.h"
17
18struct WebPreferences;
19
20namespace blink {
21class WebElement;
22class WebFrame;
23class WebNode;
24class WebString;
25class WebURLRequest;
26class WebView;
27struct WebContextMenuData;
28}
29
30namespace gfx {
31class Size;
32}
33
34namespace content {
35
36class RenderFrame;
37class RenderViewVisitor;
38struct SSLStatus;
39
40class CONTENT_EXPORT RenderView : public IPC::Sender {
41 public:
42  // Returns the RenderView containing the given WebView.
43  static RenderView* FromWebView(blink::WebView* webview);
44
45  // Returns the RenderView for the given routing ID.
46  static RenderView* FromRoutingID(int routing_id);
47
48  // Visit all RenderViews with a live WebView (i.e., RenderViews that have
49  // been closed but not yet destroyed are excluded).
50  static void ForEach(RenderViewVisitor* visitor);
51
52  // Returns the main RenderFrame.
53  virtual RenderFrame* GetMainRenderFrame() = 0;
54
55  // Get the routing ID of the view.
56  virtual int GetRoutingID() const = 0;
57
58  // Page IDs allow the browser to identify pages in each renderer process for
59  // keeping back/forward history in sync.
60  // Note that this is NOT updated for every main frame navigation, only for
61  // "regular" navigations that go into session history. In particular, client
62  // redirects, like the page cycler uses (document.location.href="foo") do not
63  // count as regular navigations and do not increment the page id.
64  virtual int GetPageId() const = 0;
65
66  // Returns the size of the view.
67  virtual gfx::Size GetSize() const = 0;
68
69  // Gets WebKit related preferences associated with this view.
70  virtual WebPreferences& GetWebkitPreferences() = 0;
71
72  // Overrides the WebKit related preferences associated with this view. Note
73  // that the browser process may update the preferences at any time.
74  virtual void SetWebkitPreferences(const WebPreferences& preferences) = 0;
75
76  // Returns the associated WebView. May return NULL when the view is closing.
77  virtual blink::WebView* GetWebView() = 0;
78
79  // Gets the focused element. If no such element exists then
80  // the element will be Null.
81  virtual blink::WebElement GetFocusedElement() const = 0;
82
83  // Returns true if the parameter node is a textfield, text area, a content
84  // editable div, or has an ARIA role of textbox.
85  virtual bool IsEditableNode(const blink::WebNode& node) const = 0;
86
87  // Evaluates a string of JavaScript in a particular frame.
88  virtual void EvaluateScript(const base::string16& frame_xpath,
89                              const base::string16& jscript,
90                              int id,
91                              bool notify_result) = 0;
92
93  // Returns true if we should display scrollbars for the given view size and
94  // false if the scrollbars should be hidden.
95  virtual bool ShouldDisplayScrollbars(int width, int height) const = 0;
96
97  // Bitwise-ORed set of extra bindings that have been enabled.  See
98  // BindingsPolicy for details.
99  virtual int GetEnabledBindings() const = 0;
100
101  // Whether content state (such as form state, scroll position and page
102  // contents) should be sent to the browser immediately. This is normally
103  // false, but set to true by some tests.
104  virtual bool GetContentStateImmediately() const = 0;
105
106  // Filtered time per frame based on UpdateRect messages.
107  virtual float GetFilteredTimePerFrame() const = 0;
108
109  // Returns the current visibility of the WebView.
110  virtual blink::WebPageVisibilityState GetVisibilityState() const = 0;
111
112  // Displays a modal alert dialog containing the given message.  Returns
113  // once the user dismisses the dialog.
114  virtual void RunModalAlertDialog(blink::WebFrame* frame,
115                                   const blink::WebString& message) = 0;
116
117  // Used by plugins that load data in this RenderView to update the loading
118  // notifications.
119  virtual void DidStartLoading() = 0;
120  virtual void DidStopLoading() = 0;
121
122  // Notifies the renderer that a paint is to be generated for the size
123  // passed in.
124  virtual void Repaint(const gfx::Size& size) = 0;
125
126  // Inject edit commands to be used for the next keyboard event.
127  virtual void SetEditCommandForNextKeyEvent(const std::string& name,
128                                             const std::string& value) = 0;
129  virtual void ClearEditCommands() = 0;
130
131  // Returns a collection of security info about |frame|.
132  virtual SSLStatus GetSSLStatusOfFrame(blink::WebFrame* frame) const = 0;
133
134  // Returns |renderer_preferences_.accept_languages| value.
135  virtual const std::string& GetAcceptLanguages() const = 0;
136
137#if defined(OS_ANDROID)
138  virtual void UpdateTopControlsState(TopControlsState constraints,
139                                      TopControlsState current,
140                                      bool animate) = 0;
141#endif
142
143 protected:
144  virtual ~RenderView() {}
145
146 private:
147  // This interface should only be implemented inside content.
148  friend class RenderViewImpl;
149  RenderView() {}
150};
151
152}  // namespace content
153
154#endif  // CONTENT_PUBLIC_RENDERER_RENDER_VIEW_H_
155