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 994 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1478 for (const auto& iter : node_to_browser_plugin_instance_id_map) { | 1482 for (const auto& iter : node_to_browser_plugin_instance_id_map) { |
1479 // This is the id of the accessibility node that hosts a plugin. | 1483 // This is the id of the accessibility node that hosts a plugin. |
1480 int32 node_id = iter.first; | 1484 int32 node_id = iter.first; |
1481 // The id of the browser plugin. | 1485 // The id of the browser plugin. |
1482 int browser_plugin_instance_id = iter.second; | 1486 int browser_plugin_instance_id = iter.second; |
1483 FrameAccessibility::GetInstance()->AddGuestWebContents( | 1487 FrameAccessibility::GetInstance()->AddGuestWebContents( |
1484 this, node_id, browser_plugin_instance_id); | 1488 this, node_id, browser_plugin_instance_id); |
1485 } | 1489 } |
1486 } | 1490 } |
1487 | 1491 |
| 1492 bool RenderFrameHostImpl::IsSameSiteInstance( |
| 1493 RenderFrameHostImpl* other_render_frame_host) { |
| 1494 // As a sanity check, make sure the frame belongs to the same BrowserContext. |
| 1495 CHECK_EQ(GetSiteInstance()->GetBrowserContext(), |
| 1496 other_render_frame_host->GetSiteInstance()->GetBrowserContext()); |
| 1497 return GetSiteInstance() == other_render_frame_host->GetSiteInstance(); |
| 1498 } |
| 1499 |
1488 void RenderFrameHostImpl::SetAccessibilityMode(AccessibilityMode mode) { | 1500 void RenderFrameHostImpl::SetAccessibilityMode(AccessibilityMode mode) { |
1489 Send(new FrameMsg_SetAccessibilityMode(routing_id_, mode)); | 1501 Send(new FrameMsg_SetAccessibilityMode(routing_id_, mode)); |
1490 } | 1502 } |
1491 | 1503 |
1492 void RenderFrameHostImpl::SetAccessibilityCallbackForTesting( | 1504 void RenderFrameHostImpl::SetAccessibilityCallbackForTesting( |
1493 const base::Callback<void(ui::AXEvent, int)>& callback) { | 1505 const base::Callback<void(ui::AXEvent, int)>& callback) { |
1494 accessibility_testing_callback_ = callback; | 1506 accessibility_testing_callback_ = callback; |
1495 } | 1507 } |
1496 | 1508 |
1497 const ui::AXTree* RenderFrameHostImpl::GetAXTreeForTesting() { | 1509 const ui::AXTree* RenderFrameHostImpl::GetAXTreeForTesting() { |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1618 void RenderFrameHostImpl::DidUseGeolocationPermission() { | 1630 void RenderFrameHostImpl::DidUseGeolocationPermission() { |
1619 RenderFrameHost* top_frame = frame_tree_node()->frame_tree()->GetMainFrame(); | 1631 RenderFrameHost* top_frame = frame_tree_node()->frame_tree()->GetMainFrame(); |
1620 GetContentClient()->browser()->RegisterPermissionUsage( | 1632 GetContentClient()->browser()->RegisterPermissionUsage( |
1621 PERMISSION_GEOLOCATION, | 1633 PERMISSION_GEOLOCATION, |
1622 delegate_->GetAsWebContents(), | 1634 delegate_->GetAsWebContents(), |
1623 GetLastCommittedURL().GetOrigin(), | 1635 GetLastCommittedURL().GetOrigin(), |
1624 top_frame->GetLastCommittedURL().GetOrigin()); | 1636 top_frame->GetLastCommittedURL().GetOrigin()); |
1625 } | 1637 } |
1626 | 1638 |
1627 } // namespace content | 1639 } // namespace content |
OLD | NEW |