Chromium Code Reviews| 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 extensions::EventRouter* event_router = extensions::EventRouter::Get(context); |
|
not at google - send to devlin
2014/04/17 16:47:46
hm, extensions:: unnecessary here too
limasdf
2014/04/17 16:54:28
Done.
| |
| 49 scoped_ptr<Event> event(new Event(event_name, args.Pass())); | 48 if (!event_router) |
| 50 event->restrict_to_browser_context = context; | 49 return; |
| 51 ExtensionSystem::Get(context)->event_router()->BroadcastEvent(event.Pass()); | 50 |
| 52 } | 51 scoped_ptr<Event> event(new Event(event_name, args.Pass())); |
| 52 event->restrict_to_browser_context = context; | |
| 53 event_router->BroadcastEvent(event.Pass()); | |
| 53 } | 54 } |
| 54 | 55 |
| 55 } // namespace | 56 } // namespace |
| 56 | 57 |
| 57 // Helper class that receives accessibility data from |WebContents|. | 58 // Helper class that receives accessibility data from |WebContents|. |
| 58 class AutomationWebContentsObserver | 59 class AutomationWebContentsObserver |
| 59 : public content::WebContentsObserver, | 60 : public content::WebContentsObserver, |
| 60 public content::WebContentsUserData<AutomationWebContentsObserver> { | 61 public content::WebContentsUserData<AutomationWebContentsObserver> { |
| 61 public: | 62 public: |
| 62 virtual ~AutomationWebContentsObserver() {} | 63 virtual ~AutomationWebContentsObserver() {} |
| (...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 262 selection_params.end_index); | 263 selection_params.end_index); |
| 263 break; | 264 break; |
| 264 } | 265 } |
| 265 default: | 266 default: |
| 266 NOTREACHED(); | 267 NOTREACHED(); |
| 267 } | 268 } |
| 268 return true; | 269 return true; |
| 269 } | 270 } |
| 270 | 271 |
| 271 } // namespace extensions | 272 } // namespace extensions |
| OLD | NEW |