| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_BROWSER_FRAME_HOST_RENDER_FRAME_HOST_IMPL_H_ | 5 #ifndef CONTENT_BROWSER_FRAME_HOST_RENDER_FRAME_HOST_IMPL_H_ |
| 6 #define CONTENT_BROWSER_FRAME_HOST_RENDER_FRAME_HOST_IMPL_H_ | 6 #define CONTENT_BROWSER_FRAME_HOST_RENDER_FRAME_HOST_IMPL_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/callback.h" | 11 #include "base/callback.h" |
| 12 #include "base/compiler_specific.h" | 12 #include "base/compiler_specific.h" |
| 13 #include "base/memory/weak_ptr.h" | 13 #include "base/memory/weak_ptr.h" |
| 14 #include "base/strings/string16.h" | 14 #include "base/strings/string16.h" |
| 15 #include "base/time/time.h" | 15 #include "base/time/time.h" |
| 16 #include "content/browser/accessibility/browser_accessibility_manager.h" |
| 17 #include "content/common/accessibility_mode_enums.h" |
| 16 #include "content/common/content_export.h" | 18 #include "content/common/content_export.h" |
| 17 #include "content/common/mojo/service_registry_impl.h" | 19 #include "content/common/mojo/service_registry_impl.h" |
| 18 #include "content/public/browser/render_frame_host.h" | 20 #include "content/public/browser/render_frame_host.h" |
| 19 #include "content/public/common/javascript_message_type.h" | 21 #include "content/public/common/javascript_message_type.h" |
| 20 #include "content/public/common/page_transition_types.h" | 22 #include "content/public/common/page_transition_types.h" |
| 21 #include "net/http/http_response_headers.h" | 23 #include "net/http/http_response_headers.h" |
| 22 #include "third_party/WebKit/public/web/WebTextDirection.h" | 24 #include "third_party/WebKit/public/web/WebTextDirection.h" |
| 25 #include "ui/accessibility/ax_node_data.h" |
| 23 | 26 |
| 24 class GURL; | 27 class GURL; |
| 28 struct AccessibilityHostMsg_EventParams; |
| 29 struct AccessibilityHostMsg_LocationChangeParams; |
| 25 struct FrameHostMsg_DidFailProvisionalLoadWithError_Params; | 30 struct FrameHostMsg_DidFailProvisionalLoadWithError_Params; |
| 26 struct FrameHostMsg_OpenURL_Params; | 31 struct FrameHostMsg_OpenURL_Params; |
| 27 struct FrameHostMsg_BeginNavigation_Params; | 32 struct FrameHostMsg_BeginNavigation_Params; |
| 28 struct FrameMsg_Navigate_Params; | 33 struct FrameMsg_Navigate_Params; |
| 29 | 34 |
| 30 namespace base { | 35 namespace base { |
| 31 class FilePath; | 36 class FilePath; |
| 32 class ListValue; | 37 class ListValue; |
| 33 } | 38 } |
| 34 | 39 |
| 35 namespace content { | 40 namespace content { |
| 36 | 41 |
| 37 class CrossProcessFrameConnector; | 42 class CrossProcessFrameConnector; |
| 38 class CrossSiteTransferringRequest; | 43 class CrossSiteTransferringRequest; |
| 39 class FrameTree; | 44 class FrameTree; |
| 40 class FrameTreeNode; | 45 class FrameTreeNode; |
| 41 class RenderFrameHostDelegate; | 46 class RenderFrameHostDelegate; |
| 42 class RenderFrameProxyHost; | 47 class RenderFrameProxyHost; |
| 43 class RenderProcessHost; | 48 class RenderProcessHost; |
| 44 class RenderViewHostImpl; | 49 class RenderViewHostImpl; |
| 45 class RenderWidgetHostImpl; | 50 class RenderWidgetHostImpl; |
| 46 struct ContextMenuParams; | 51 struct ContextMenuParams; |
| 47 struct GlobalRequestID; | 52 struct GlobalRequestID; |
| 48 struct Referrer; | 53 struct Referrer; |
| 49 struct ShowDesktopNotificationHostMsgParams; | 54 struct ShowDesktopNotificationHostMsgParams; |
| 50 | 55 |
| 51 class CONTENT_EXPORT RenderFrameHostImpl : public RenderFrameHost { | 56 class CONTENT_EXPORT RenderFrameHostImpl |
| 57 : public RenderFrameHost, |
| 58 public BrowserAccessibilityDelegate { |
| 52 public: | 59 public: |
| 53 static RenderFrameHostImpl* FromID(int process_id, int routing_id); | 60 static RenderFrameHostImpl* FromID(int process_id, int routing_id); |
| 54 | 61 |
| 55 virtual ~RenderFrameHostImpl(); | 62 virtual ~RenderFrameHostImpl(); |
| 56 | 63 |
| 57 // RenderFrameHost | 64 // RenderFrameHost |
| 58 virtual int GetRoutingID() OVERRIDE; | 65 virtual int GetRoutingID() OVERRIDE; |
| 59 virtual SiteInstance* GetSiteInstance() OVERRIDE; | 66 virtual SiteInstance* GetSiteInstance() OVERRIDE; |
| 60 virtual RenderProcessHost* GetProcess() OVERRIDE; | 67 virtual RenderProcessHost* GetProcess() OVERRIDE; |
| 61 virtual RenderFrameHost* GetParent() OVERRIDE; | 68 virtual RenderFrameHost* GetParent() OVERRIDE; |
| 62 virtual const std::string& GetFrameName() OVERRIDE; | 69 virtual const std::string& GetFrameName() OVERRIDE; |
| 63 virtual bool IsCrossProcessSubframe() OVERRIDE; | 70 virtual bool IsCrossProcessSubframe() OVERRIDE; |
| 64 virtual GURL GetLastCommittedURL() OVERRIDE; | 71 virtual GURL GetLastCommittedURL() OVERRIDE; |
| 65 virtual gfx::NativeView GetNativeView() OVERRIDE; | 72 virtual gfx::NativeView GetNativeView() OVERRIDE; |
| 66 virtual void ExecuteJavaScript( | 73 virtual void ExecuteJavaScript( |
| 67 const base::string16& javascript) OVERRIDE; | 74 const base::string16& javascript) OVERRIDE; |
| 68 virtual void ExecuteJavaScript( | 75 virtual void ExecuteJavaScript( |
| 69 const base::string16& javascript, | 76 const base::string16& javascript, |
| 70 const JavaScriptResultCallback& callback) OVERRIDE; | 77 const JavaScriptResultCallback& callback) OVERRIDE; |
| 71 virtual RenderViewHost* GetRenderViewHost() OVERRIDE; | 78 virtual RenderViewHost* GetRenderViewHost() OVERRIDE; |
| 72 virtual ServiceRegistry* GetServiceRegistry() OVERRIDE; | 79 virtual ServiceRegistry* GetServiceRegistry() OVERRIDE; |
| 73 | 80 |
| 74 // IPC::Sender | 81 // IPC::Sender |
| 75 virtual bool Send(IPC::Message* msg) OVERRIDE; | 82 virtual bool Send(IPC::Message* msg) OVERRIDE; |
| 76 | 83 |
| 77 // IPC::Listener | 84 // IPC::Listener |
| 78 virtual bool OnMessageReceived(const IPC::Message& msg) OVERRIDE; | 85 virtual bool OnMessageReceived(const IPC::Message& msg) OVERRIDE; |
| 79 | 86 |
| 87 // BrowserAccessibilityDelegate |
| 88 virtual void AccessibilitySetFocus(int acc_obj_id) OVERRIDE; |
| 89 virtual void AccessibilityDoDefaultAction(int acc_obj_id) OVERRIDE; |
| 90 virtual void AccessibilityShowMenu(const gfx::Point& global_point) OVERRIDE; |
| 91 virtual void AccessibilityScrollToMakeVisible( |
| 92 int acc_obj_id, const gfx::Rect& subfocus) OVERRIDE; |
| 93 virtual void AccessibilityScrollToPoint( |
| 94 int acc_obj_id, const gfx::Point& point) OVERRIDE; |
| 95 virtual void AccessibilitySetTextSelection( |
| 96 int acc_obj_id, int start_offset, int end_offset) OVERRIDE; |
| 97 virtual bool AccessibilityViewHasFocus() const OVERRIDE; |
| 98 virtual gfx::Rect AccessibilityGetViewBounds() const OVERRIDE; |
| 99 virtual gfx::Point AccessibilityOriginInScreen(const gfx::Rect& bounds) |
| 100 const OVERRIDE; |
| 101 virtual void AccessibilityHitTest(const gfx::Point& point) OVERRIDE; |
| 102 virtual void AccessibilityFatalError() OVERRIDE; |
| 103 |
| 80 void Init(); | 104 void Init(); |
| 81 int routing_id() const { return routing_id_; } | 105 int routing_id() const { return routing_id_; } |
| 82 void OnCreateChildFrame(int new_routing_id, | 106 void OnCreateChildFrame(int new_routing_id, |
| 83 const std::string& frame_name); | 107 const std::string& frame_name); |
| 84 | 108 |
| 85 RenderViewHostImpl* render_view_host() { return render_view_host_; } | 109 RenderViewHostImpl* render_view_host() { return render_view_host_; } |
| 86 RenderFrameHostDelegate* delegate() { return delegate_; } | 110 RenderFrameHostDelegate* delegate() { return delegate_; } |
| 87 FrameTreeNode* frame_tree_node() { return frame_tree_node_; } | 111 FrameTreeNode* frame_tree_node() { return frame_tree_node_; } |
| 88 // TODO(nasko): The RenderWidgetHost will be owned by RenderFrameHost in | 112 // TODO(nasko): The RenderWidgetHost will be owned by RenderFrameHost in |
| 89 // the future, so update this accessor to return the right pointer. | 113 // the future, so update this accessor to return the right pointer. |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 176 bool dialog_was_suppressed); | 200 bool dialog_was_suppressed); |
| 177 | 201 |
| 178 // Called when an HTML5 notification is closed. | 202 // Called when an HTML5 notification is closed. |
| 179 void NotificationClosed(int notification_id); | 203 void NotificationClosed(int notification_id); |
| 180 | 204 |
| 181 // Sets whether there is an outstanding transition request. This is called at | 205 // Sets whether there is an outstanding transition request. This is called at |
| 182 // the start of a provisional load for the main frame, and cleared when we | 206 // the start of a provisional load for the main frame, and cleared when we |
| 183 // hear the response or commit. | 207 // hear the response or commit. |
| 184 void SetHasPendingTransitionRequest(bool has_pending_request); | 208 void SetHasPendingTransitionRequest(bool has_pending_request); |
| 185 | 209 |
| 210 // Send a message to the renderer process to change the accessibility mode. |
| 211 void SetAccessibilityMode(AccessibilityMode AccessibilityMode); |
| 212 |
| 213 // Turn on accessibility testing. The given callback will be run |
| 214 // every time an accessibility notification is received from the |
| 215 // renderer process, and the accessibility tree it sent can be |
| 216 // retrieved using GetAXTreeForTesting(). |
| 217 void SetAccessibilityCallbackForTesting( |
| 218 const base::Callback<void(ui::AXEvent, int)>& callback); |
| 219 |
| 220 // Returns a snapshot of the accessibility tree received from the |
| 221 // renderer as of the last time an accessibility notification was |
| 222 // received. |
| 223 const ui::AXTree* GetAXTreeForTesting(); |
| 224 |
| 225 // Access the BrowserAccessibilityManager if it already exists. |
| 226 BrowserAccessibilityManager* browser_accessibility_manager() const { |
| 227 return browser_accessibility_manager_.get(); |
| 228 } |
| 229 |
| 230 // If accessibility is enabled, get the BrowserAccessibilityManager for |
| 231 // this frame, or create one if it doesn't exist yet, otherwise return |
| 232 // NULL. |
| 233 BrowserAccessibilityManager* GetOrCreateBrowserAccessibilityManager(); |
| 234 |
| 235 #if defined(OS_WIN) |
| 236 void SetParentNativeViewAccessible( |
| 237 gfx::NativeViewAccessible accessible_parent); |
| 238 gfx::NativeViewAccessible GetParentNativeViewAccessible() const; |
| 239 #endif |
| 240 |
| 186 protected: | 241 protected: |
| 187 friend class RenderFrameHostFactory; | 242 friend class RenderFrameHostFactory; |
| 188 | 243 |
| 189 // TODO(nasko): Remove dependency on RenderViewHost here. RenderProcessHost | 244 // TODO(nasko): Remove dependency on RenderViewHost here. RenderProcessHost |
| 190 // should be the abstraction needed here, but we need RenderViewHost to pass | 245 // should be the abstraction needed here, but we need RenderViewHost to pass |
| 191 // into WebContentsObserver::FrameDetached for now. | 246 // into WebContentsObserver::FrameDetached for now. |
| 192 RenderFrameHostImpl(RenderViewHostImpl* render_view_host, | 247 RenderFrameHostImpl(RenderViewHostImpl* render_view_host, |
| 193 RenderFrameHostDelegate* delegate, | 248 RenderFrameHostDelegate* delegate, |
| 194 FrameTree* frame_tree, | 249 FrameTree* frame_tree, |
| 195 FrameTreeNode* frame_tree_node, | 250 FrameTreeNode* frame_tree_node, |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 246 size_t start_offset, | 301 size_t start_offset, |
| 247 size_t end_offset); | 302 size_t end_offset); |
| 248 void OnDidAccessInitialDocument(); | 303 void OnDidAccessInitialDocument(); |
| 249 void OnDidDisownOpener(); | 304 void OnDidDisownOpener(); |
| 250 void OnUpdateTitle(int32 page_id, | 305 void OnUpdateTitle(int32 page_id, |
| 251 const base::string16& title, | 306 const base::string16& title, |
| 252 blink::WebTextDirection title_direction); | 307 blink::WebTextDirection title_direction); |
| 253 void OnUpdateEncoding(const std::string& encoding); | 308 void OnUpdateEncoding(const std::string& encoding); |
| 254 void OnBeginNavigation( | 309 void OnBeginNavigation( |
| 255 const FrameHostMsg_BeginNavigation_Params& params); | 310 const FrameHostMsg_BeginNavigation_Params& params); |
| 311 void OnAccessibilityEvents( |
| 312 const std::vector<AccessibilityHostMsg_EventParams>& params); |
| 313 void OnAccessibilityLocationChanges( |
| 314 const std::vector<AccessibilityHostMsg_LocationChangeParams>& params); |
| 256 | 315 |
| 257 // Returns whether the given URL is allowed to commit in the current process. | 316 // Returns whether the given URL is allowed to commit in the current process. |
| 258 // This is a more conservative check than RenderProcessHost::FilterURL, since | 317 // This is a more conservative check than RenderProcessHost::FilterURL, since |
| 259 // it will be used to kill processes that commit unauthorized URLs. | 318 // it will be used to kill processes that commit unauthorized URLs. |
| 260 bool CanCommitURL(const GURL& url); | 319 bool CanCommitURL(const GURL& url); |
| 261 | 320 |
| 262 void DesktopNotificationPermissionRequestDone(int callback_context); | 321 void DesktopNotificationPermissionRequestDone(int callback_context); |
| 263 | 322 |
| 264 // For now, RenderFrameHosts indirectly keep RenderViewHosts alive via a | 323 // For now, RenderFrameHosts indirectly keep RenderViewHosts alive via a |
| 265 // refcount that calls Shutdown when it reaches zero. This allows each | 324 // refcount that calls Shutdown when it reaches zero. This allows each |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 307 int routing_id_; | 366 int routing_id_; |
| 308 bool is_swapped_out_; | 367 bool is_swapped_out_; |
| 309 | 368 |
| 310 // When the last BeforeUnload message was sent. | 369 // When the last BeforeUnload message was sent. |
| 311 base::TimeTicks send_before_unload_start_time_; | 370 base::TimeTicks send_before_unload_start_time_; |
| 312 | 371 |
| 313 ServiceRegistryImpl service_registry_; | 372 ServiceRegistryImpl service_registry_; |
| 314 | 373 |
| 315 base::WeakPtrFactory<RenderFrameHostImpl> weak_ptr_factory_; | 374 base::WeakPtrFactory<RenderFrameHostImpl> weak_ptr_factory_; |
| 316 | 375 |
| 376 scoped_ptr<BrowserAccessibilityManager> browser_accessibility_manager_; |
| 377 |
| 378 // Callback when an event is received, for testing. |
| 379 base::Callback<void(ui::AXEvent, int)> accessibility_testing_callback_; |
| 380 // The most recently received accessibility tree - for testing only. |
| 381 scoped_ptr<ui::AXTree> ax_tree_for_testing_; |
| 382 |
| 317 DISALLOW_COPY_AND_ASSIGN(RenderFrameHostImpl); | 383 DISALLOW_COPY_AND_ASSIGN(RenderFrameHostImpl); |
| 318 }; | 384 }; |
| 319 | 385 |
| 320 } // namespace content | 386 } // namespace content |
| 321 | 387 |
| 322 #endif // CONTENT_BROWSER_FRAME_HOST_RENDER_FRAME_HOST_IMPL_H_ | 388 #endif // CONTENT_BROWSER_FRAME_HOST_RENDER_FRAME_HOST_IMPL_H_ |
| OLD | NEW |