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

Side by Side Diff: chrome/browser/extensions/api/automation_internal/automation_util.cc

Issue 280853004: Use EventRouter::Get instead of ExtensionSystem::Get(browser_context)->event_router() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: review Created 6 years, 7 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 #include "chrome/browser/extensions/api/automation_internal/automation_util.h" 5 #include "chrome/browser/extensions/api/automation_internal/automation_util.h"
6 6
7 #include <string> 7 #include <string>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/command_line.h" 10 #include "base/command_line.h"
11 #include "base/values.h" 11 #include "base/values.h"
12 #include "chrome/common/chrome_switches.h" 12 #include "chrome/common/chrome_switches.h"
13 #include "chrome/common/extensions/api/automation_internal.h" 13 #include "chrome/common/extensions/api/automation_internal.h"
14 #include "extensions/browser/event_router.h" 14 #include "extensions/browser/event_router.h"
15 #include "extensions/browser/extension_system.h"
16 #include "ui/accessibility/ax_enums.h" 15 #include "ui/accessibility/ax_enums.h"
17 #include "ui/accessibility/ax_node_data.h" 16 #include "ui/accessibility/ax_node_data.h"
18 17
19 namespace extensions { 18 namespace extensions {
20 19
21 namespace { 20 namespace {
22 21
23 void PopulateNodeData(const ui::AXNodeData& node_data, 22 void PopulateNodeData(const ui::AXNodeData& node_data,
24 linked_ptr< api::automation_internal::AXNodeData>& out_node_data) { 23 linked_ptr< api::automation_internal::AXNodeData>& out_node_data) {
25 out_node_data->id = node_data.id; 24 out_node_data->id = node_data.id;
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 } 107 }
109 108
110 for (size_t i = 0; i < node_data.child_ids.size(); ++i) { 109 for (size_t i = 0; i < node_data.child_ids.size(); ++i) {
111 out_node_data->child_ids.push_back(node_data.child_ids[i]); 110 out_node_data->child_ids.push_back(node_data.child_ids[i]);
112 } 111 }
113 } 112 }
114 113
115 void DispatchEventInternal(content::BrowserContext* context, 114 void DispatchEventInternal(content::BrowserContext* context,
116 const std::string& event_name, 115 const std::string& event_name,
117 scoped_ptr<base::ListValue> args) { 116 scoped_ptr<base::ListValue> args) {
118 if (context && ExtensionSystem::Get(context)->event_router()) { 117 if (context && EventRouter::Get(context)) {
119 scoped_ptr<Event> event(new Event(event_name, args.Pass())); 118 scoped_ptr<Event> event(new Event(event_name, args.Pass()));
120 event->restrict_to_browser_context = context; 119 event->restrict_to_browser_context = context;
121 ExtensionSystem::Get(context)->event_router()->BroadcastEvent(event.Pass()); 120 EventRouter::Get(context)->BroadcastEvent(event.Pass());
122 } 121 }
123 } 122 }
124 123
125 } //namespace 124 } // namespace
126 125
127 namespace automation_util { 126 namespace automation_util {
128 127
129 void DispatchAccessibilityEventsToAutomation( 128 void DispatchAccessibilityEventsToAutomation(
130 const std::vector<content::AXEventNotificationDetails>& details, 129 const std::vector<content::AXEventNotificationDetails>& details,
131 content::BrowserContext* browser_context) { 130 content::BrowserContext* browser_context) {
132 if (!CommandLine::ForCurrentProcess()->HasSwitch( 131 if (!CommandLine::ForCurrentProcess()->HasSwitch(
133 switches::kEnableAutomationAPI)) { 132 switches::kEnableAutomationAPI)) {
134 return; 133 return;
135 } 134 }
(...skipping 24 matching lines...) Expand all
160 // |AccessibilityHostMsg_EventParams| and |AccessibilityHostMsg_Events|. 159 // |AccessibilityHostMsg_EventParams| and |AccessibilityHostMsg_Events|.
161 DispatchEventInternal(browser_context, 160 DispatchEventInternal(browser_context,
162 api::automation_internal::OnAccessibilityEvent::kEventName, 161 api::automation_internal::OnAccessibilityEvent::kEventName,
163 api::automation_internal::OnAccessibilityEvent::Create(ax_tree_update)); 162 api::automation_internal::OnAccessibilityEvent::Create(ax_tree_update));
164 } 163 }
165 } 164 }
166 165
167 } // namespace automation_util 166 } // namespace automation_util
168 167
169 } // namespace extensions 168 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698