| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CONTENT_RENDERER_RENDER_VIEW_IMPL_H_ | 5 #ifndef CONTENT_RENDERER_RENDER_VIEW_IMPL_H_ |
| 6 #define CONTENT_RENDERER_RENDER_VIEW_IMPL_H_ | 6 #define CONTENT_RENDERER_RENDER_VIEW_IMPL_H_ |
| 7 | 7 |
| 8 #include <set> | 8 #include <set> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 156 class RendererAccessibility; | 156 class RendererAccessibility; |
| 157 class RendererPpapiHost; | 157 class RendererPpapiHost; |
| 158 class RendererWebColorChooserImpl; | 158 class RendererWebColorChooserImpl; |
| 159 class RenderWidgetFullscreenPepper; | 159 class RenderWidgetFullscreenPepper; |
| 160 class SpeechRecognitionDispatcher; | 160 class SpeechRecognitionDispatcher; |
| 161 class WebIntentsHost; | 161 class WebIntentsHost; |
| 162 class WebPluginDelegateProxy; | 162 class WebPluginDelegateProxy; |
| 163 class WebUIBindings; | 163 class WebUIBindings; |
| 164 struct CustomContextMenuContext; | 164 struct CustomContextMenuContext; |
| 165 struct FileChooserParams; | 165 struct FileChooserParams; |
| 166 struct RenderViewImplParams; |
| 166 | 167 |
| 167 #if defined(OS_ANDROID) | 168 #if defined(OS_ANDROID) |
| 168 class WebMediaPlayerProxyImplAndroid; | 169 class WebMediaPlayerProxyImplAndroid; |
| 169 #endif | 170 #endif |
| 170 | 171 |
| 171 // We need to prevent a page from trying to create infinite popups. It is not | 172 // We need to prevent a page from trying to create infinite popups. It is not |
| 172 // as simple as keeping a count of the number of immediate children | 173 // as simple as keeping a count of the number of immediate children |
| 173 // popups. Having an html file that window.open()s itself would create | 174 // popups. Having an html file that window.open()s itself would create |
| 174 // an unlimited chain of RenderViews who only have one RenderView child. | 175 // an unlimited chain of RenderViews who only have one RenderView child. |
| 175 // | 176 // |
| 176 // Therefore, each new top level RenderView creates a new counter and shares it | 177 // Therefore, each new top level RenderView creates a new counter and shares it |
| 177 // with all its children and grandchildren popup RenderViewImpls created with | 178 // with all its children and grandchildren popup RenderViewImpls created with |
| 178 // createView() to have a sort of global limit for the page so no more than | 179 // createView() to have a sort of global limit for the page so no more than |
| 179 // kMaximumNumberOfPopups popups are created. | 180 // kMaximumNumberOfPopups popups are created. |
| 180 // | 181 // |
| 181 // This is a RefCounted holder of an int because I can't say | 182 // This is a RefCounted holder of an int because I can't say |
| 182 // scoped_refptr<int>. | 183 // scoped_refptr<int>. |
| 183 typedef base::RefCountedData<int> SharedRenderViewCounter; | 184 typedef base::RefCountedData<int> SharedRenderViewCounter; |
| 184 | 185 |
| 185 // | 186 // |
| 186 // RenderView is an object that manages a WebView object, and provides a | 187 // RenderView is an object that manages a WebView object, and provides a |
| 187 // communication interface with an embedding application process | 188 // communication interface with an embedding application process |
| 188 // | 189 // |
| 189 class RenderViewImpl : public RenderWidget, | 190 class CONTENT_EXPORT RenderViewImpl |
| 190 public WebKit::WebViewClient, | 191 : public RenderWidget, |
| 191 public WebKit::WebFrameClient, | 192 public WebKit::WebViewClient, |
| 192 public WebKit::WebPageSerializerClient, | 193 public WebKit::WebFrameClient, |
| 193 public RenderView, | 194 public WebKit::WebPageSerializerClient, |
| 194 public webkit::npapi::WebPluginPageDelegate, | 195 public RenderView, |
| 195 public webkit_media::WebMediaPlayerDelegate, | 196 public webkit::npapi::WebPluginPageDelegate, |
| 196 public WebGraphicsContext3DSwapBuffersClient, | 197 public webkit_media::WebMediaPlayerDelegate, |
| 197 public base::SupportsWeakPtr<RenderViewImpl> { | 198 public WebGraphicsContext3DSwapBuffersClient, |
| 199 public base::SupportsWeakPtr<RenderViewImpl> { |
| 198 public: | 200 public: |
| 199 // Creates a new RenderView. If this is a blocked popup or as a new tab, | 201 // Creates a new RenderView. If this is a blocked popup or as a new tab, |
| 200 // opener_id is the routing ID of the RenderView responsible for creating this | 202 // opener_id is the routing ID of the RenderView responsible for creating this |
| 201 // RenderView. |counter| is either a currently initialized counter, or NULL | 203 // RenderView. |counter| is either a currently initialized counter, or NULL |
| 202 // (in which case we treat this RenderView as a top level window). | 204 // (in which case we treat this RenderView as a top level window). |
| 203 CONTENT_EXPORT static RenderViewImpl* Create( | 205 CONTENT_EXPORT static RenderViewImpl* Create( |
| 204 int32 opener_id, | 206 int32 opener_id, |
| 205 const RendererPreferences& renderer_prefs, | 207 const RendererPreferences& renderer_prefs, |
| 206 const webkit_glue::WebPreferences& webkit_prefs, | 208 const webkit_glue::WebPreferences& webkit_prefs, |
| 207 SharedRenderViewCounter* counter, | 209 SharedRenderViewCounter* counter, |
| 208 int32 routing_id, | 210 int32 routing_id, |
| 209 int32 surface_id, | 211 int32 surface_id, |
| 210 int64 session_storage_namespace_id, | 212 int64 session_storage_namespace_id, |
| 211 const string16& frame_name, | 213 const string16& frame_name, |
| 212 bool is_renderer_created, | 214 bool is_renderer_created, |
| 213 bool swapped_out, | 215 bool swapped_out, |
| 214 int32 next_page_id, | 216 int32 next_page_id, |
| 215 const WebKit::WebScreenInfo& screen_info, | 217 const WebKit::WebScreenInfo& screen_info, |
| 216 AccessibilityMode accessibility_mode); | 218 AccessibilityMode accessibility_mode); |
| 217 | 219 |
| 220 // Used by content_layouttest_support to hook into the creation of |
| 221 // RenderViewImpls. |
| 222 static void InstallCreateHook( |
| 223 RenderViewImpl* (*create_render_view_impl)(RenderViewImplParams*)); |
| 224 |
| 218 // Returns the RenderViewImpl containing the given WebView. | 225 // Returns the RenderViewImpl containing the given WebView. |
| 219 CONTENT_EXPORT static RenderViewImpl* FromWebView(WebKit::WebView* webview); | 226 CONTENT_EXPORT static RenderViewImpl* FromWebView(WebKit::WebView* webview); |
| 220 | 227 |
| 221 // May return NULL when the view is closing. | 228 // May return NULL when the view is closing. |
| 222 CONTENT_EXPORT WebKit::WebView* webview() const; | 229 CONTENT_EXPORT WebKit::WebView* webview() const; |
| 223 | 230 |
| 224 // WebGraphicsContext3DSwapBuffersClient implementation. | 231 // WebGraphicsContext3DSwapBuffersClient implementation. |
| 225 | 232 |
| 226 // Called by a GraphicsContext associated with this view when swapbuffers | 233 // Called by a GraphicsContext associated with this view when swapbuffers |
| 227 // is posted, completes or is aborted. | 234 // is posted, completes or is aborted. |
| (...skipping 532 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 760 virtual void OnImeConfirmComposition( | 767 virtual void OnImeConfirmComposition( |
| 761 const string16& text, const ui::Range& replacement_range) OVERRIDE; | 768 const string16& text, const ui::Range& replacement_range) OVERRIDE; |
| 762 virtual void OnSetDeviceScaleFactor(float device_scale_factor) OVERRIDE; | 769 virtual void OnSetDeviceScaleFactor(float device_scale_factor) OVERRIDE; |
| 763 virtual ui::TextInputType GetTextInputType() OVERRIDE; | 770 virtual ui::TextInputType GetTextInputType() OVERRIDE; |
| 764 virtual void GetSelectionBounds(gfx::Rect* start, gfx::Rect* end) OVERRIDE; | 771 virtual void GetSelectionBounds(gfx::Rect* start, gfx::Rect* end) OVERRIDE; |
| 765 virtual void GetCompositionCharacterBounds( | 772 virtual void GetCompositionCharacterBounds( |
| 766 std::vector<gfx::Rect>* character_bounds) OVERRIDE; | 773 std::vector<gfx::Rect>* character_bounds) OVERRIDE; |
| 767 virtual bool CanComposeInline() OVERRIDE; | 774 virtual bool CanComposeInline() OVERRIDE; |
| 768 virtual bool WebWidgetHandlesCompositorScheduling() const OVERRIDE; | 775 virtual bool WebWidgetHandlesCompositorScheduling() const OVERRIDE; |
| 769 | 776 |
| 777 protected: |
| 778 RenderViewImpl(RenderViewImplParams* params); |
| 779 |
| 780 // Do not delete directly. This class is reference counted. |
| 781 virtual ~RenderViewImpl(); |
| 782 |
| 770 private: | 783 private: |
| 771 // For unit tests. | 784 // For unit tests. |
| 772 friend class ExternalPopupMenuTest; | 785 friend class ExternalPopupMenuTest; |
| 773 friend class PepperDeviceTest; | 786 friend class PepperDeviceTest; |
| 774 friend class RendererAccessibilityTest; | 787 friend class RendererAccessibilityTest; |
| 775 friend class WebIntentsHostTest; | 788 friend class WebIntentsHostTest; |
| 776 friend class RenderViewTest; | 789 friend class RenderViewTest; |
| 777 | 790 |
| 778 FRIEND_TEST_ALL_PREFIXES(ExternalPopupMenuRemoveTest, RemoveOnChange); | 791 FRIEND_TEST_ALL_PREFIXES(ExternalPopupMenuRemoveTest, RemoveOnChange); |
| 779 FRIEND_TEST_ALL_PREFIXES(ExternalPopupMenuTest, NormalCase); | 792 FRIEND_TEST_ALL_PREFIXES(ExternalPopupMenuTest, NormalCase); |
| (...skipping 27 matching lines...) Expand all Loading... |
| 807 FRIEND_TEST_ALL_PREFIXES(RenderViewImplTest, ZoomLimit); | 820 FRIEND_TEST_ALL_PREFIXES(RenderViewImplTest, ZoomLimit); |
| 808 | 821 |
| 809 typedef std::map<GURL, double> HostZoomLevels; | 822 typedef std::map<GURL, double> HostZoomLevels; |
| 810 | 823 |
| 811 enum ErrorPageType { | 824 enum ErrorPageType { |
| 812 DNS_ERROR, | 825 DNS_ERROR, |
| 813 HTTP_404, | 826 HTTP_404, |
| 814 CONNECTION_ERROR, | 827 CONNECTION_ERROR, |
| 815 }; | 828 }; |
| 816 | 829 |
| 817 RenderViewImpl(int32 opener_id, | |
| 818 const RendererPreferences& renderer_prefs, | |
| 819 const webkit_glue::WebPreferences& webkit_prefs, | |
| 820 SharedRenderViewCounter* counter, | |
| 821 int32 routing_id, | |
| 822 int32 surface_id, | |
| 823 int64 session_storage_namespace_id, | |
| 824 const string16& frame_name, | |
| 825 bool is_renderer_created, | |
| 826 bool swapped_out, | |
| 827 int32 next_page_id, | |
| 828 const WebKit::WebScreenInfo& screen_info, | |
| 829 AccessibilityMode accessibility_mode); | |
| 830 | |
| 831 // Do not delete directly. This class is reference counted. | |
| 832 virtual ~RenderViewImpl(); | |
| 833 | |
| 834 void UpdateURL(WebKit::WebFrame* frame); | 830 void UpdateURL(WebKit::WebFrame* frame); |
| 835 void UpdateTitle(WebKit::WebFrame* frame, const string16& title, | 831 void UpdateTitle(WebKit::WebFrame* frame, const string16& title, |
| 836 WebKit::WebTextDirection title_direction); | 832 WebKit::WebTextDirection title_direction); |
| 837 void UpdateSessionHistory(WebKit::WebFrame* frame); | 833 void UpdateSessionHistory(WebKit::WebFrame* frame); |
| 838 void SendUpdateState(const WebKit::WebHistoryItem& item); | 834 void SendUpdateState(const WebKit::WebHistoryItem& item); |
| 839 | 835 |
| 840 // Update current main frame's encoding and send it to browser window. | 836 // Update current main frame's encoding and send it to browser window. |
| 841 // Since we want to let users see the right encoding info from menu | 837 // Since we want to let users see the right encoding info from menu |
| 842 // before finishing loading, we call the UpdateEncoding in | 838 // before finishing loading, we call the UpdateEncoding in |
| 843 // a) function:DidCommitLoadForFrame. When this function is called, | 839 // a) function:DidCommitLoadForFrame. When this function is called, |
| (...skipping 711 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1555 // use the Observer interface to filter IPC messages and receive frame change | 1551 // use the Observer interface to filter IPC messages and receive frame change |
| 1556 // notifications. | 1552 // notifications. |
| 1557 // --------------------------------------------------------------------------- | 1553 // --------------------------------------------------------------------------- |
| 1558 | 1554 |
| 1559 DISALLOW_COPY_AND_ASSIGN(RenderViewImpl); | 1555 DISALLOW_COPY_AND_ASSIGN(RenderViewImpl); |
| 1560 }; | 1556 }; |
| 1561 | 1557 |
| 1562 } // namespace content | 1558 } // namespace content |
| 1563 | 1559 |
| 1564 #endif // CONTENT_RENDERER_RENDER_VIEW_IMPL_H_ | 1560 #endif // CONTENT_RENDERER_RENDER_VIEW_IMPL_H_ |
| OLD | NEW |