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

Unified Diff: content/browser/frame_host/render_frame_host_impl.cc

Issue 625443002: Reset accessibility if it gets out of sync. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Removed flakiness Created 6 years, 2 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/browser/frame_host/render_frame_host_impl.h ('k') | content/common/accessibility_messages.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 e2bf47bc3e6b179002fb72ed4f1a3fdf6525290b..1f228805e7651e4c4876b0ca92393e503dc9ec18 100644
--- a/content/browser/frame_host/render_frame_host_impl.cc
+++ b/content/browser/frame_host/render_frame_host_impl.cc
@@ -70,6 +70,9 @@ namespace content {
namespace {
+// The next value to use for the accessibility reset token.
+int g_next_accessibility_reset_token = 1;
+
// The (process id, routing id) pair that identifies one RenderFrame.
typedef std::pair<int32, int32> RenderFrameHostID;
typedef base::hash_map<RenderFrameHostID, RenderFrameHostImpl*>
@@ -189,6 +192,9 @@ RenderFrameHostImpl::RenderFrameHostImpl(RenderViewHostImpl* render_view_host,
navigations_suspended_(false),
is_waiting_for_beforeunload_ack_(false),
unload_ack_is_for_cross_site_transition_(false),
+ accessibility_reset_token_(0),
+ accessibility_reset_count_(0),
+ no_create_browser_accessibility_manager_for_testing_(false),
weak_ptr_factory_(this) {
frame_tree_->RegisterRenderFrameHost(this);
GetProcess()->AddRoute(routing_id_, this);
@@ -479,8 +485,18 @@ void RenderFrameHostImpl::AccessibilityHitTest(const gfx::Point& point) {
}
void RenderFrameHostImpl::AccessibilityFatalError() {
- Send(new AccessibilityMsg_FatalError(routing_id_));
browser_accessibility_manager_.reset(NULL);
+ if (accessibility_reset_token_)
+ return;
+
+ accessibility_reset_count_++;
+ if (accessibility_reset_count_ >= kMaxAccessibilityResets) {
+ Send(new AccessibilityMsg_FatalError(routing_id_));
+ } else {
+ accessibility_reset_token_ = g_next_accessibility_reset_token++;
+ UMA_HISTOGRAM_COUNTS("Accessibility.FrameResetCount", 1);
+ Send(new AccessibilityMsg_Reset(routing_id_, accessibility_reset_token_));
+ }
}
gfx::AcceleratedWidget
@@ -756,6 +772,7 @@ void RenderFrameHostImpl::OnDidCommitProvisionalLoad(const IPC::Message& msg) {
return;
}
+ accessibility_reset_count_ = 0;
frame_tree_node()->navigator()->DidNavigate(this, validated_params);
}
@@ -1081,7 +1098,17 @@ void RenderFrameHostImpl::OnBeginNavigation(
}
void RenderFrameHostImpl::OnAccessibilityEvents(
- const std::vector<AccessibilityHostMsg_EventParams>& params) {
+ const std::vector<AccessibilityHostMsg_EventParams>& params,
+ int reset_token) {
+ // Don't process this IPC if either we're waiting on a reset and this
+ // IPC doesn't have the matching token ID, or if we're not waiting on a
+ // reset but this message includes a reset token.
+ if (accessibility_reset_token_ != reset_token) {
+ Send(new AccessibilityMsg_Events_ACK(routing_id_));
+ return;
+ }
+ accessibility_reset_token_ = 0;
+
RenderWidgetHostViewBase* view = static_cast<RenderWidgetHostViewBase*>(
render_view_host_->GetView());
@@ -1156,17 +1183,18 @@ void RenderFrameHostImpl::OnAccessibilityEvents(
void RenderFrameHostImpl::OnAccessibilityLocationChanges(
const std::vector<AccessibilityHostMsg_LocationChangeParams>& params) {
+ if (accessibility_reset_token_)
+ return;
+
RenderWidgetHostViewBase* view = static_cast<RenderWidgetHostViewBase*>(
render_view_host_->GetView());
if (view && RenderFrameHostImpl::IsRFHStateActive(rfh_state())) {
AccessibilityMode accessibility_mode = delegate_->GetAccessibilityMode();
if (accessibility_mode & AccessibilityModeFlagPlatform) {
- if (!browser_accessibility_manager_) {
- browser_accessibility_manager_.reset(
- view->CreateBrowserAccessibilityManager(this));
- }
- if (browser_accessibility_manager_)
- browser_accessibility_manager_->OnLocationChanges(params);
+ BrowserAccessibilityManager* manager =
+ GetOrCreateBrowserAccessibilityManager();
+ if (manager)
+ manager->OnLocationChanges(params);
}
// TODO(aboxhall): send location change events to web contents observers too
}
@@ -1474,9 +1502,14 @@ BrowserAccessibilityManager*
RenderWidgetHostViewBase* view = static_cast<RenderWidgetHostViewBase*>(
render_view_host_->GetView());
if (view &&
- !browser_accessibility_manager_) {
+ !browser_accessibility_manager_ &&
+ !no_create_browser_accessibility_manager_for_testing_) {
browser_accessibility_manager_.reset(
view->CreateBrowserAccessibilityManager(this));
+ if (browser_accessibility_manager_)
+ UMA_HISTOGRAM_COUNTS("Accessibility.FrameEnabledCount", 1);
+ else
+ UMA_HISTOGRAM_COUNTS("Accessibility.FrameDidNotEnableCount", 1);
}
return browser_accessibility_manager_.get();
}
« no previous file with comments | « content/browser/frame_host/render_frame_host_impl.h ('k') | content/common/accessibility_messages.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698