OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "content/browser/frame_host/render_frame_host_impl.h" | 5 #include "content/browser/frame_host/render_frame_host_impl.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/containers/hash_tables.h" | 9 #include "base/containers/hash_tables.h" |
10 #include "base/lazy_instance.h" | 10 #include "base/lazy_instance.h" |
(...skipping 434 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
445 render_view_host_->GetView()); | 445 render_view_host_->GetView()); |
446 if (view) | 446 if (view) |
447 return view->AccessibilityGetNativeViewAccessible(); | 447 return view->AccessibilityGetNativeViewAccessible(); |
448 return NULL; | 448 return NULL; |
449 } | 449 } |
450 | 450 |
451 BrowserAccessibilityManager* RenderFrameHostImpl::AccessibilityGetChildFrame( | 451 BrowserAccessibilityManager* RenderFrameHostImpl::AccessibilityGetChildFrame( |
452 int accessibility_node_id) { | 452 int accessibility_node_id) { |
453 RenderFrameHostImpl* child_frame = | 453 RenderFrameHostImpl* child_frame = |
454 FrameAccessibility::GetInstance()->GetChild(this, accessibility_node_id); | 454 FrameAccessibility::GetInstance()->GetChild(this, accessibility_node_id); |
455 if (!child_frame) | 455 if (!child_frame || IsSameSiteInstance(child_frame)) |
456 return NULL; | 456 return nullptr; |
457 | |
458 // Return NULL if this isn't an out-of-process iframe. Same-process iframes | |
459 // are already part of the accessibility tree. | |
460 if (child_frame->GetProcess()->GetID() == GetProcess()->GetID()) | |
461 return NULL; | |
462 | |
463 // As a sanity check, make sure the frame we're going to return belongs | |
464 // to the same BrowserContext. | |
465 if (GetSiteInstance()->GetBrowserContext() != | |
466 child_frame->GetSiteInstance()->GetBrowserContext()) { | |
467 NOTREACHED(); | |
468 return NULL; | |
469 } | |
470 | 457 |
471 return child_frame->GetOrCreateBrowserAccessibilityManager(); | 458 return child_frame->GetOrCreateBrowserAccessibilityManager(); |
472 } | 459 } |
473 | 460 |
| 461 void RenderFrameHostImpl::AccessibilityGetAllChildFrames( |
| 462 std::vector<BrowserAccessibilityManager*>* child_frames) { |
| 463 std::vector<RenderFrameHostImpl*> child_frame_hosts; |
| 464 FrameAccessibility::GetInstance()->GetAllChildFrames( |
| 465 this, &child_frame_hosts); |
| 466 for (size_t i = 0; i < child_frame_hosts.size(); ++i) { |
| 467 RenderFrameHostImpl* child_frame_host = child_frame_hosts[i]; |
| 468 if (!child_frame_host || IsSameSiteInstance(child_frame_host)) |
| 469 continue; |
| 470 |
| 471 BrowserAccessibilityManager* manager = |
| 472 child_frame_host->GetOrCreateBrowserAccessibilityManager(); |
| 473 if (manager) |
| 474 child_frames->push_back(manager); |
| 475 } |
| 476 } |
| 477 |
474 BrowserAccessibility* RenderFrameHostImpl::AccessibilityGetParentFrame() { | 478 BrowserAccessibility* RenderFrameHostImpl::AccessibilityGetParentFrame() { |
475 RenderFrameHostImpl* parent_frame = NULL; | 479 RenderFrameHostImpl* parent_frame = NULL; |
476 int parent_node_id = 0; | 480 int parent_node_id = 0; |
477 if (!FrameAccessibility::GetInstance()->GetParent( | 481 if (!FrameAccessibility::GetInstance()->GetParent( |
478 this, &parent_frame, &parent_node_id)) { | 482 this, &parent_frame, &parent_node_id)) { |
479 return NULL; | 483 return NULL; |
480 } | 484 } |
481 | 485 |
482 // As a sanity check, make sure the frame we're going to return belongs | 486 // As a sanity check, make sure the frame we're going to return belongs |
483 // to the same BrowserContext. | 487 // to the same BrowserContext. |
(...skipping 990 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1474 for (const auto& iter : node_to_browser_plugin_instance_id_map) { | 1478 for (const auto& iter : node_to_browser_plugin_instance_id_map) { |
1475 // This is the id of the accessibility node that hosts a plugin. | 1479 // This is the id of the accessibility node that hosts a plugin. |
1476 int32 node_id = iter.first; | 1480 int32 node_id = iter.first; |
1477 // The id of the browser plugin. | 1481 // The id of the browser plugin. |
1478 int browser_plugin_instance_id = iter.second; | 1482 int browser_plugin_instance_id = iter.second; |
1479 FrameAccessibility::GetInstance()->AddGuestWebContents( | 1483 FrameAccessibility::GetInstance()->AddGuestWebContents( |
1480 this, node_id, browser_plugin_instance_id); | 1484 this, node_id, browser_plugin_instance_id); |
1481 } | 1485 } |
1482 } | 1486 } |
1483 | 1487 |
| 1488 bool RenderFrameHostImpl::IsSameSiteInstance( |
| 1489 RenderFrameHostImpl* other_render_frame_host) { |
| 1490 // As a sanity check, make sure the frame belongs to the same BrowserContext. |
| 1491 CHECK_EQ(GetSiteInstance()->GetBrowserContext(), |
| 1492 child_frame->GetSiteInstance()->GetBrowserContext()); |
| 1493 return GetSiteInstance() == other_render_frame_host->GetSiteInstance(); |
| 1494 } |
| 1495 |
1484 void RenderFrameHostImpl::SetAccessibilityMode(AccessibilityMode mode) { | 1496 void RenderFrameHostImpl::SetAccessibilityMode(AccessibilityMode mode) { |
1485 Send(new FrameMsg_SetAccessibilityMode(routing_id_, mode)); | 1497 Send(new FrameMsg_SetAccessibilityMode(routing_id_, mode)); |
1486 } | 1498 } |
1487 | 1499 |
1488 void RenderFrameHostImpl::SetAccessibilityCallbackForTesting( | 1500 void RenderFrameHostImpl::SetAccessibilityCallbackForTesting( |
1489 const base::Callback<void(ui::AXEvent, int)>& callback) { | 1501 const base::Callback<void(ui::AXEvent, int)>& callback) { |
1490 accessibility_testing_callback_ = callback; | 1502 accessibility_testing_callback_ = callback; |
1491 } | 1503 } |
1492 | 1504 |
1493 const ui::AXTree* RenderFrameHostImpl::GetAXTreeForTesting() { | 1505 const ui::AXTree* RenderFrameHostImpl::GetAXTreeForTesting() { |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1614 void RenderFrameHostImpl::DidUseGeolocationPermission() { | 1626 void RenderFrameHostImpl::DidUseGeolocationPermission() { |
1615 RenderFrameHost* top_frame = frame_tree_node()->frame_tree()->GetMainFrame(); | 1627 RenderFrameHost* top_frame = frame_tree_node()->frame_tree()->GetMainFrame(); |
1616 GetContentClient()->browser()->RegisterPermissionUsage( | 1628 GetContentClient()->browser()->RegisterPermissionUsage( |
1617 PERMISSION_GEOLOCATION, | 1629 PERMISSION_GEOLOCATION, |
1618 delegate_->GetAsWebContents(), | 1630 delegate_->GetAsWebContents(), |
1619 GetLastCommittedURL().GetOrigin(), | 1631 GetLastCommittedURL().GetOrigin(), |
1620 top_frame->GetLastCommittedURL().GetOrigin()); | 1632 top_frame->GetLastCommittedURL().GetOrigin()); |
1621 } | 1633 } |
1622 | 1634 |
1623 } // namespace content | 1635 } // namespace content |
OLD | NEW |