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 RenderFrameProxyHost; | 44 class RenderFrameProxyHost; |
40 class RenderProcessHost; | 45 class RenderProcessHost; |
41 class RenderViewHostImpl; | 46 class RenderViewHostImpl; |
42 struct ContextMenuParams; | 47 struct ContextMenuParams; |
43 struct GlobalRequestID; | 48 struct GlobalRequestID; |
44 struct Referrer; | 49 struct Referrer; |
45 struct ShowDesktopNotificationHostMsgParams; | 50 struct ShowDesktopNotificationHostMsgParams; |
46 | 51 |
47 class CONTENT_EXPORT RenderFrameHostImpl : public RenderFrameHost { | 52 class CONTENT_EXPORT RenderFrameHostImpl |
| 53 : public RenderFrameHost, |
| 54 public BrowserAccessibilityDelegate { |
48 public: | 55 public: |
49 static RenderFrameHostImpl* FromID(int process_id, int routing_id); | 56 static RenderFrameHostImpl* FromID(int process_id, int routing_id); |
50 | 57 |
51 virtual ~RenderFrameHostImpl(); | 58 virtual ~RenderFrameHostImpl(); |
52 | 59 |
53 // RenderFrameHost | 60 // RenderFrameHost |
54 virtual int GetRoutingID() OVERRIDE; | 61 virtual int GetRoutingID() OVERRIDE; |
55 virtual SiteInstance* GetSiteInstance() OVERRIDE; | 62 virtual SiteInstance* GetSiteInstance() OVERRIDE; |
56 virtual RenderProcessHost* GetProcess() OVERRIDE; | 63 virtual RenderProcessHost* GetProcess() OVERRIDE; |
57 virtual RenderFrameHost* GetParent() OVERRIDE; | 64 virtual RenderFrameHost* GetParent() OVERRIDE; |
58 virtual const std::string& GetFrameName() OVERRIDE; | 65 virtual const std::string& GetFrameName() OVERRIDE; |
59 virtual bool IsCrossProcessSubframe() OVERRIDE; | 66 virtual bool IsCrossProcessSubframe() OVERRIDE; |
60 virtual GURL GetLastCommittedURL() OVERRIDE; | 67 virtual GURL GetLastCommittedURL() OVERRIDE; |
61 virtual gfx::NativeView GetNativeView() OVERRIDE; | 68 virtual gfx::NativeView GetNativeView() OVERRIDE; |
62 virtual void ExecuteJavaScript( | 69 virtual void ExecuteJavaScript( |
63 const base::string16& javascript) OVERRIDE; | 70 const base::string16& javascript) OVERRIDE; |
64 virtual void ExecuteJavaScript( | 71 virtual void ExecuteJavaScript( |
65 const base::string16& javascript, | 72 const base::string16& javascript, |
66 const JavaScriptResultCallback& callback) OVERRIDE; | 73 const JavaScriptResultCallback& callback) OVERRIDE; |
67 virtual RenderViewHost* GetRenderViewHost() OVERRIDE; | 74 virtual RenderViewHost* GetRenderViewHost() OVERRIDE; |
68 | 75 |
69 // IPC::Sender | 76 // IPC::Sender |
70 virtual bool Send(IPC::Message* msg) OVERRIDE; | 77 virtual bool Send(IPC::Message* msg) OVERRIDE; |
71 | 78 |
72 // IPC::Listener | 79 // IPC::Listener |
73 virtual bool OnMessageReceived(const IPC::Message& msg) OVERRIDE; | 80 virtual bool OnMessageReceived(const IPC::Message& msg) OVERRIDE; |
74 | 81 |
| 82 // BrowserAccessibilityDelegate |
| 83 virtual void AccessibilitySetFocus(int acc_obj_id) OVERRIDE; |
| 84 virtual void AccessibilityDoDefaultAction(int acc_obj_id) OVERRIDE; |
| 85 virtual void AccessibilityShowMenu(const gfx::Point& point) OVERRIDE; |
| 86 virtual void AccessibilityScrollToMakeVisible( |
| 87 int acc_obj_id, gfx::Rect subfocus) OVERRIDE; |
| 88 virtual void AccessibilityScrollToPoint( |
| 89 int acc_obj_id, gfx::Point point) OVERRIDE; |
| 90 virtual void AccessibilitySetTextSelection( |
| 91 int acc_obj_id, int start_offset, int end_offset) OVERRIDE; |
| 92 virtual bool AccessibilityViewHasFocus() const OVERRIDE; |
| 93 virtual gfx::Rect AccessibilityGetViewBounds() const OVERRIDE; |
| 94 virtual gfx::Point AccessibilityOriginInScreen(const gfx::Rect& bounds) |
| 95 const OVERRIDE; |
| 96 virtual void AccessibilityHitTest(const gfx::Point& point) OVERRIDE; |
| 97 virtual void AccessibilityFatalError() OVERRIDE; |
| 98 |
75 void Init(); | 99 void Init(); |
76 int routing_id() const { return routing_id_; } | 100 int routing_id() const { return routing_id_; } |
77 void OnCreateChildFrame(int new_routing_id, | 101 void OnCreateChildFrame(int new_routing_id, |
78 const std::string& frame_name); | 102 const std::string& frame_name); |
79 | 103 |
80 RenderViewHostImpl* render_view_host() { return render_view_host_; } | 104 RenderViewHostImpl* render_view_host() { return render_view_host_; } |
81 RenderFrameHostDelegate* delegate() { return delegate_; } | 105 RenderFrameHostDelegate* delegate() { return delegate_; } |
82 FrameTreeNode* frame_tree_node() { return frame_tree_node_; } | 106 FrameTreeNode* frame_tree_node() { return frame_tree_node_; } |
83 | 107 |
84 // This function is called when this is a swapped out RenderFrameHost that | 108 // This function is called when this is a swapped out RenderFrameHost that |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
156 // Notifies the RenderFrame that the JavaScript message that was shown was | 180 // Notifies the RenderFrame that the JavaScript message that was shown was |
157 // closed by the user. | 181 // closed by the user. |
158 void JavaScriptDialogClosed(IPC::Message* reply_msg, | 182 void JavaScriptDialogClosed(IPC::Message* reply_msg, |
159 bool success, | 183 bool success, |
160 const base::string16& user_input, | 184 const base::string16& user_input, |
161 bool dialog_was_suppressed); | 185 bool dialog_was_suppressed); |
162 | 186 |
163 // Called when an HTML5 notification is closed. | 187 // Called when an HTML5 notification is closed. |
164 void NotificationClosed(int notification_id); | 188 void NotificationClosed(int notification_id); |
165 | 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 BrowserAccessibilityManager* browser_accessibility_manager() const { |
| 211 return browser_accessibility_manager_.get(); |
| 212 } |
| 213 |
| 214 #if defined(OS_WIN) |
| 215 void SetParentNativeViewAccessible( |
| 216 gfx::NativeViewAccessible accessible_parent); |
| 217 gfx::NativeViewAccessible GetParentNativeViewAccessible() const; |
| 218 #endif |
| 219 |
166 protected: | 220 protected: |
167 friend class RenderFrameHostFactory; | 221 friend class RenderFrameHostFactory; |
168 | 222 |
169 // TODO(nasko): Remove dependency on RenderViewHost here. RenderProcessHost | 223 // TODO(nasko): Remove dependency on RenderViewHost here. RenderProcessHost |
170 // should be the abstraction needed here, but we need RenderViewHost to pass | 224 // should be the abstraction needed here, but we need RenderViewHost to pass |
171 // into WebContentsObserver::FrameDetached for now. | 225 // into WebContentsObserver::FrameDetached for now. |
172 RenderFrameHostImpl(RenderViewHostImpl* render_view_host, | 226 RenderFrameHostImpl(RenderViewHostImpl* render_view_host, |
173 RenderFrameHostDelegate* delegate, | 227 RenderFrameHostDelegate* delegate, |
174 FrameTree* frame_tree, | 228 FrameTree* frame_tree, |
175 FrameTreeNode* frame_tree_node, | 229 FrameTreeNode* frame_tree_node, |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
222 void OnShowDesktopNotification( | 276 void OnShowDesktopNotification( |
223 int notification_id, | 277 int notification_id, |
224 const ShowDesktopNotificationHostMsgParams& params); | 278 const ShowDesktopNotificationHostMsgParams& params); |
225 void OnCancelDesktopNotification(int notification_id); | 279 void OnCancelDesktopNotification(int notification_id); |
226 void OnDidAccessInitialDocument(); | 280 void OnDidAccessInitialDocument(); |
227 void OnDidDisownOpener(); | 281 void OnDidDisownOpener(); |
228 void OnUpdateTitle(int32 page_id, | 282 void OnUpdateTitle(int32 page_id, |
229 const base::string16& title, | 283 const base::string16& title, |
230 blink::WebTextDirection title_direction); | 284 blink::WebTextDirection title_direction); |
231 void OnUpdateEncoding(const std::string& encoding); | 285 void OnUpdateEncoding(const std::string& encoding); |
| 286 void OnAccessibilityEvents( |
| 287 const std::vector<AccessibilityHostMsg_EventParams>& params); |
| 288 void OnAccessibilityLocationChanges( |
| 289 const std::vector<AccessibilityHostMsg_LocationChangeParams>& params); |
232 | 290 |
233 // Returns whether the given URL is allowed to commit in the current process. | 291 // Returns whether the given URL is allowed to commit in the current process. |
234 // This is a more conservative check than RenderProcessHost::FilterURL, since | 292 // This is a more conservative check than RenderProcessHost::FilterURL, since |
235 // it will be used to kill processes that commit unauthorized URLs. | 293 // it will be used to kill processes that commit unauthorized URLs. |
236 bool CanCommitURL(const GURL& url); | 294 bool CanCommitURL(const GURL& url); |
237 | 295 |
238 void DesktopNotificationPermissionRequestDone(int callback_context); | 296 void DesktopNotificationPermissionRequestDone(int callback_context); |
239 | 297 |
240 // For now, RenderFrameHosts indirectly keep RenderViewHosts alive via a | 298 // For now, RenderFrameHosts indirectly keep RenderViewHosts alive via a |
241 // refcount that calls Shutdown when it reaches zero. This allows each | 299 // refcount that calls Shutdown when it reaches zero. This allows each |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
281 std::map<int, base::Closure> cancel_notification_callbacks_; | 339 std::map<int, base::Closure> cancel_notification_callbacks_; |
282 | 340 |
283 int routing_id_; | 341 int routing_id_; |
284 bool is_swapped_out_; | 342 bool is_swapped_out_; |
285 | 343 |
286 // When the last BeforeUnload message was sent. | 344 // When the last BeforeUnload message was sent. |
287 base::TimeTicks send_before_unload_start_time_; | 345 base::TimeTicks send_before_unload_start_time_; |
288 | 346 |
289 base::WeakPtrFactory<RenderFrameHostImpl> weak_ptr_factory_; | 347 base::WeakPtrFactory<RenderFrameHostImpl> weak_ptr_factory_; |
290 | 348 |
| 349 AccessibilityMode accessibility_mode_; |
| 350 base::Callback<void(ui::AXEvent)> accessibility_testing_callback_; |
| 351 // The most recently received accessibility tree - for testing only. |
| 352 scoped_ptr<ui::AXTree> ax_tree_for_testing_; |
| 353 scoped_ptr<BrowserAccessibilityManager> browser_accessibility_manager_; |
| 354 |
291 DISALLOW_COPY_AND_ASSIGN(RenderFrameHostImpl); | 355 DISALLOW_COPY_AND_ASSIGN(RenderFrameHostImpl); |
292 }; | 356 }; |
293 | 357 |
294 } // namespace content | 358 } // namespace content |
295 | 359 |
296 #endif // CONTENT_BROWSER_FRAME_HOST_RENDER_FRAME_HOST_IMPL_H_ | 360 #endif // CONTENT_BROWSER_FRAME_HOST_RENDER_FRAME_HOST_IMPL_H_ |
OLD | NEW |