Revert "content: convert accessibility notifications to callbacks"

TBR=jam

BUG=170921

Review URL: https://codereview.chromium.org/12212188

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@182433 0039d316-1c4b-4281-b951-d872f2087c98
parent f47adce3
...@@ -33,17 +33,17 @@ class CrossPlatformAccessibilityBrowserTest : public ContentBrowserTest { ...@@ -33,17 +33,17 @@ class CrossPlatformAccessibilityBrowserTest : public ContentBrowserTest {
// notification that it's been received. // notification that it's been received.
const AccessibilityNodeData& GetAccessibilityNodeDataTree( const AccessibilityNodeData& GetAccessibilityNodeDataTree(
AccessibilityMode accessibility_mode = AccessibilityModeComplete) { AccessibilityMode accessibility_mode = AccessibilityModeComplete) {
scoped_refptr<MessageLoopRunner> loop_runner(new MessageLoopRunner); WindowedNotificationObserver tree_updated_observer(
NOTIFICATION_ACCESSIBILITY_LAYOUT_COMPLETE,
NotificationService::AllSources());
RenderWidgetHostView* host_view = RenderWidgetHostView* host_view =
shell()->web_contents()->GetRenderWidgetHostView(); shell()->web_contents()->GetRenderWidgetHostView();
RenderWidgetHostImpl* host = RenderWidgetHostImpl* host =
RenderWidgetHostImpl::From(host_view->GetRenderWidgetHost()); RenderWidgetHostImpl::From(host_view->GetRenderWidgetHost());
RenderViewHostImpl* view_host = static_cast<RenderViewHostImpl*>(host); RenderViewHostImpl* view_host = static_cast<RenderViewHostImpl*>(host);
view_host->SetAccessibilityLayoutCompleteCallbackForTesting(
loop_runner->QuitClosure());
view_host->set_save_accessibility_tree_for_testing(true); view_host->set_save_accessibility_tree_for_testing(true);
view_host->SetAccessibilityMode(accessibility_mode); view_host->SetAccessibilityMode(accessibility_mode);
loop_runner->Run(); tree_updated_observer.Wait();
return view_host->accessibility_tree_for_testing(); return view_host->accessibility_tree_for_testing();
} }
......
...@@ -18,6 +18,8 @@ ...@@ -18,6 +18,8 @@
#include "content/browser/accessibility/dump_accessibility_tree_helper.h" #include "content/browser/accessibility/dump_accessibility_tree_helper.h"
#include "content/browser/renderer_host/render_view_host_impl.h" #include "content/browser/renderer_host/render_view_host_impl.h"
#include "content/port/browser/render_widget_host_view_port.h" #include "content/port/browser/render_widget_host_view_port.h"
#include "content/public/browser/notification_service.h"
#include "content/public/browser/notification_types.h"
#include "content/public/browser/web_contents.h" #include "content/public/browser/web_contents.h"
#include "content/public/common/content_paths.h" #include "content/public/common/content_paths.h"
#include "content/public/test/test_utils.h" #include "content/public/test/test_utils.h"
...@@ -26,16 +28,14 @@ ...@@ -26,16 +28,14 @@
#include "content/shell/shell.h" #include "content/shell/shell.h"
#include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest/include/gtest/gtest.h"
namespace content {
namespace { namespace {
static const char kCommentToken = '#';
static const char* kMarkSkipFile = "#<skip";
static const char* kMarkEndOfFile = "<-- End-of-file -->";
static const char* kSignalDiff = "*";
} // namespace
const char kCommentToken = '#'; namespace content {
const char kMarkSkipFile[] = "#<skip";
const char kMarkEndOfFile[] = "<-- End-of-file -->";
const char kSignalDiff[] = "*";
} // namespace
typedef DumpAccessibilityTreeHelper::Filter Filter; typedef DumpAccessibilityTreeHelper::Filter Filter;
...@@ -166,17 +166,17 @@ void DumpAccessibilityTreeTest::RunTest( ...@@ -166,17 +166,17 @@ void DumpAccessibilityTreeTest::RunTest(
} }
// Load the page. // Load the page.
WindowedNotificationObserver tree_updated_observer(
NOTIFICATION_ACCESSIBILITY_LOAD_COMPLETE,
NotificationService::AllSources());
string16 html_contents16; string16 html_contents16;
html_contents16 = UTF8ToUTF16(html_contents); html_contents16 = UTF8ToUTF16(html_contents);
GURL url = GetTestUrl("accessibility", GURL url = GetTestUrl("accessibility",
html_file.BaseName().MaybeAsASCII().c_str()); html_file.BaseName().MaybeAsASCII().c_str());
scoped_refptr<MessageLoopRunner> loop_runner(new MessageLoopRunner);
view_host->SetAccessibilityLoadCompleteCallbackForTesting(
loop_runner->QuitClosure());
NavigateToURL(shell(), url); NavigateToURL(shell(), url);
// Wait for the tree. // Wait for the tree.
loop_runner->Run(); tree_updated_observer.Wait();
// Perform a diff (or write the initial baseline). // Perform a diff (or write the initial baseline).
string16 actual_contents_utf16; string16 actual_contents_utf16;
......
...@@ -1786,16 +1786,6 @@ void RenderViewHostImpl::UpdateFrameTree( ...@@ -1786,16 +1786,6 @@ void RenderViewHostImpl::UpdateFrameTree(
frame_tree_)); frame_tree_));
} }
void RenderViewHostImpl::SetAccessibilityLayoutCompleteCallbackForTesting(
const base::Closure& callback) {
accessibility_layout_callback_ = callback;
}
void RenderViewHostImpl::SetAccessibilityLoadCompleteCallbackForTesting(
const base::Closure& callback) {
accessibility_load_callback_ = callback;
}
void RenderViewHostImpl::UpdateWebkitPreferences( void RenderViewHostImpl::UpdateWebkitPreferences(
const webkit_glue::WebPreferences& prefs) { const webkit_glue::WebPreferences& prefs) {
Send(new ViewMsg_UpdateWebPreferences(GetRoutingID(), prefs)); Send(new ViewMsg_UpdateWebPreferences(GetRoutingID(), prefs));
...@@ -1902,11 +1892,17 @@ void RenderViewHostImpl::OnAccessibilityNotifications( ...@@ -1902,11 +1892,17 @@ void RenderViewHostImpl::OnAccessibilityNotifications(
accessibility_tree_ = param.acc_tree; accessibility_tree_ = param.acc_tree;
} }
if (src_type == AccessibilityNotificationLayoutComplete) { NotificationType dst_type;
accessibility_layout_callback_.Run(); if (src_type == AccessibilityNotificationLoadComplete)
} else if (src_type == AccessibilityNotificationLoadComplete) { dst_type = NOTIFICATION_ACCESSIBILITY_LOAD_COMPLETE;
accessibility_load_callback_.Run(); else if (src_type == AccessibilityNotificationLayoutComplete)
} dst_type = NOTIFICATION_ACCESSIBILITY_LAYOUT_COMPLETE;
else
dst_type = NOTIFICATION_ACCESSIBILITY_OTHER;
NotificationService::current()->Notify(
dst_type,
Source<RenderViewHost>(this),
NotificationService::NoDetails());
} }
Send(new AccessibilityMsg_Notifications_ACK(GetRoutingID())); Send(new AccessibilityMsg_Notifications_ACK(GetRoutingID()));
......
...@@ -414,12 +414,6 @@ class CONTENT_EXPORT RenderViewHostImpl ...@@ -414,12 +414,6 @@ class CONTENT_EXPORT RenderViewHostImpl
int route_id, int route_id,
const std::string& frame_tree); const std::string& frame_tree);
// Set accessibility callbacks.
void SetAccessibilityLayoutCompleteCallbackForTesting(
const base::Closure& callback);
void SetAccessibilityLoadCompleteCallbackForTesting(
const base::Closure& callback);
void set_save_accessibility_tree_for_testing(bool save) { void set_save_accessibility_tree_for_testing(bool save) {
save_accessibility_tree_for_testing_ = save; save_accessibility_tree_for_testing_ = save;
} }
...@@ -658,10 +652,6 @@ class CONTENT_EXPORT RenderViewHostImpl ...@@ -658,10 +652,6 @@ class CONTENT_EXPORT RenderViewHostImpl
// callbacks. // callbacks.
std::map<int, JavascriptResultCallback> javascript_callbacks_; std::map<int, JavascriptResultCallback> javascript_callbacks_;
// Accessibility callbacks.
base::Closure accessibility_layout_callback_;
base::Closure accessibility_load_callback_;
// True if the render view can be shut down suddenly. // True if the render view can be shut down suddenly.
bool sudden_termination_allowed_; bool sudden_termination_allowed_;
......
...@@ -250,6 +250,21 @@ enum NotificationType { ...@@ -250,6 +250,21 @@ enum NotificationType {
// the RenderViewHost, and the details is a DomOperationNotificationDetails. // the RenderViewHost, and the details is a DomOperationNotificationDetails.
NOTIFICATION_DOM_OPERATION_RESPONSE, NOTIFICATION_DOM_OPERATION_RESPONSE,
// Indicates that the render view host has received a "load complete"
// accessibility notification. The source is the RenderViewHost,
// the details are not used.
NOTIFICATION_ACCESSIBILITY_LOAD_COMPLETE,
// Indicates that the render view host has received a "layout complete"
// accessibility notification. The source is the RenderViewHost,
// the details are not used.
NOTIFICATION_ACCESSIBILITY_LAYOUT_COMPLETE,
// Indicates that the render view host has received an accessibility
// notification. other than the ones covered above.
// The source is the RenderViewHost, the details are not used.
NOTIFICATION_ACCESSIBILITY_OTHER,
// Child Processes --------------------------------------------------------- // Child Processes ---------------------------------------------------------
// This notification is sent when a child process host has connected to a // This notification is sent when a child process host has connected to a
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment