Chromium Code Reviews| Index: content/browser/frame_host/render_frame_host_impl.cc |
| diff --git a/content/browser/frame_host/render_frame_host_impl.cc b/content/browser/frame_host/render_frame_host_impl.cc |
| index d4cc6f50c5f352ef7c908d8f5601785b97335ec6..1b9b8c7db50cf345358aa119bedecef2769dcc50 100644 |
| --- a/content/browser/frame_host/render_frame_host_impl.cc |
| +++ b/content/browser/frame_host/render_frame_host_impl.cc |
| @@ -64,6 +64,7 @@ |
| #include "content/public/common/url_constants.h" |
| #include "content/public/common/url_utils.h" |
| #include "ui/accessibility/ax_tree.h" |
| +#include "ui/accessibility/ax_tree_update.h" |
| #include "url/gurl.h" |
| #if defined(OS_MACOSX) |
| @@ -381,6 +382,8 @@ bool RenderFrameHostImpl::OnMessageReceived(const IPC::Message &msg) { |
| OnAccessibilityLocationChanges) |
| IPC_MESSAGE_HANDLER(AccessibilityHostMsg_FindInPageResult, |
| OnAccessibilityFindInPageResult) |
| + IPC_MESSAGE_HANDLER(AccessibilityHostMsg_SnapshotResponse, |
| + OnAccessibilitySnapshotResponse) |
| IPC_MESSAGE_HANDLER(FrameHostMsg_ToggleFullscreen, OnToggleFullscreen) |
| // The following message is synthetic and doesn't come from RenderFrame, but |
| // from RenderProcessHost. |
| @@ -1078,6 +1081,15 @@ void RenderFrameHostImpl::OnRenderProcessGone(int status, int exit_code) { |
| render_view_host_, static_cast<base::TerminationStatus>(status), |
| exit_code); |
| } |
| + |
| + // Execute any pending AX tree snapshot callbacks with an empty response, |
| + // since we're never going to get a response from this renderer. |
| + for (auto iter = ax_tree_snapshot_callbacks_.begin(); |
|
dcheng
2015/04/10 22:49:00
for (const auto& iter : ax_tree_snapshot_callbacks
dmazzoni
2015/04/13 06:37:18
Done.
|
| + iter != ax_tree_snapshot_callbacks_.end(); |
| + ++iter) { |
| + iter->second.Run(ui::AXTreeUpdate()); |
| + } |
| + ax_tree_snapshot_callbacks_.clear(); |
| } |
| void RenderFrameHostImpl::OnSwappedOut() { |
| @@ -1392,6 +1404,19 @@ void RenderFrameHostImpl::OnAccessibilityFindInPageResult( |
| } |
| } |
| +void RenderFrameHostImpl::OnAccessibilitySnapshotResponse( |
| + int callback_id, |
| + const ui::AXTreeUpdate& snapshot) { |
| + std::map<int, AXTreeSnapshotCallback>::iterator it = |
| + ax_tree_snapshot_callbacks_.find(callback_id); |
| + if (it != ax_tree_snapshot_callbacks_.end()) { |
| + it->second.Run(snapshot); |
| + ax_tree_snapshot_callbacks_.erase(it); |
| + } else { |
| + NOTREACHED() << "Received AX tree snapshot response for unknown id"; |
| + } |
| +} |
| + |
| void RenderFrameHostImpl::OnToggleFullscreen(bool enter_fullscreen) { |
| if (enter_fullscreen) |
| delegate_->EnterFullscreenMode(GetLastCommittedURL().GetOrigin()); |
| @@ -1805,6 +1830,14 @@ void RenderFrameHostImpl::SetAccessibilityMode(AccessibilityMode mode) { |
| Send(new FrameMsg_SetAccessibilityMode(routing_id_, mode)); |
| } |
| +void RenderFrameHostImpl::RequestAXTreeSnapshot( |
| + AXTreeSnapshotCallback callback) { |
| + static int next_id = 1; |
| + int callback_id = next_id++; |
| + Send(new AccessibilityMsg_SnapshotTree(routing_id_, callback_id)); |
| + ax_tree_snapshot_callbacks_.insert(std::make_pair(callback_id, callback)); |
| +} |
| + |
| void RenderFrameHostImpl::SetAccessibilityCallbackForTesting( |
| const base::Callback<void(ui::AXEvent, int)>& callback) { |
| accessibility_testing_callback_ = callback; |