Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(363)

Side by Side Diff: content/browser/frame_host/render_frame_host_impl.h

Issue 273423004: Migrate accessibility from RenderView to RenderFrame. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 FrameMsg_Navigate_Params; 31 struct FrameMsg_Navigate_Params;
27 32
28 namespace base { 33 namespace base {
29 class FilePath; 34 class FilePath;
30 class ListValue; 35 class ListValue;
31 } 36 }
32 37
33 namespace content { 38 namespace content {
34 39
35 class CrossProcessFrameConnector; 40 class CrossProcessFrameConnector;
36 class CrossSiteTransferringRequest; 41 class CrossSiteTransferringRequest;
37 class FrameTree; 42 class FrameTree;
38 class FrameTreeNode; 43 class FrameTreeNode;
39 class RenderFrameHostDelegate; 44 class RenderFrameHostDelegate;
40 class RenderFrameProxyHost; 45 class RenderFrameProxyHost;
41 class RenderProcessHost; 46 class RenderProcessHost;
42 class RenderViewHostImpl; 47 class RenderViewHostImpl;
43 class RenderWidgetHostImpl; 48 class RenderWidgetHostImpl;
44 struct ContextMenuParams; 49 struct ContextMenuParams;
45 struct GlobalRequestID; 50 struct GlobalRequestID;
46 struct Referrer; 51 struct Referrer;
47 struct ShowDesktopNotificationHostMsgParams; 52 struct ShowDesktopNotificationHostMsgParams;
48 53
49 class CONTENT_EXPORT RenderFrameHostImpl : public RenderFrameHost { 54 class CONTENT_EXPORT RenderFrameHostImpl
55 : public RenderFrameHost,
56 public BrowserAccessibilityDelegate {
50 public: 57 public:
51 static RenderFrameHostImpl* FromID(int process_id, int routing_id); 58 static RenderFrameHostImpl* FromID(int process_id, int routing_id);
52 59
53 virtual ~RenderFrameHostImpl(); 60 virtual ~RenderFrameHostImpl();
54 61
55 // RenderFrameHost 62 // RenderFrameHost
56 virtual int GetRoutingID() OVERRIDE; 63 virtual int GetRoutingID() OVERRIDE;
57 virtual SiteInstance* GetSiteInstance() OVERRIDE; 64 virtual SiteInstance* GetSiteInstance() OVERRIDE;
58 virtual RenderProcessHost* GetProcess() OVERRIDE; 65 virtual RenderProcessHost* GetProcess() OVERRIDE;
59 virtual RenderFrameHost* GetParent() OVERRIDE; 66 virtual RenderFrameHost* GetParent() OVERRIDE;
60 virtual const std::string& GetFrameName() OVERRIDE; 67 virtual const std::string& GetFrameName() OVERRIDE;
61 virtual bool IsCrossProcessSubframe() OVERRIDE; 68 virtual bool IsCrossProcessSubframe() OVERRIDE;
62 virtual GURL GetLastCommittedURL() OVERRIDE; 69 virtual GURL GetLastCommittedURL() OVERRIDE;
63 virtual gfx::NativeView GetNativeView() OVERRIDE; 70 virtual gfx::NativeView GetNativeView() OVERRIDE;
64 virtual void ExecuteJavaScript( 71 virtual void ExecuteJavaScript(
65 const base::string16& javascript) OVERRIDE; 72 const base::string16& javascript) OVERRIDE;
66 virtual void ExecuteJavaScript( 73 virtual void ExecuteJavaScript(
67 const base::string16& javascript, 74 const base::string16& javascript,
68 const JavaScriptResultCallback& callback) OVERRIDE; 75 const JavaScriptResultCallback& callback) OVERRIDE;
69 virtual RenderViewHost* GetRenderViewHost() OVERRIDE; 76 virtual RenderViewHost* GetRenderViewHost() OVERRIDE;
70 virtual ServiceRegistry* GetServiceRegistry() OVERRIDE; 77 virtual ServiceRegistry* GetServiceRegistry() OVERRIDE;
71 78
72 // IPC::Sender 79 // IPC::Sender
73 virtual bool Send(IPC::Message* msg) OVERRIDE; 80 virtual bool Send(IPC::Message* msg) OVERRIDE;
74 81
75 // IPC::Listener 82 // IPC::Listener
76 virtual bool OnMessageReceived(const IPC::Message& msg) OVERRIDE; 83 virtual bool OnMessageReceived(const IPC::Message& msg) OVERRIDE;
77 84
85 // BrowserAccessibilityDelegate
86 virtual void AccessibilitySetFocus(int acc_obj_id) OVERRIDE;
87 virtual void AccessibilityDoDefaultAction(int acc_obj_id) OVERRIDE;
88 virtual void AccessibilityShowMenu(const gfx::Point& point) OVERRIDE;
89 virtual void AccessibilityScrollToMakeVisible(
90 int acc_obj_id, gfx::Rect subfocus) OVERRIDE;
ncarter (slow) 2014/07/15 01:23:28 Probably worth passing the gfx::Rect as a const re
dmazzoni 2014/07/15 07:55:04 Done.
91 virtual void AccessibilityScrollToPoint(
92 int acc_obj_id, gfx::Point point) OVERRIDE;
93 virtual void AccessibilitySetTextSelection(
94 int acc_obj_id, int start_offset, int end_offset) OVERRIDE;
95 virtual bool AccessibilityViewHasFocus() const OVERRIDE;
96 virtual gfx::Rect AccessibilityGetViewBounds() const OVERRIDE;
97 virtual gfx::Point AccessibilityOriginInScreen(const gfx::Rect& bounds)
98 const OVERRIDE;
99 virtual void AccessibilityHitTest(const gfx::Point& point) OVERRIDE;
100 virtual void AccessibilityFatalError() OVERRIDE;
101
78 void Init(); 102 void Init();
79 int routing_id() const { return routing_id_; } 103 int routing_id() const { return routing_id_; }
80 void OnCreateChildFrame(int new_routing_id, 104 void OnCreateChildFrame(int new_routing_id,
81 const std::string& frame_name); 105 const std::string& frame_name);
82 106
83 RenderViewHostImpl* render_view_host() { return render_view_host_; } 107 RenderViewHostImpl* render_view_host() { return render_view_host_; }
84 RenderFrameHostDelegate* delegate() { return delegate_; } 108 RenderFrameHostDelegate* delegate() { return delegate_; }
85 FrameTreeNode* frame_tree_node() { return frame_tree_node_; } 109 FrameTreeNode* frame_tree_node() { return frame_tree_node_; }
86 // TODO(nasko): The RenderWidgetHost will be owned by RenderFrameHost in 110 // TODO(nasko): The RenderWidgetHost will be owned by RenderFrameHost in
87 // the future, so update this accessor to return the right pointer. 111 // the future, so update this accessor to return the right pointer.
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
171 bool dialog_was_suppressed); 195 bool dialog_was_suppressed);
172 196
173 // Called when an HTML5 notification is closed. 197 // Called when an HTML5 notification is closed.
174 void NotificationClosed(int notification_id); 198 void NotificationClosed(int notification_id);
175 199
176 // Sets whether there is an outstanding transition request. This is called at 200 // Sets whether there is an outstanding transition request. This is called at
177 // the start of a provisional load for the main frame, and cleared when we 201 // the start of a provisional load for the main frame, and cleared when we
178 // hear the response or commit. 202 // hear the response or commit.
179 void SetHasPendingTransitionRequest(bool has_pending_request); 203 void SetHasPendingTransitionRequest(bool has_pending_request);
180 204
205 // Gets the accessibility mode.
206 AccessibilityMode accessibility_mode() const {
207 return accessibility_mode_;
David Tseng 2014/07/14 19:08:02 Does each frame get its own accessibility mode? If
dmazzoni 2014/07/15 07:55:04 This change already made the WebContents have the
208 }
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().
David Tseng 2014/07/14 19:08:02 Why not just pass the ax tree as a param of the ca
dmazzoni 2014/07/15 07:55:04 Often the callback is used by the accessibility wa
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();
David Tseng 2014/07/14 19:08:02 Not really needed; see above.
224
225 // Access the BrowserAccessibilityManager if it already exists.
226 BrowserAccessibilityManager* browser_accessibility_manager() const {
David Tseng 2014/07/14 19:08:02 How do you feel about naming this RenderFrameHostA
dmazzoni 2014/07/15 07:55:04 I was thinking FrameAccessibility or FrameHostAcce
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
181 protected: 241 protected:
182 friend class RenderFrameHostFactory; 242 friend class RenderFrameHostFactory;
183 243
184 // TODO(nasko): Remove dependency on RenderViewHost here. RenderProcessHost 244 // TODO(nasko): Remove dependency on RenderViewHost here. RenderProcessHost
185 // 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
186 // into WebContentsObserver::FrameDetached for now. 246 // into WebContentsObserver::FrameDetached for now.
187 RenderFrameHostImpl(RenderViewHostImpl* render_view_host, 247 RenderFrameHostImpl(RenderViewHostImpl* render_view_host,
188 RenderFrameHostDelegate* delegate, 248 RenderFrameHostDelegate* delegate,
189 FrameTree* frame_tree, 249 FrameTree* frame_tree,
190 FrameTreeNode* frame_tree_node, 250 FrameTreeNode* frame_tree_node,
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
239 void OnCancelDesktopNotification(int notification_id); 299 void OnCancelDesktopNotification(int notification_id);
240 void OnTextSurroundingSelectionResponse(const base::string16& content, 300 void OnTextSurroundingSelectionResponse(const base::string16& content,
241 size_t start_offset, 301 size_t start_offset,
242 size_t end_offset); 302 size_t end_offset);
243 void OnDidAccessInitialDocument(); 303 void OnDidAccessInitialDocument();
244 void OnDidDisownOpener(); 304 void OnDidDisownOpener();
245 void OnUpdateTitle(int32 page_id, 305 void OnUpdateTitle(int32 page_id,
246 const base::string16& title, 306 const base::string16& title,
247 blink::WebTextDirection title_direction); 307 blink::WebTextDirection title_direction);
248 void OnUpdateEncoding(const std::string& encoding); 308 void OnUpdateEncoding(const std::string& encoding);
309 void OnAccessibilityEvents(
310 const std::vector<AccessibilityHostMsg_EventParams>& params);
311 void OnAccessibilityLocationChanges(
312 const std::vector<AccessibilityHostMsg_LocationChangeParams>& params);
249 313
250 // Returns whether the given URL is allowed to commit in the current process. 314 // Returns whether the given URL is allowed to commit in the current process.
251 // This is a more conservative check than RenderProcessHost::FilterURL, since 315 // This is a more conservative check than RenderProcessHost::FilterURL, since
252 // it will be used to kill processes that commit unauthorized URLs. 316 // it will be used to kill processes that commit unauthorized URLs.
253 bool CanCommitURL(const GURL& url); 317 bool CanCommitURL(const GURL& url);
254 318
255 void DesktopNotificationPermissionRequestDone(int callback_context); 319 void DesktopNotificationPermissionRequestDone(int callback_context);
256 320
257 // For now, RenderFrameHosts indirectly keep RenderViewHosts alive via a 321 // For now, RenderFrameHosts indirectly keep RenderViewHosts alive via a
258 // refcount that calls Shutdown when it reaches zero. This allows each 322 // refcount that calls Shutdown when it reaches zero. This allows each
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
300 int routing_id_; 364 int routing_id_;
301 bool is_swapped_out_; 365 bool is_swapped_out_;
302 366
303 // When the last BeforeUnload message was sent. 367 // When the last BeforeUnload message was sent.
304 base::TimeTicks send_before_unload_start_time_; 368 base::TimeTicks send_before_unload_start_time_;
305 369
306 ServiceRegistryImpl service_registry_; 370 ServiceRegistryImpl service_registry_;
307 371
308 base::WeakPtrFactory<RenderFrameHostImpl> weak_ptr_factory_; 372 base::WeakPtrFactory<RenderFrameHostImpl> weak_ptr_factory_;
309 373
374 AccessibilityMode accessibility_mode_;
375 base::Callback<void(ui::AXEvent, int)> accessibility_testing_callback_;
376 // The most recently received accessibility tree - for testing only.
David Tseng 2014/07/14 19:08:02 Are we ok with test only members?
ncarter (slow) 2014/07/15 01:23:28 I also would rather we not have test-only members,
dmazzoni 2014/07/15 07:55:04 Yeah, I'm happy to work on ways to do this without
377 scoped_ptr<ui::AXTree> ax_tree_for_testing_;
378 scoped_ptr<BrowserAccessibilityManager> browser_accessibility_manager_;
David Tseng 2014/07/14 19:08:02 Seems like test members should go last?
dmazzoni 2014/07/15 07:55:04 Done.
379
310 DISALLOW_COPY_AND_ASSIGN(RenderFrameHostImpl); 380 DISALLOW_COPY_AND_ASSIGN(RenderFrameHostImpl);
311 }; 381 };
312 382
313 } // namespace content 383 } // namespace content
314 384
315 #endif // CONTENT_BROWSER_FRAME_HOST_RENDER_FRAME_HOST_IMPL_H_ 385 #endif // CONTENT_BROWSER_FRAME_HOST_RENDER_FRAME_HOST_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698