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

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

Issue 2550593003: Expose media controls to accessibility (Closed)
Patch Set: Created 4 years 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
« no previous file with comments | « no previous file | chrome/browser/resources/chromeos/chromevox/common/chrome_extension_externs.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_internal_ api.h" 5 #include "chrome/browser/extensions/api/automation_internal/automation_internal_ api.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include <vector> 9 #include <vector>
10 10
(...skipping 10 matching lines...) Expand all
21 #include "chrome/browser/ui/browser.h" 21 #include "chrome/browser/ui/browser.h"
22 #include "chrome/browser/ui/tabs/tab_strip_model.h" 22 #include "chrome/browser/ui/tabs/tab_strip_model.h"
23 #include "chrome/common/extensions/api/automation_api_constants.h" 23 #include "chrome/common/extensions/api/automation_api_constants.h"
24 #include "chrome/common/extensions/api/automation_internal.h" 24 #include "chrome/common/extensions/api/automation_internal.h"
25 #include "chrome/common/extensions/chrome_extension_messages.h" 25 #include "chrome/common/extensions/chrome_extension_messages.h"
26 #include "chrome/common/extensions/manifest_handlers/automation.h" 26 #include "chrome/common/extensions/manifest_handlers/automation.h"
27 #include "content/public/browser/ax_event_notification_details.h" 27 #include "content/public/browser/ax_event_notification_details.h"
28 #include "content/public/browser/browser_accessibility_state.h" 28 #include "content/public/browser/browser_accessibility_state.h"
29 #include "content/public/browser/browser_context.h" 29 #include "content/public/browser/browser_context.h"
30 #include "content/public/browser/browser_plugin_guest_manager.h" 30 #include "content/public/browser/browser_plugin_guest_manager.h"
31 #include "content/public/browser/media_session.h"
31 #include "content/public/browser/render_frame_host.h" 32 #include "content/public/browser/render_frame_host.h"
32 #include "content/public/browser/render_view_host.h" 33 #include "content/public/browser/render_view_host.h"
33 #include "content/public/browser/render_widget_host.h" 34 #include "content/public/browser/render_widget_host.h"
34 #include "content/public/browser/render_widget_host_view.h" 35 #include "content/public/browser/render_widget_host_view.h"
35 #include "content/public/browser/web_contents.h" 36 #include "content/public/browser/web_contents.h"
36 #include "content/public/browser/web_contents_observer.h" 37 #include "content/public/browser/web_contents_observer.h"
37 #include "content/public/browser/web_contents_user_data.h" 38 #include "content/public/browser/web_contents_user_data.h"
38 #include "extensions/common/extension_messages.h" 39 #include "extensions/common/extension_messages.h"
39 #include "extensions/common/permissions/permissions_data.h" 40 #include "extensions/common/permissions/permissions_data.h"
40 #include "ui/accessibility/ax_action_data.h" 41 #include "ui/accessibility/ax_action_data.h"
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
215 } 216 }
216 217
217 void RenderFrameDeleted( 218 void RenderFrameDeleted(
218 content::RenderFrameHost* render_frame_host) override { 219 content::RenderFrameHost* render_frame_host) override {
219 int tree_id = render_frame_host->GetAXTreeID(); 220 int tree_id = render_frame_host->GetAXTreeID();
220 AutomationEventRouter::GetInstance()->DispatchTreeDestroyedEvent( 221 AutomationEventRouter::GetInstance()->DispatchTreeDestroyedEvent(
221 tree_id, 222 tree_id,
222 browser_context_); 223 browser_context_);
223 } 224 }
224 225
226 void MediaStartedPlaying(const MediaPlayerInfo& video_type,
227 const MediaPlayerId& id) override {
dmazzoni 2016/12/02 17:01:43 nit: indentation
228 std::vector<content::AXEventNotificationDetails> details;
229 content::AXEventNotificationDetails detail;
230 detail.ax_tree_id = id.first->GetAXTreeID();
dmazzoni 2016/12/02 17:01:43 nit: extra space
231 detail.event_type = ui::AX_EVENT_MEDIA_STARTED_PLAYING;
232 details.push_back(detail);
233 AccessibilityEventReceived(details);
234 }
235
236 void MediaStoppedPlaying(const MediaPlayerInfo& video_type,
237 const MediaPlayerId& id) override {
dmazzoni 2016/12/02 17:01:43 same
238 std::vector<content::AXEventNotificationDetails> details;
239 content::AXEventNotificationDetails detail;
240 detail.ax_tree_id = id.first->GetAXTreeID();
dmazzoni 2016/12/02 17:01:43 same
241 detail.event_type = ui::AX_EVENT_MEDIA_STOPPED_PLAYING;
242 details.push_back(detail);
243 AccessibilityEventReceived(details);
244 }
245
225 private: 246 private:
226 friend class content::WebContentsUserData<AutomationWebContentsObserver>; 247 friend class content::WebContentsUserData<AutomationWebContentsObserver>;
227 248
228 explicit AutomationWebContentsObserver(content::WebContents* web_contents) 249 explicit AutomationWebContentsObserver(content::WebContents* web_contents)
229 : content::WebContentsObserver(web_contents), 250 : content::WebContentsObserver(web_contents),
230 browser_context_(web_contents->GetBrowserContext()) {} 251 browser_context_(web_contents->GetBrowserContext()) {}
231 252
232 content::BrowserContext* browser_context_; 253 content::BrowserContext* browser_context_;
233 254
234 DISALLOW_COPY_AND_ASSIGN(AutomationWebContentsObserver); 255 DISALLOW_COPY_AND_ASSIGN(AutomationWebContentsObserver);
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
327 NOTREACHED(); 348 NOTREACHED();
328 return RespondNow(Error("Unexpected action on desktop automation tree;" 349 return RespondNow(Error("Unexpected action on desktop automation tree;"
329 " platform does not support desktop automation")); 350 " platform does not support desktop automation"));
330 #endif // defined(USE_AURA) 351 #endif // defined(USE_AURA)
331 } 352 }
332 content::RenderFrameHost* rfh = 353 content::RenderFrameHost* rfh =
333 content::RenderFrameHost::FromAXTreeID(params->args.tree_id); 354 content::RenderFrameHost::FromAXTreeID(params->args.tree_id);
334 if (!rfh) 355 if (!rfh)
335 return RespondNow(Error("Ignoring action on destroyed node")); 356 return RespondNow(Error("Ignoring action on destroyed node"));
336 357
337 const content::WebContents* contents = 358 content::WebContents* contents =
338 content::WebContents::FromRenderFrameHost(rfh); 359 content::WebContents::FromRenderFrameHost(rfh);
339 if (!CanRequestAutomation(extension(), automation_info, contents)) { 360 if (!CanRequestAutomation(extension(), automation_info, contents)) {
340 return RespondNow( 361 return RespondNow(
341 Error(kCannotRequestAutomationOnPage, contents->GetURL().spec())); 362 Error(kCannotRequestAutomationOnPage, contents->GetURL().spec()));
342 } 363 }
343 364
365 // These actions are handled directly for the WebContents.
366 if (params->args.action_type ==
367 api::automation_internal::ACTION_TYPE_STARTDUCKING) {
368 content::MediaSession* session = content::MediaSession::Get(contents);
369 session->StartDucking();
370 return RespondNow(NoArguments());
371 } else if (params->args.action_type ==
372 api::automation_internal::ACTION_TYPE_STOPDUCKING) {
373 content::MediaSession* session = content::MediaSession::Get(contents);
374 session->StopDucking();
375 return RespondNow(NoArguments());
376 }
377
344 RenderFrameHostActionAdapter adapter(rfh); 378 RenderFrameHostActionAdapter adapter(rfh);
345 return RouteActionToAdapter(params.get(), &adapter); 379 return RouteActionToAdapter(params.get(), &adapter);
346 } 380 }
347 381
348 ExtensionFunction::ResponseAction 382 ExtensionFunction::ResponseAction
349 AutomationInternalPerformActionFunction::RouteActionToAdapter( 383 AutomationInternalPerformActionFunction::RouteActionToAdapter(
350 api::automation_internal::PerformAction::Params* params, 384 api::automation_internal::PerformAction::Params* params,
351 AutomationActionAdapter* adapter) { 385 AutomationActionAdapter* adapter) {
352 ui::AXActionData action; 386 ui::AXActionData action;
353 action.target_node_id = params->args.automation_node_id; 387 action.target_node_id = params->args.automation_node_id;
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
477 if (!error.empty()) { 511 if (!error.empty()) {
478 Respond(Error(error)); 512 Respond(Error(error));
479 return; 513 return;
480 } 514 }
481 515
482 Respond( 516 Respond(
483 OneArgument(base::MakeUnique<base::FundamentalValue>(result_acc_obj_id))); 517 OneArgument(base::MakeUnique<base::FundamentalValue>(result_acc_obj_id)));
484 } 518 }
485 519
486 } // namespace extensions 520 } // namespace extensions
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/resources/chromeos/chromevox/common/chrome_extension_externs.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698