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