OLD | NEW |
---|---|
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_internal_ api.h" | 5 #include "chrome/browser/extensions/api/automation_internal/automation_internal_ api.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/lazy_instance.h" | 8 #include "base/lazy_instance.h" |
9 #include "base/strings/string_number_conversions.h" | 9 #include "base/strings/string_number_conversions.h" |
10 #include "base/values.h" | 10 #include "base/values.h" |
11 #include "chrome/browser/ui/browser.h" | 11 #include "chrome/browser/ui/browser.h" |
12 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 12 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
13 #include "chrome/common/chrome_switches.h" | 13 #include "chrome/common/chrome_switches.h" |
14 #include "chrome/common/extensions/api/automation_internal.h" | 14 #include "chrome/common/extensions/api/automation_internal.h" |
15 #include "content/public/browser/ax_event_notification_details.h" | 15 #include "content/public/browser/ax_event_notification_details.h" |
16 #include "content/public/browser/browser_accessibility_state.h" | 16 #include "content/public/browser/browser_accessibility_state.h" |
17 #include "content/public/browser/browser_thread.h" | 17 #include "content/public/browser/browser_thread.h" |
18 #include "content/public/browser/notification_service.h" | 18 #include "content/public/browser/notification_service.h" |
19 #include "content/public/browser/notification_source.h" | 19 #include "content/public/browser/notification_source.h" |
20 #include "content/public/browser/notification_types.h" | 20 #include "content/public/browser/notification_types.h" |
21 #include "content/public/browser/render_process_host.h" | 21 #include "content/public/browser/render_process_host.h" |
22 #include "content/public/browser/render_view_host.h" | 22 #include "content/public/browser/render_view_host.h" |
23 #include "content/public/browser/render_widget_host.h" | 23 #include "content/public/browser/render_widget_host.h" |
24 #include "content/public/browser/render_widget_host.h" | 24 #include "content/public/browser/render_widget_host.h" |
25 #include "content/public/browser/render_widget_host_view.h" | 25 #include "content/public/browser/render_widget_host_view.h" |
26 #include "content/public/browser/web_contents.h" | 26 #include "content/public/browser/web_contents.h" |
27 #include "extensions/browser/event_router.h" | 27 #include "extensions/browser/event_router.h" |
28 #include "extensions/browser/extension_system.h" | |
29 #include "ui/accessibility/ax_enums.h" | 28 #include "ui/accessibility/ax_enums.h" |
30 #include "ui/accessibility/ax_node_data.h" | 29 #include "ui/accessibility/ax_node_data.h" |
31 | 30 |
32 namespace extensions { | 31 namespace extensions { |
33 class AutomationWebContentsObserver; | 32 class AutomationWebContentsObserver; |
34 } // namespace extensions | 33 } // namespace extensions |
35 | 34 |
36 DEFINE_WEB_CONTENTS_USER_DATA_KEY(extensions::AutomationWebContentsObserver); | 35 DEFINE_WEB_CONTENTS_USER_DATA_KEY(extensions::AutomationWebContentsObserver); |
37 | 36 |
38 namespace extensions { | 37 namespace extensions { |
39 | 38 |
40 using ui::AXNodeData; | 39 using ui::AXNodeData; |
41 | 40 |
42 namespace { | 41 namespace { |
43 | 42 |
44 // Dispatches events to the extension message service. | 43 // Dispatches events to the extension message service. |
45 void DispatchEvent(content::BrowserContext* context, | 44 void DispatchEvent(content::BrowserContext* context, |
46 const std::string& event_name, | 45 const std::string& event_name, |
47 scoped_ptr<base::ListValue> args) { | 46 scoped_ptr<base::ListValue> args) { |
48 if (context && extensions::ExtensionSystem::Get(context)->event_router()) { | 47 if (!context) |
not at google - send to devlin
2014/04/17 16:09:46
the context can't possibly be null here, so you do
limasdf
2014/04/17 16:22:56
Done.
| |
49 scoped_ptr<Event> event(new Event(event_name, args.Pass())); | 48 return; |
50 event->restrict_to_browser_context = context; | 49 extensions::EventRouter* event_router = extensions::EventRouter::Get(context); |
51 ExtensionSystem::Get(context)->event_router()->BroadcastEvent(event.Pass()); | 50 if (!event_router) |
52 } | 51 return; |
52 | |
53 scoped_ptr<Event> event(new Event(event_name, args.Pass())); | |
54 event->restrict_to_browser_context = context; | |
55 event_router->BroadcastEvent(event.Pass()); | |
53 } | 56 } |
54 | 57 |
55 } // namespace | 58 } // namespace |
56 | 59 |
57 // Helper class that receives accessibility data from |WebContents|. | 60 // Helper class that receives accessibility data from |WebContents|. |
58 class AutomationWebContentsObserver | 61 class AutomationWebContentsObserver |
59 : public content::WebContentsObserver, | 62 : public content::WebContentsObserver, |
60 public content::WebContentsUserData<AutomationWebContentsObserver> { | 63 public content::WebContentsUserData<AutomationWebContentsObserver> { |
61 public: | 64 public: |
62 virtual ~AutomationWebContentsObserver() {} | 65 virtual ~AutomationWebContentsObserver() {} |
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
262 selection_params.end_index); | 265 selection_params.end_index); |
263 break; | 266 break; |
264 } | 267 } |
265 default: | 268 default: |
266 NOTREACHED(); | 269 NOTREACHED(); |
267 } | 270 } |
268 return true; | 271 return true; |
269 } | 272 } |
270 | 273 |
271 } // namespace extensions | 274 } // namespace extensions |
OLD | NEW |