| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 CHROME_RENDERER_RENDER_VIEW_H_ | 5 #ifndef CHROME_RENDERER_RENDER_VIEW_H_ |
| 6 #define CHROME_RENDERER_RENDER_VIEW_H_ | 6 #define CHROME_RENDERER_RENDER_VIEW_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <set> | 9 #include <set> |
| 10 #include <string> | 10 #include <string> |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 #include "chrome/renderer/extensions/extension_process_bindings.h" | 31 #include "chrome/renderer/extensions/extension_process_bindings.h" |
| 32 #include "chrome/renderer/external_host_bindings.h" | 32 #include "chrome/renderer/external_host_bindings.h" |
| 33 #include "chrome/renderer/notification_provider.h" | 33 #include "chrome/renderer/notification_provider.h" |
| 34 #include "chrome/renderer/render_widget.h" | 34 #include "chrome/renderer/render_widget.h" |
| 35 #include "chrome/renderer/render_view_visitor.h" | 35 #include "chrome/renderer/render_view_visitor.h" |
| 36 #include "third_party/skia/include/core/SkBitmap.h" | 36 #include "third_party/skia/include/core/SkBitmap.h" |
| 37 #include "testing/gtest/include/gtest/gtest_prod.h" | 37 #include "testing/gtest/include/gtest/gtest_prod.h" |
| 38 #include "webkit/api/public/WebConsoleMessage.h" | 38 #include "webkit/api/public/WebConsoleMessage.h" |
| 39 #include "webkit/api/public/WebContextMenuData.h" | 39 #include "webkit/api/public/WebContextMenuData.h" |
| 40 #include "webkit/api/public/WebFrameClient.h" | 40 #include "webkit/api/public/WebFrameClient.h" |
| 41 #include "webkit/api/public/WebMediaPlayerAction.h" |
| 41 #include "webkit/api/public/WebNode.h" | 42 #include "webkit/api/public/WebNode.h" |
| 42 #include "webkit/api/public/WebTextDirection.h" | 43 #include "webkit/api/public/WebTextDirection.h" |
| 44 #include "webkit/api/public/WebView.h" |
| 45 #include "webkit/api/public/WebViewClient.h" |
| 43 #include "webkit/glue/dom_serializer_delegate.h" | 46 #include "webkit/glue/dom_serializer_delegate.h" |
| 44 #include "webkit/glue/form_data.h" | 47 #include "webkit/glue/form_data.h" |
| 45 #include "webkit/glue/image_resource_fetcher.h" | 48 #include "webkit/glue/image_resource_fetcher.h" |
| 46 #include "webkit/glue/password_form_dom_manager.h" | 49 #include "webkit/glue/password_form_dom_manager.h" |
| 47 #include "webkit/glue/webaccessibilitymanager.h" | 50 #include "webkit/glue/webaccessibilitymanager.h" |
| 48 #include "webkit/glue/webplugin_page_delegate.h" | 51 #include "webkit/glue/webplugin_page_delegate.h" |
| 49 #include "webkit/glue/webpreferences.h" | 52 #include "webkit/glue/webpreferences.h" |
| 50 #include "webkit/glue/webview_delegate.h" | |
| 51 #include "webkit/glue/webview.h" | |
| 52 | 53 |
| 53 #if defined(OS_WIN) | 54 #if defined(OS_WIN) |
| 54 // RenderView is a diamond-shaped hierarchy, with WebWidgetClient at the root. | 55 // RenderView is a diamond-shaped hierarchy, with WebWidgetClient at the root. |
| 55 // VS warns when we inherit the WebWidgetClient method implementations from | 56 // VS warns when we inherit the WebWidgetClient method implementations from |
| 56 // RenderWidget. It's safe to ignore that warning. | 57 // RenderWidget. It's safe to ignore that warning. |
| 57 #pragma warning(disable: 4250) | 58 #pragma warning(disable: 4250) |
| 58 #endif | 59 #endif |
| 59 | 60 |
| 60 class AudioMessageFilter; | 61 class AudioMessageFilter; |
| 61 class DictionaryValue; | 62 class DictionaryValue; |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 101 // | 102 // |
| 102 // This is a RefCounted holder of an int because I can't say | 103 // This is a RefCounted holder of an int because I can't say |
| 103 // scoped_refptr<int>. | 104 // scoped_refptr<int>. |
| 104 typedef base::RefCountedData<int> SharedRenderViewCounter; | 105 typedef base::RefCountedData<int> SharedRenderViewCounter; |
| 105 | 106 |
| 106 // | 107 // |
| 107 // RenderView is an object that manages a WebView object, and provides a | 108 // RenderView is an object that manages a WebView object, and provides a |
| 108 // communication interface with an embedding application process | 109 // communication interface with an embedding application process |
| 109 // | 110 // |
| 110 class RenderView : public RenderWidget, | 111 class RenderView : public RenderWidget, |
| 111 public WebViewDelegate, | 112 public WebKit::WebViewClient, |
| 112 public WebKit::WebFrameClient, | 113 public WebKit::WebFrameClient, |
| 113 public webkit_glue::WebPluginPageDelegate, | 114 public webkit_glue::WebPluginPageDelegate, |
| 114 public webkit_glue::DomSerializerDelegate, | 115 public webkit_glue::DomSerializerDelegate, |
| 115 public base::SupportsWeakPtr<RenderView> { | 116 public base::SupportsWeakPtr<RenderView> { |
| 116 public: | 117 public: |
| 117 // Visit all RenderViews with a live WebView (i.e., RenderViews that have | 118 // Visit all RenderViews with a live WebView (i.e., RenderViews that have |
| 118 // been closed but not yet destroyed are excluded). | 119 // been closed but not yet destroyed are excluded). |
| 119 static void ForEach(RenderViewVisitor* visitor); | 120 static void ForEach(RenderViewVisitor* visitor); |
| 120 | 121 |
| 121 // Returns the RenderView containing the given WebView. | 122 // Returns the RenderView containing the given WebView. |
| 122 static RenderView* FromWebView(WebView* webview); | 123 static RenderView* FromWebView(WebKit::WebView* webview); |
| 123 | 124 |
| 124 // Creates a new RenderView. The parent_hwnd specifies a HWND to use as the | 125 // Creates a new RenderView. The parent_hwnd specifies a HWND to use as the |
| 125 // parent of the WebView HWND that will be created. If this is a constrained | 126 // parent of the WebView HWND that will be created. If this is a constrained |
| 126 // popup or as a new tab, opener_id is the routing ID of the RenderView | 127 // popup or as a new tab, opener_id is the routing ID of the RenderView |
| 127 // responsible for creating this RenderView (corresponding to parent_hwnd). | 128 // responsible for creating this RenderView (corresponding to parent_hwnd). |
| 128 // |counter| is either a currently initialized counter, or NULL (in which case | 129 // |counter| is either a currently initialized counter, or NULL (in which case |
| 129 // we treat this RenderView as a top level window). | 130 // we treat this RenderView as a top level window). |
| 130 static RenderView* Create( | 131 static RenderView* Create( |
| 131 RenderThreadBase* render_thread, | 132 RenderThreadBase* render_thread, |
| 132 gfx::NativeViewId parent_hwnd, | 133 gfx::NativeViewId parent_hwnd, |
| 133 int32 opener_id, | 134 int32 opener_id, |
| 134 const RendererPreferences& renderer_prefs, | 135 const RendererPreferences& renderer_prefs, |
| 135 const WebPreferences& webkit_prefs, | 136 const WebPreferences& webkit_prefs, |
| 136 SharedRenderViewCounter* counter, | 137 SharedRenderViewCounter* counter, |
| 137 int32 routing_id); | 138 int32 routing_id); |
| 138 | 139 |
| 139 // Sets the "next page id" counter. | 140 // Sets the "next page id" counter. |
| 140 static void SetNextPageID(int32 next_page_id); | 141 static void SetNextPageID(int32 next_page_id); |
| 141 | 142 |
| 142 // May return NULL when the view is closing. | 143 // May return NULL when the view is closing. |
| 143 WebView* webview() const { | 144 WebKit::WebView* webview() const { |
| 144 return static_cast<WebView*>(webwidget()); | 145 return static_cast<WebKit::WebView*>(webwidget()); |
| 145 } | 146 } |
| 146 | 147 |
| 147 gfx::NativeViewId host_window() const { | 148 gfx::NativeViewId host_window() const { |
| 148 return host_window_; | 149 return host_window_; |
| 149 } | 150 } |
| 150 | 151 |
| 151 int browser_window_id() { | 152 int browser_window_id() { |
| 152 return browser_window_id_; | 153 return browser_window_id_; |
| 153 } | 154 } |
| 154 | 155 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 170 const WebKit::WebURLError& error, | 171 const WebKit::WebURLError& error, |
| 171 const std::string& html, | 172 const std::string& html, |
| 172 bool replace); | 173 bool replace); |
| 173 virtual void OnMissingPluginStatus( | 174 virtual void OnMissingPluginStatus( |
| 174 WebPluginDelegateProxy* delegate, | 175 WebPluginDelegateProxy* delegate, |
| 175 int status); | 176 int status); |
| 176 virtual void UserMetricsRecordAction(const std::wstring& action); | 177 virtual void UserMetricsRecordAction(const std::wstring& action); |
| 177 virtual void DnsPrefetch(const std::vector<std::string>& host_names); | 178 virtual void DnsPrefetch(const std::vector<std::string>& host_names); |
| 178 | 179 |
| 179 // WebKit::WebViewClient | 180 // WebKit::WebViewClient |
| 180 virtual WebView* createView(WebKit::WebFrame* creator); | 181 virtual WebKit::WebView* createView(WebKit::WebFrame* creator); |
| 181 virtual WebKit::WebWidget* createPopupMenu(bool activatable); | 182 virtual WebKit::WebWidget* createPopupMenu(bool activatable); |
| 182 virtual WebKit::WebWidget* createPopupMenu( | 183 virtual WebKit::WebWidget* createPopupMenu( |
| 183 const WebKit::WebPopupMenuInfo& info); | 184 const WebKit::WebPopupMenuInfo& info); |
| 184 virtual void didAddMessageToConsole( | 185 virtual void didAddMessageToConsole( |
| 185 const WebKit::WebConsoleMessage& message, | 186 const WebKit::WebConsoleMessage& message, |
| 186 const WebKit::WebString& source_name, unsigned source_line); | 187 const WebKit::WebString& source_name, unsigned source_line); |
| 187 virtual void printPage(WebKit::WebFrame* frame); | 188 virtual void printPage(WebKit::WebFrame* frame); |
| 188 virtual WebKit::WebNotificationPresenter* notificationPresenter() { | 189 virtual WebKit::WebNotificationPresenter* notificationPresenter() { |
| 189 return NULL; | 190 return NULL; |
| 190 } | 191 } |
| (...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 489 // a NOP. Typically called on a timer, so the load ID may have changed in the | 490 // a NOP. Typically called on a timer, so the load ID may have changed in the |
| 490 // meantime. | 491 // meantime. |
| 491 void CapturePageInfo(int load_id, bool preliminary_capture); | 492 void CapturePageInfo(int load_id, bool preliminary_capture); |
| 492 | 493 |
| 493 // Called to retrieve the text from the given frame contents, the page text | 494 // Called to retrieve the text from the given frame contents, the page text |
| 494 // up to the maximum amount will be placed into the given buffer | 495 // up to the maximum amount will be placed into the given buffer |
| 495 void CaptureText(WebKit::WebFrame* frame, std::wstring* contents); | 496 void CaptureText(WebKit::WebFrame* frame, std::wstring* contents); |
| 496 | 497 |
| 497 // Creates a thumbnail of |frame|'s contents resized to (|w|, |h|) | 498 // Creates a thumbnail of |frame|'s contents resized to (|w|, |h|) |
| 498 // and puts that in |thumbnail|. Thumbnail metadata goes in |score|. | 499 // and puts that in |thumbnail|. Thumbnail metadata goes in |score|. |
| 499 bool CaptureThumbnail(WebView* view, int w, int h, | 500 bool CaptureThumbnail(WebKit::WebView* view, int w, int h, |
| 500 SkBitmap* thumbnail, | 501 SkBitmap* thumbnail, |
| 501 ThumbnailScore* score); | 502 ThumbnailScore* score); |
| 502 | 503 |
| 503 // Calculates how "boring" a thumbnail is. The boring score is the | 504 // Calculates how "boring" a thumbnail is. The boring score is the |
| 504 // 0,1 ranged percentage of pixels that are the most common | 505 // 0,1 ranged percentage of pixels that are the most common |
| 505 // luma. Higher boring scores indicate that a higher percentage of a | 506 // luma. Higher boring scores indicate that a higher percentage of a |
| 506 // bitmap are all the same brightness. | 507 // bitmap are all the same brightness. |
| 507 double CalculateBoringScore(SkBitmap* bitmap); | 508 double CalculateBoringScore(SkBitmap* bitmap); |
| 508 | 509 |
| 509 bool RunJavaScriptMessage(int type, | 510 bool RunJavaScriptMessage(int type, |
| (...skipping 465 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 975 WebPreferences webkit_preferences_; | 976 WebPreferences webkit_preferences_; |
| 976 | 977 |
| 977 // Stores edit commands associated to the next key event. | 978 // Stores edit commands associated to the next key event. |
| 978 // Shall be cleared as soon as the next key event is processed. | 979 // Shall be cleared as soon as the next key event is processed. |
| 979 EditCommands edit_commands_; | 980 EditCommands edit_commands_; |
| 980 | 981 |
| 981 // ImageResourceFetchers schedule via DownloadImage. | 982 // ImageResourceFetchers schedule via DownloadImage. |
| 982 typedef std::set<webkit_glue::ImageResourceFetcher*> ImageResourceFetcherSet; | 983 typedef std::set<webkit_glue::ImageResourceFetcher*> ImageResourceFetcherSet; |
| 983 ImageResourceFetcherSet image_fetchers_; | 984 ImageResourceFetcherSet image_fetchers_; |
| 984 | 985 |
| 985 typedef std::map<WebView*, RenderView*> ViewMap; | 986 typedef std::map<WebKit::WebView*, RenderView*> ViewMap; |
| 986 | 987 |
| 987 DISALLOW_COPY_AND_ASSIGN(RenderView); | 988 DISALLOW_COPY_AND_ASSIGN(RenderView); |
| 988 }; | 989 }; |
| 989 | 990 |
| 990 #endif // CHROME_RENDERER_RENDER_VIEW_H_ | 991 #endif // CHROME_RENDERER_RENDER_VIEW_H_ |
| OLD | NEW |