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