render_view.h revision 0529e5d033099cbfc42635f6f6183833b09dff6e
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 WebLocalFrame; 24class WebNode; 25class WebString; 26class WebURLRequest; 27class WebView; 28struct WebContextMenuData; 29} 30 31namespace gfx { 32class Size; 33} 34 35namespace content { 36 37class RenderFrame; 38class RenderViewVisitor; 39struct SSLStatus; 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 // Returns the main RenderFrame. 54 virtual RenderFrame* GetMainRenderFrame() = 0; 55 56 // Get the routing ID of the view. 57 virtual int GetRoutingID() const = 0; 58 59 // Page IDs allow the browser to identify pages in each renderer process for 60 // keeping back/forward history in sync. 61 // Note that this is NOT updated for every main frame navigation, only for 62 // "regular" navigations that go into session history. In particular, client 63 // redirects, like the page cycler uses (document.location.href="foo") do not 64 // count as regular navigations and do not increment the page id. 65 virtual int GetPageId() const = 0; 66 67 // Returns the size of the view. 68 virtual gfx::Size GetSize() const = 0; 69 70 // Gets WebKit related preferences associated with this view. 71 virtual WebPreferences& GetWebkitPreferences() = 0; 72 73 // Overrides the WebKit related preferences associated with this view. Note 74 // that the browser process may update the preferences at any time. 75 virtual void SetWebkitPreferences(const WebPreferences& preferences) = 0; 76 77 // Returns the associated WebView. May return NULL when the view is closing. 78 virtual blink::WebView* GetWebView() = 0; 79 80 // Gets the focused element. If no such element exists then 81 // the element will be Null. 82 virtual blink::WebElement GetFocusedElement() 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 // 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 // Filtered time per frame based on UpdateRect messages. 102 virtual float GetFilteredTimePerFrame() const = 0; 103 104 // Returns the current visibility of the WebView. 105 virtual blink::WebPageVisibilityState GetVisibilityState() const = 0; 106 107 // Used by plugins that load data in this RenderView to update the loading 108 // notifications. 109 virtual void DidStartLoading() = 0; 110 virtual void DidStopLoading() = 0; 111 112 // Notifies the renderer that a paint is to be generated for the size 113 // passed in. 114 virtual void Repaint(const gfx::Size& size) = 0; 115 116 // Inject edit commands to be used for the next keyboard event. 117 virtual void SetEditCommandForNextKeyEvent(const std::string& name, 118 const std::string& value) = 0; 119 virtual void ClearEditCommands() = 0; 120 121 // Returns a collection of security info about |frame|. 122 virtual SSLStatus GetSSLStatusOfFrame(blink::WebFrame* frame) const = 0; 123 124 // Returns |renderer_preferences_.accept_languages| value. 125 virtual const std::string& GetAcceptLanguages() const = 0; 126 127#if defined(OS_ANDROID) 128 virtual void UpdateTopControlsState(TopControlsState constraints, 129 TopControlsState current, 130 bool animate) = 0; 131#endif 132 133 protected: 134 virtual ~RenderView() {} 135 136 private: 137 // This interface should only be implemented inside content. 138 friend class RenderViewImpl; 139 RenderView() {} 140}; 141 142} // namespace content 143 144#endif // CONTENT_PUBLIC_RENDERER_RENDER_VIEW_H_ 145