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 986 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1470 for (const auto& iter : node_to_browser_plugin_instance_id_map) { | 1474 for (const auto& iter : node_to_browser_plugin_instance_id_map) { |
1471 // This is the id of the accessibility node that hosts a plugin. | 1475 // This is the id of the accessibility node that hosts a plugin. |
1472 int32 node_id = iter.first; | 1476 int32 node_id = iter.first; |
1473 // The id of the browser plugin. | 1477 // The id of the browser plugin. |
1474 int browser_plugin_instance_id = iter.second; | 1478 int browser_plugin_instance_id = iter.second; |
1475 FrameAccessibility::GetInstance()->AddGuestWebContents( | 1479 FrameAccessibility::GetInstance()->AddGuestWebContents( |
1476 this, node_id, browser_plugin_instance_id); | 1480 this, node_id, browser_plugin_instance_id); |
1477 } | 1481 } |
1478 } | 1482 } |
1479 | 1483 |
1484 bool RenderFrameHostImpl::IsSameSiteInstance(RenderFrameHostImpl* child_frame) { | |
nasko
2015/01/16 00:20:33
nit: s/child_frame/render_frame_host/
Nothing in
dmazzoni
2015/01/16 17:44:56
Done.
| |
1485 // As a sanity check, make sure the frame belongs to the same BrowserContext. | |
1486 CHECK_EQ(GetSiteInstance()->GetBrowserContext(), | |
1487 child_frame->GetSiteInstance()->GetBrowserContext()); | |
1488 return GetSiteInstance() == child_frame->GetSiteInstance(); | |
1489 } | |
1490 | |
1480 void RenderFrameHostImpl::SetAccessibilityMode(AccessibilityMode mode) { | 1491 void RenderFrameHostImpl::SetAccessibilityMode(AccessibilityMode mode) { |
1481 Send(new FrameMsg_SetAccessibilityMode(routing_id_, mode)); | 1492 Send(new FrameMsg_SetAccessibilityMode(routing_id_, mode)); |
1482 } | 1493 } |
1483 | 1494 |
1484 void RenderFrameHostImpl::SetAccessibilityCallbackForTesting( | 1495 void RenderFrameHostImpl::SetAccessibilityCallbackForTesting( |
1485 const base::Callback<void(ui::AXEvent, int)>& callback) { | 1496 const base::Callback<void(ui::AXEvent, int)>& callback) { |
1486 accessibility_testing_callback_ = callback; | 1497 accessibility_testing_callback_ = callback; |
1487 } | 1498 } |
1488 | 1499 |
1489 const ui::AXTree* RenderFrameHostImpl::GetAXTreeForTesting() { | 1500 const ui::AXTree* RenderFrameHostImpl::GetAXTreeForTesting() { |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1610 void RenderFrameHostImpl::DidUseGeolocationPermission() { | 1621 void RenderFrameHostImpl::DidUseGeolocationPermission() { |
1611 RenderFrameHost* top_frame = frame_tree_node()->frame_tree()->GetMainFrame(); | 1622 RenderFrameHost* top_frame = frame_tree_node()->frame_tree()->GetMainFrame(); |
1612 GetContentClient()->browser()->RegisterPermissionUsage( | 1623 GetContentClient()->browser()->RegisterPermissionUsage( |
1613 PERMISSION_GEOLOCATION, | 1624 PERMISSION_GEOLOCATION, |
1614 delegate_->GetAsWebContents(), | 1625 delegate_->GetAsWebContents(), |
1615 GetLastCommittedURL().GetOrigin(), | 1626 GetLastCommittedURL().GetOrigin(), |
1616 top_frame->GetLastCommittedURL().GetOrigin()); | 1627 top_frame->GetLastCommittedURL().GetOrigin()); |
1617 } | 1628 } |
1618 | 1629 |
1619 } // namespace content | 1630 } // namespace content |
OLD | NEW |