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 AccessibilityFatalError() OVERRIDE; |
| 97 |
75 void Init(); | 98 void Init(); |
76 int routing_id() const { return routing_id_; } | 99 int routing_id() const { return routing_id_; } |
77 void OnCreateChildFrame(int new_routing_id, | 100 void OnCreateChildFrame(int new_routing_id, |
78 const std::string& frame_name); | 101 const std::string& frame_name); |
79 | 102 |
80 RenderViewHostImpl* render_view_host() { return render_view_host_; } | 103 RenderViewHostImpl* render_view_host() { return render_view_host_; } |
81 RenderFrameHostDelegate* delegate() { return delegate_; } | 104 RenderFrameHostDelegate* delegate() { return delegate_; } |
82 FrameTreeNode* frame_tree_node() { return frame_tree_node_; } | 105 FrameTreeNode* frame_tree_node() { return frame_tree_node_; } |
83 | 106 |
84 // This function is called when this is a swapped out RenderFrameHost that | 107 // This function is called when this is a swapped out RenderFrameHost that |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
162 // Notifies the RenderFrame that the JavaScript message that was shown was | 185 // Notifies the RenderFrame that the JavaScript message that was shown was |
163 // closed by the user. | 186 // closed by the user. |
164 void JavaScriptDialogClosed(IPC::Message* reply_msg, | 187 void JavaScriptDialogClosed(IPC::Message* reply_msg, |
165 bool success, | 188 bool success, |
166 const base::string16& user_input, | 189 const base::string16& user_input, |
167 bool dialog_was_suppressed); | 190 bool dialog_was_suppressed); |
168 | 191 |
169 // Called when an HTML5 notification is closed. | 192 // Called when an HTML5 notification is closed. |
170 void NotificationClosed(int notification_id); | 193 void NotificationClosed(int notification_id); |
171 | 194 |
| 195 // Gets the accessibility mode. |
| 196 AccessibilityMode accessibility_mode() const { |
| 197 return accessibility_mode_; |
| 198 } |
| 199 |
| 200 // Send a message to the renderer process to change the accessibility mode. |
| 201 void SetAccessibilityMode(AccessibilityMode AccessibilityMode); |
| 202 |
| 203 // Turn on accessibility testing. The given callback will be run |
| 204 // every time an accessibility notification is received from the |
| 205 // renderer process, and the accessibility tree it sent can be |
| 206 // retrieved using GetAXTreeForTesting(). |
| 207 void SetAccessibilityCallbackForTesting( |
| 208 const base::Callback<void(ui::AXEvent)>& callback); |
| 209 |
| 210 // Returns a snapshot of the accessibility tree received from the |
| 211 // renderer as of the last time an accessibility notification was |
| 212 // received. |
| 213 const ui::AXTree* GetAXTreeForTesting(); |
| 214 |
| 215 BrowserAccessibilityManager* browser_accessibility_manager() const { |
| 216 return browser_accessibility_manager_.get(); |
| 217 } |
| 218 |
| 219 #if defined(OS_WIN) |
| 220 void SetParentNativeViewAccessible( |
| 221 gfx::NativeViewAccessible accessible_parent); |
| 222 gfx::NativeViewAccessible GetParentNativeViewAccessible() const; |
| 223 #endif |
| 224 |
172 protected: | 225 protected: |
173 friend class RenderFrameHostFactory; | 226 friend class RenderFrameHostFactory; |
174 | 227 |
175 // TODO(nasko): Remove dependency on RenderViewHost here. RenderProcessHost | 228 // TODO(nasko): Remove dependency on RenderViewHost here. RenderProcessHost |
176 // should be the abstraction needed here, but we need RenderViewHost to pass | 229 // should be the abstraction needed here, but we need RenderViewHost to pass |
177 // into WebContentsObserver::FrameDetached for now. | 230 // into WebContentsObserver::FrameDetached for now. |
178 RenderFrameHostImpl(RenderViewHostImpl* render_view_host, | 231 RenderFrameHostImpl(RenderViewHostImpl* render_view_host, |
179 RenderFrameHostDelegate* delegate, | 232 RenderFrameHostDelegate* delegate, |
180 FrameTree* frame_tree, | 233 FrameTree* frame_tree, |
181 FrameTreeNode* frame_tree_node, | 234 FrameTreeNode* frame_tree_node, |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
229 void OnShowDesktopNotification( | 282 void OnShowDesktopNotification( |
230 int notification_id, | 283 int notification_id, |
231 const ShowDesktopNotificationHostMsgParams& params); | 284 const ShowDesktopNotificationHostMsgParams& params); |
232 void OnCancelDesktopNotification(int notification_id); | 285 void OnCancelDesktopNotification(int notification_id); |
233 void OnDidAccessInitialDocument(); | 286 void OnDidAccessInitialDocument(); |
234 void OnDidDisownOpener(); | 287 void OnDidDisownOpener(); |
235 void OnUpdateTitle(int32 page_id, | 288 void OnUpdateTitle(int32 page_id, |
236 const base::string16& title, | 289 const base::string16& title, |
237 blink::WebTextDirection title_direction); | 290 blink::WebTextDirection title_direction); |
238 void OnUpdateEncoding(const std::string& encoding); | 291 void OnUpdateEncoding(const std::string& encoding); |
| 292 void OnAccessibilityEvents( |
| 293 const std::vector<AccessibilityHostMsg_EventParams>& params); |
| 294 void OnAccessibilityLocationChanges( |
| 295 const std::vector<AccessibilityHostMsg_LocationChangeParams>& params); |
239 | 296 |
240 // Returns whether the given URL is allowed to commit in the current process. | 297 // Returns whether the given URL is allowed to commit in the current process. |
241 // This is a more conservative check than RenderProcessHost::FilterURL, since | 298 // This is a more conservative check than RenderProcessHost::FilterURL, since |
242 // it will be used to kill processes that commit unauthorized URLs. | 299 // it will be used to kill processes that commit unauthorized URLs. |
243 bool CanCommitURL(const GURL& url); | 300 bool CanCommitURL(const GURL& url); |
244 | 301 |
245 void DesktopNotificationPermissionRequestDone(int callback_context); | 302 void DesktopNotificationPermissionRequestDone(int callback_context); |
246 | 303 |
247 // For now, RenderFrameHosts indirectly keep RenderViewHosts alive via a | 304 // For now, RenderFrameHosts indirectly keep RenderViewHosts alive via a |
248 // refcount that calls Shutdown when it reaches zero. This allows each | 305 // refcount that calls Shutdown when it reaches zero. This allows each |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
288 std::map<int, base::Closure> cancel_notification_callbacks_; | 345 std::map<int, base::Closure> cancel_notification_callbacks_; |
289 | 346 |
290 int routing_id_; | 347 int routing_id_; |
291 bool is_swapped_out_; | 348 bool is_swapped_out_; |
292 | 349 |
293 // When the last BeforeUnload message was sent. | 350 // When the last BeforeUnload message was sent. |
294 base::TimeTicks send_before_unload_start_time_; | 351 base::TimeTicks send_before_unload_start_time_; |
295 | 352 |
296 base::WeakPtrFactory<RenderFrameHostImpl> weak_ptr_factory_; | 353 base::WeakPtrFactory<RenderFrameHostImpl> weak_ptr_factory_; |
297 | 354 |
| 355 AccessibilityMode accessibility_mode_; |
| 356 base::Callback<void(ui::AXEvent)> accessibility_testing_callback_; |
| 357 // The most recently received accessibility tree - for testing only. |
| 358 scoped_ptr<ui::AXTree> ax_tree_for_testing_; |
| 359 scoped_ptr<BrowserAccessibilityManager> browser_accessibility_manager_; |
| 360 |
298 DISALLOW_COPY_AND_ASSIGN(RenderFrameHostImpl); | 361 DISALLOW_COPY_AND_ASSIGN(RenderFrameHostImpl); |
299 }; | 362 }; |
300 | 363 |
301 } // namespace content | 364 } // namespace content |
302 | 365 |
303 #endif // CONTENT_BROWSER_FRAME_HOST_RENDER_FRAME_HOST_IMPL_H_ | 366 #endif // CONTENT_BROWSER_FRAME_HOST_RENDER_FRAME_HOST_IMPL_H_ |
OLD | NEW |