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/public/browser/render_frame_host.h" | 19 #include "content/public/browser/render_frame_host.h" |
18 #include "content/public/common/javascript_message_type.h" | 20 #include "content/public/common/javascript_message_type.h" |
19 #include "content/public/common/page_transition_types.h" | 21 #include "content/public/common/page_transition_types.h" |
20 #include "third_party/WebKit/public/web/WebTextDirection.h" | 22 #include "third_party/WebKit/public/web/WebTextDirection.h" |
| 23 #include "ui/accessibility/ax_node_data.h" |
21 | 24 |
22 class GURL; | 25 class GURL; |
| 26 struct AccessibilityHostMsg_EventParams; |
| 27 struct AccessibilityHostMsg_LocationChangeParams; |
23 struct FrameHostMsg_DidFailProvisionalLoadWithError_Params; | 28 struct FrameHostMsg_DidFailProvisionalLoadWithError_Params; |
24 struct FrameHostMsg_OpenURL_Params; | 29 struct FrameHostMsg_OpenURL_Params; |
25 struct FrameMsg_Navigate_Params; | 30 struct FrameMsg_Navigate_Params; |
26 | 31 |
27 namespace base { | 32 namespace base { |
28 class FilePath; | 33 class FilePath; |
29 class ListValue; | 34 class ListValue; |
30 } | 35 } |
31 | 36 |
32 namespace content { | 37 namespace content { |
33 | 38 |
34 class CrossProcessFrameConnector; | 39 class CrossProcessFrameConnector; |
35 class CrossSiteTransferringRequest; | 40 class CrossSiteTransferringRequest; |
36 class FrameTree; | 41 class FrameTree; |
37 class FrameTreeNode; | 42 class FrameTreeNode; |
38 class RenderFrameHostDelegate; | 43 class RenderFrameHostDelegate; |
39 class RenderProcessHost; | 44 class RenderProcessHost; |
40 class RenderViewHostImpl; | 45 class RenderViewHostImpl; |
41 struct ContextMenuParams; | 46 struct ContextMenuParams; |
42 struct GlobalRequestID; | 47 struct GlobalRequestID; |
43 struct Referrer; | 48 struct Referrer; |
44 struct ShowDesktopNotificationHostMsgParams; | 49 struct ShowDesktopNotificationHostMsgParams; |
45 | 50 |
46 class CONTENT_EXPORT RenderFrameHostImpl : public RenderFrameHost { | 51 class CONTENT_EXPORT RenderFrameHostImpl |
| 52 : public RenderFrameHost, |
| 53 public BrowserAccessibilityDelegate { |
47 public: | 54 public: |
48 static RenderFrameHostImpl* FromID(int process_id, int routing_id); | 55 static RenderFrameHostImpl* FromID(int process_id, int routing_id); |
49 | 56 |
50 virtual ~RenderFrameHostImpl(); | 57 virtual ~RenderFrameHostImpl(); |
51 | 58 |
52 // RenderFrameHost | 59 // RenderFrameHost |
53 virtual int GetRoutingID() OVERRIDE; | 60 virtual int GetRoutingID() OVERRIDE; |
54 virtual SiteInstance* GetSiteInstance() OVERRIDE; | 61 virtual SiteInstance* GetSiteInstance() OVERRIDE; |
55 virtual RenderProcessHost* GetProcess() OVERRIDE; | 62 virtual RenderProcessHost* GetProcess() OVERRIDE; |
56 virtual RenderFrameHost* GetParent() OVERRIDE; | 63 virtual RenderFrameHost* GetParent() OVERRIDE; |
57 virtual const std::string& GetFrameName() OVERRIDE; | 64 virtual const std::string& GetFrameName() OVERRIDE; |
58 virtual bool IsCrossProcessSubframe() OVERRIDE; | 65 virtual bool IsCrossProcessSubframe() OVERRIDE; |
59 virtual GURL GetLastCommittedURL() OVERRIDE; | 66 virtual GURL GetLastCommittedURL() OVERRIDE; |
60 virtual gfx::NativeView GetNativeView() OVERRIDE; | 67 virtual gfx::NativeView GetNativeView() OVERRIDE; |
61 virtual void ExecuteJavaScript( | 68 virtual void ExecuteJavaScript( |
62 const base::string16& javascript) OVERRIDE; | 69 const base::string16& javascript) OVERRIDE; |
63 virtual void ExecuteJavaScript( | 70 virtual void ExecuteJavaScript( |
64 const base::string16& javascript, | 71 const base::string16& javascript, |
65 const JavaScriptResultCallback& callback) OVERRIDE; | 72 const JavaScriptResultCallback& callback) OVERRIDE; |
66 virtual RenderViewHost* GetRenderViewHost() OVERRIDE; | 73 virtual RenderViewHost* GetRenderViewHost() OVERRIDE; |
67 | 74 |
68 // IPC::Sender | 75 // IPC::Sender |
69 virtual bool Send(IPC::Message* msg) OVERRIDE; | 76 virtual bool Send(IPC::Message* msg) OVERRIDE; |
70 | 77 |
71 // IPC::Listener | 78 // IPC::Listener |
72 virtual bool OnMessageReceived(const IPC::Message& msg) OVERRIDE; | 79 virtual bool OnMessageReceived(const IPC::Message& msg) OVERRIDE; |
73 | 80 |
| 81 // BrowserAccessibilityDelegate |
| 82 virtual void AccessibilitySetFocus(int acc_obj_id) OVERRIDE; |
| 83 virtual void AccessibilityDoDefaultAction(int acc_obj_id) OVERRIDE; |
| 84 virtual void AccessibilityShowMenu(int acc_obj_id) OVERRIDE; |
| 85 virtual void AccessibilityScrollToMakeVisible( |
| 86 int acc_obj_id, gfx::Rect subfocus) OVERRIDE; |
| 87 virtual void AccessibilityScrollToPoint( |
| 88 int acc_obj_id, gfx::Point point) OVERRIDE; |
| 89 virtual void AccessibilitySetTextSelection( |
| 90 int acc_obj_id, int start_offset, int end_offset) OVERRIDE; |
| 91 virtual bool AccessibilityViewHasFocus() const OVERRIDE; |
| 92 virtual gfx::Rect AccessibilityGetViewBounds() const OVERRIDE; |
| 93 virtual gfx::Point AccessibilityOriginInScreen(const gfx::Rect& bounds) |
| 94 const OVERRIDE; |
| 95 virtual void AccessibilityFatalError() OVERRIDE; |
| 96 |
74 void Init(); | 97 void Init(); |
75 int routing_id() const { return routing_id_; } | 98 int routing_id() const { return routing_id_; } |
76 void OnCreateChildFrame(int new_routing_id, | 99 void OnCreateChildFrame(int new_routing_id, |
77 const std::string& frame_name); | 100 const std::string& frame_name); |
78 | 101 |
79 RenderViewHostImpl* render_view_host() { return render_view_host_; } | 102 RenderViewHostImpl* render_view_host() { return render_view_host_; } |
80 RenderFrameHostDelegate* delegate() { return delegate_; } | 103 RenderFrameHostDelegate* delegate() { return delegate_; } |
81 FrameTreeNode* frame_tree_node() { return frame_tree_node_; } | 104 FrameTreeNode* frame_tree_node() { return frame_tree_node_; } |
82 | 105 |
83 // This function is called when this is a swapped out RenderFrameHost that | 106 // This function is called when this is a swapped out RenderFrameHost that |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
157 // Notifies the RenderFrame that the JavaScript message that was shown was | 180 // Notifies the RenderFrame that the JavaScript message that was shown was |
158 // closed by the user. | 181 // closed by the user. |
159 void JavaScriptDialogClosed(IPC::Message* reply_msg, | 182 void JavaScriptDialogClosed(IPC::Message* reply_msg, |
160 bool success, | 183 bool success, |
161 const base::string16& user_input, | 184 const base::string16& user_input, |
162 bool dialog_was_suppressed); | 185 bool dialog_was_suppressed); |
163 | 186 |
164 // Called when an HTML5 notification is closed. | 187 // Called when an HTML5 notification is closed. |
165 void NotificationClosed(int notification_id); | 188 void NotificationClosed(int notification_id); |
166 | 189 |
| 190 // Gets the accessibility mode. |
| 191 AccessibilityMode accessibility_mode() const { |
| 192 return accessibility_mode_; |
| 193 } |
| 194 |
| 195 // Send a message to the renderer process to change the accessibility mode. |
| 196 void SetAccessibilityMode(AccessibilityMode AccessibilityMode); |
| 197 |
| 198 // Turn on accessibility testing. The given callback will be run |
| 199 // every time an accessibility notification is received from the |
| 200 // renderer process, and the accessibility tree it sent can be |
| 201 // retrieved using GetAXTreeForTesting(). |
| 202 void SetAccessibilityCallbackForTesting( |
| 203 const base::Callback<void(ui::AXEvent)>& callback); |
| 204 |
| 205 // Returns a snapshot of the accessibility tree received from the |
| 206 // renderer as of the last time an accessibility notification was |
| 207 // received. |
| 208 const ui::AXTree* GetAXTreeForTesting(); |
| 209 |
| 210 #if defined(OS_WIN) |
| 211 void SetParentNativeViewAccessible( |
| 212 gfx::NativeViewAccessible accessible_parent); |
| 213 gfx::NativeViewAccessible GetParentNativeViewAccessible() const; |
| 214 #endif |
| 215 |
167 protected: | 216 protected: |
168 friend class RenderFrameHostFactory; | 217 friend class RenderFrameHostFactory; |
169 | 218 |
170 // TODO(nasko): Remove dependency on RenderViewHost here. RenderProcessHost | 219 // TODO(nasko): Remove dependency on RenderViewHost here. RenderProcessHost |
171 // should be the abstraction needed here, but we need RenderViewHost to pass | 220 // should be the abstraction needed here, but we need RenderViewHost to pass |
172 // into WebContentsObserver::FrameDetached for now. | 221 // into WebContentsObserver::FrameDetached for now. |
173 RenderFrameHostImpl(RenderViewHostImpl* render_view_host, | 222 RenderFrameHostImpl(RenderViewHostImpl* render_view_host, |
174 RenderFrameHostDelegate* delegate, | 223 RenderFrameHostDelegate* delegate, |
175 FrameTree* frame_tree, | 224 FrameTree* frame_tree, |
176 FrameTreeNode* frame_tree_node, | 225 FrameTreeNode* frame_tree_node, |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
224 void OnShowDesktopNotification( | 273 void OnShowDesktopNotification( |
225 int notification_id, | 274 int notification_id, |
226 const ShowDesktopNotificationHostMsgParams& params); | 275 const ShowDesktopNotificationHostMsgParams& params); |
227 void OnCancelDesktopNotification(int notification_id); | 276 void OnCancelDesktopNotification(int notification_id); |
228 void OnDidAccessInitialDocument(); | 277 void OnDidAccessInitialDocument(); |
229 void OnDidDisownOpener(); | 278 void OnDidDisownOpener(); |
230 void OnUpdateTitle(int32 page_id, | 279 void OnUpdateTitle(int32 page_id, |
231 const base::string16& title, | 280 const base::string16& title, |
232 blink::WebTextDirection title_direction); | 281 blink::WebTextDirection title_direction); |
233 void OnUpdateEncoding(const std::string& encoding); | 282 void OnUpdateEncoding(const std::string& encoding); |
| 283 void OnAccessibilityEvents( |
| 284 const std::vector<AccessibilityHostMsg_EventParams>& params); |
| 285 void OnAccessibilityLocationChanges( |
| 286 const std::vector<AccessibilityHostMsg_LocationChangeParams>& params); |
234 | 287 |
235 // Returns whether the given URL is allowed to commit in the current process. | 288 // Returns whether the given URL is allowed to commit in the current process. |
236 // This is a more conservative check than RenderProcessHost::FilterURL, since | 289 // This is a more conservative check than RenderProcessHost::FilterURL, since |
237 // it will be used to kill processes that commit unauthorized URLs. | 290 // it will be used to kill processes that commit unauthorized URLs. |
238 bool CanCommitURL(const GURL& url); | 291 bool CanCommitURL(const GURL& url); |
239 | 292 |
240 void DesktopNotificationPermissionRequestDone(int callback_context); | 293 void DesktopNotificationPermissionRequestDone(int callback_context); |
241 | 294 |
242 // For now, RenderFrameHosts indirectly keep RenderViewHosts alive via a | 295 // For now, RenderFrameHosts indirectly keep RenderViewHosts alive via a |
243 // refcount that calls Shutdown when it reaches zero. This allows each | 296 // refcount that calls Shutdown when it reaches zero. This allows each |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
277 std::map<int, base::Closure> cancel_notification_callbacks_; | 330 std::map<int, base::Closure> cancel_notification_callbacks_; |
278 | 331 |
279 int routing_id_; | 332 int routing_id_; |
280 bool is_swapped_out_; | 333 bool is_swapped_out_; |
281 | 334 |
282 // When the last BeforeUnload message was sent. | 335 // When the last BeforeUnload message was sent. |
283 base::TimeTicks send_before_unload_start_time_; | 336 base::TimeTicks send_before_unload_start_time_; |
284 | 337 |
285 base::WeakPtrFactory<RenderFrameHostImpl> weak_ptr_factory_; | 338 base::WeakPtrFactory<RenderFrameHostImpl> weak_ptr_factory_; |
286 | 339 |
| 340 AccessibilityMode accessibility_mode_; |
| 341 base::Callback<void(ui::AXEvent)> accessibility_testing_callback_; |
| 342 // The most recently received accessibility tree - for testing only. |
| 343 scoped_ptr<ui::AXTree> ax_tree_for_testing_; |
| 344 |
287 DISALLOW_COPY_AND_ASSIGN(RenderFrameHostImpl); | 345 DISALLOW_COPY_AND_ASSIGN(RenderFrameHostImpl); |
288 }; | 346 }; |
289 | 347 |
290 } // namespace content | 348 } // namespace content |
291 | 349 |
292 #endif // CONTENT_BROWSER_FRAME_HOST_RENDER_FRAME_HOST_IMPL_H_ | 350 #endif // CONTENT_BROWSER_FRAME_HOST_RENDER_FRAME_HOST_IMPL_H_ |
OLD | NEW |