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 <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/strings/string_number_conversions.h" | 9 #include "base/strings/string_number_conversions.h" |
10 #include "chrome/browser/extensions/api/automation_internal/automation_action_ad
apter.h" | 10 #include "chrome/browser/extensions/api/automation_internal/automation_action_ad
apter.h" |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
67 // Helper class that receives accessibility data from |WebContents|. | 67 // Helper class that receives accessibility data from |WebContents|. |
68 class AutomationWebContentsObserver | 68 class AutomationWebContentsObserver |
69 : public content::WebContentsObserver, | 69 : public content::WebContentsObserver, |
70 public content::WebContentsUserData<AutomationWebContentsObserver> { | 70 public content::WebContentsUserData<AutomationWebContentsObserver> { |
71 public: | 71 public: |
72 virtual ~AutomationWebContentsObserver() {} | 72 virtual ~AutomationWebContentsObserver() {} |
73 | 73 |
74 // content::WebContentsObserver overrides. | 74 // content::WebContentsObserver overrides. |
75 virtual void AccessibilityEventReceived( | 75 virtual void AccessibilityEventReceived( |
76 const std::vector<content::AXEventNotificationDetails>& details) | 76 const std::vector<content::AXEventNotificationDetails>& details) |
77 OVERRIDE { | 77 override { |
78 automation_util::DispatchAccessibilityEventsToAutomation( | 78 automation_util::DispatchAccessibilityEventsToAutomation( |
79 details, browser_context_, | 79 details, browser_context_, |
80 web_contents()->GetContainerBounds().OffsetFromOrigin()); | 80 web_contents()->GetContainerBounds().OffsetFromOrigin()); |
81 } | 81 } |
82 | 82 |
83 virtual void RenderFrameDeleted( | 83 virtual void RenderFrameDeleted( |
84 content::RenderFrameHost* render_frame_host) OVERRIDE { | 84 content::RenderFrameHost* render_frame_host) override { |
85 automation_util::DispatchTreeDestroyedEventToAutomation( | 85 automation_util::DispatchTreeDestroyedEventToAutomation( |
86 render_frame_host->GetProcess()->GetID(), | 86 render_frame_host->GetProcess()->GetID(), |
87 render_frame_host->GetRoutingID(), | 87 render_frame_host->GetRoutingID(), |
88 browser_context_); | 88 browser_context_); |
89 } | 89 } |
90 | 90 |
91 private: | 91 private: |
92 friend class content::WebContentsUserData<AutomationWebContentsObserver>; | 92 friend class content::WebContentsUserData<AutomationWebContentsObserver>; |
93 | 93 |
94 AutomationWebContentsObserver( | 94 AutomationWebContentsObserver( |
95 content::WebContents* web_contents) | 95 content::WebContents* web_contents) |
96 : content::WebContentsObserver(web_contents), | 96 : content::WebContentsObserver(web_contents), |
97 browser_context_(web_contents->GetBrowserContext()) {} | 97 browser_context_(web_contents->GetBrowserContext()) {} |
98 | 98 |
99 content::BrowserContext* browser_context_; | 99 content::BrowserContext* browser_context_; |
100 | 100 |
101 DISALLOW_COPY_AND_ASSIGN(AutomationWebContentsObserver); | 101 DISALLOW_COPY_AND_ASSIGN(AutomationWebContentsObserver); |
102 }; | 102 }; |
103 | 103 |
104 // Helper class that implements an action adapter for a |RenderFrameHost|. | 104 // Helper class that implements an action adapter for a |RenderFrameHost|. |
105 class RenderFrameHostActionAdapter : public AutomationActionAdapter { | 105 class RenderFrameHostActionAdapter : public AutomationActionAdapter { |
106 public: | 106 public: |
107 explicit RenderFrameHostActionAdapter(content::RenderFrameHost* rfh) | 107 explicit RenderFrameHostActionAdapter(content::RenderFrameHost* rfh) |
108 : rfh_(rfh) {} | 108 : rfh_(rfh) {} |
109 | 109 |
110 virtual ~RenderFrameHostActionAdapter() {} | 110 virtual ~RenderFrameHostActionAdapter() {} |
111 | 111 |
112 // AutomationActionAdapter implementation. | 112 // AutomationActionAdapter implementation. |
113 virtual void DoDefault(int32 id) OVERRIDE { | 113 virtual void DoDefault(int32 id) override { |
114 rfh_->AccessibilityDoDefaultAction(id); | 114 rfh_->AccessibilityDoDefaultAction(id); |
115 } | 115 } |
116 | 116 |
117 virtual void Focus(int32 id) OVERRIDE { | 117 virtual void Focus(int32 id) override { |
118 rfh_->AccessibilitySetFocus(id); | 118 rfh_->AccessibilitySetFocus(id); |
119 } | 119 } |
120 | 120 |
121 virtual void MakeVisible(int32 id) OVERRIDE { | 121 virtual void MakeVisible(int32 id) override { |
122 rfh_->AccessibilityScrollToMakeVisible(id, gfx::Rect()); | 122 rfh_->AccessibilityScrollToMakeVisible(id, gfx::Rect()); |
123 } | 123 } |
124 | 124 |
125 virtual void SetSelection(int32 id, int32 start, int32 end) OVERRIDE { | 125 virtual void SetSelection(int32 id, int32 start, int32 end) override { |
126 rfh_->AccessibilitySetTextSelection(id, start, end); | 126 rfh_->AccessibilitySetTextSelection(id, start, end); |
127 } | 127 } |
128 | 128 |
129 private: | 129 private: |
130 content::RenderFrameHost* rfh_; | 130 content::RenderFrameHost* rfh_; |
131 | 131 |
132 DISALLOW_COPY_AND_ASSIGN(RenderFrameHostActionAdapter); | 132 DISALLOW_COPY_AND_ASSIGN(RenderFrameHostActionAdapter); |
133 }; | 133 }; |
134 | 134 |
135 ExtensionFunction::ResponseAction | 135 ExtensionFunction::ResponseAction |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
249 return RespondNow(Error("desktop permission must be requested")); | 249 return RespondNow(Error("desktop permission must be requested")); |
250 | 250 |
251 AutomationManagerAsh::GetInstance()->Enable(browser_context()); | 251 AutomationManagerAsh::GetInstance()->Enable(browser_context()); |
252 return RespondNow(NoArguments()); | 252 return RespondNow(NoArguments()); |
253 #else | 253 #else |
254 return RespondNow(Error("getDesktop is unsupported by this platform")); | 254 return RespondNow(Error("getDesktop is unsupported by this platform")); |
255 #endif // defined(OS_CHROMEOS) | 255 #endif // defined(OS_CHROMEOS) |
256 } | 256 } |
257 | 257 |
258 } // namespace extensions | 258 } // namespace extensions |
OLD | NEW |