render_view.h revision 5f1c94371a64b3196d4be9466099bb892df9b88e
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 18namespace blink { 19class WebElement; 20class WebFrame; 21class WebLocalFrame; 22class WebNode; 23class WebString; 24class WebURLRequest; 25class WebView; 26struct WebContextMenuData; 27} 28 29namespace gfx { 30class Point; 31class Size; 32} 33 34namespace content { 35 36class RenderFrame; 37class RenderViewVisitor; 38struct SSLStatus; 39struct WebPreferences; 40 41class CONTENT_EXPORT RenderView : public IPC::Sender { 42 public: 43 // Returns the RenderView containing the given WebView. 44 static RenderView* FromWebView(blink::WebView* webview); 45 46 // Returns the RenderView for the given routing ID. 47 static RenderView* FromRoutingID(int routing_id); 48 49 // Visit all RenderViews with a live WebView (i.e., RenderViews that have 50 // been closed but not yet destroyed are excluded). 51 static void ForEach(RenderViewVisitor* visitor); 52 53 // Applies WebKit related preferences to this view. 54 static void ApplyWebPreferences(const WebPreferences& preferences, 55 blink::WebView* web_view); 56 57 // Returns the main RenderFrame. 58 virtual RenderFrame* GetMainRenderFrame() = 0; 59 60 // Get the routing ID of the view. 61 virtual int GetRoutingID() const = 0; 62 63 // Returns the size of the view. 64 virtual gfx::Size GetSize() const = 0; 65 66 // Gets WebKit related preferences associated with this view. 67 virtual WebPreferences& GetWebkitPreferences() = 0; 68 69 // Overrides the WebKit related preferences associated with this view. Note 70 // that the browser process may update the preferences at any time. 71 virtual void SetWebkitPreferences(const WebPreferences& preferences) = 0; 72 73 // Returns the associated WebView. May return NULL when the view is closing. 74 virtual blink::WebView* GetWebView() = 0; 75 76 // Gets the focused element. If no such element exists then 77 // the element will be Null. 78 virtual blink::WebElement GetFocusedElement() const = 0; 79 80 // Returns true if the parameter node is a textfield, text area, a content 81 // editable div, or has an ARIA role of textbox. 82 virtual bool IsEditableNode(const blink::WebNode& node) const = 0; 83 84 // Returns true if a hit test for |point| returns a descendant of |node|. 85 virtual bool NodeContainsPoint(const blink::WebNode& node, 86 const gfx::Point& point) const = 0; 87 88 // Returns true if we should display scrollbars for the given view size and 89 // false if the scrollbars should be hidden. 90 virtual bool ShouldDisplayScrollbars(int width, int height) const = 0; 91 92 // Bitwise-ORed set of extra bindings that have been enabled. See 93 // BindingsPolicy for details. 94 virtual int GetEnabledBindings() const = 0; 95 96 // Whether content state (such as form state, scroll position and page 97 // contents) should be sent to the browser immediately. This is normally 98 // false, but set to true by some tests. 99 virtual bool GetContentStateImmediately() const = 0; 100 101 // Returns the current visibility of the WebView. 102 virtual blink::WebPageVisibilityState GetVisibilityState() const = 0; 103 104 // Used by plugins that load data in this RenderView to update the loading 105 // notifications. 106 virtual void DidStartLoading() = 0; 107 virtual void DidStopLoading() = 0; 108 109 // Notifies the renderer that a paint is to be generated for the size 110 // passed in. 111 virtual void Repaint(const gfx::Size& size) = 0; 112 113 // Inject edit commands to be used for the next keyboard event. 114 virtual void SetEditCommandForNextKeyEvent(const std::string& name, 115 const std::string& value) = 0; 116 virtual void ClearEditCommands() = 0; 117 118 // Returns a collection of security info about |frame|. 119 virtual SSLStatus GetSSLStatusOfFrame(blink::WebFrame* frame) const = 0; 120 121 // Returns |renderer_preferences_.accept_languages| value. 122 virtual const std::string& GetAcceptLanguages() const = 0; 123 124#if defined(OS_ANDROID) 125 virtual void UpdateTopControlsState(TopControlsState constraints, 126 TopControlsState current, 127 bool animate) = 0; 128#endif 129 130 protected: 131 virtual ~RenderView() {} 132 133 private: 134 // This interface should only be implemented inside content. 135 friend class RenderViewImpl; 136 RenderView() {} 137}; 138 139} // namespace content 140 141#endif // CONTENT_PUBLIC_RENDERER_RENDER_VIEW_H_ 142