Chromium Code Reviews| 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 || |
| 456 return NULL; | 456 !IsOutOfProcessFrameInSameBrowserContext(child_frame)) { |
| 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; | 457 return NULL; |
| 469 } | 458 } |
| 470 | 459 |
| 471 return child_frame->GetOrCreateBrowserAccessibilityManager(); | 460 return child_frame->GetOrCreateBrowserAccessibilityManager(); |
| 472 } | 461 } |
| 473 | 462 |
| 463 void RenderFrameHostImpl::AccessibilityGetAllChildFrames( | |
| 464 std::vector<BrowserAccessibilityManager*>* child_frames) { | |
| 465 std::vector<RenderFrameHostImpl*> child_frame_hosts; | |
| 466 FrameAccessibility::GetInstance()->GetAllChildFrames( | |
| 467 this, &child_frame_hosts); | |
| 468 for (size_t i = 0; i < child_frame_hosts.size(); ++i) { | |
| 469 RenderFrameHostImpl* child_frame_host = child_frame_hosts[i]; | |
| 470 if (!child_frame_host || | |
| 471 !IsOutOfProcessFrameInSameBrowserContext(child_frame_host)) { | |
| 472 continue; | |
| 473 } | |
| 474 | |
| 475 BrowserAccessibilityManager* manager = | |
| 476 child_frame_host->GetOrCreateBrowserAccessibilityManager(); | |
| 477 if (manager) | |
| 478 child_frames->push_back(manager); | |
| 479 } | |
| 480 } | |
| 481 | |
| 474 BrowserAccessibility* RenderFrameHostImpl::AccessibilityGetParentFrame() { | 482 BrowserAccessibility* RenderFrameHostImpl::AccessibilityGetParentFrame() { |
| 475 RenderFrameHostImpl* parent_frame = NULL; | 483 RenderFrameHostImpl* parent_frame = NULL; |
| 476 int parent_node_id = 0; | 484 int parent_node_id = 0; |
| 477 if (!FrameAccessibility::GetInstance()->GetParent( | 485 if (!FrameAccessibility::GetInstance()->GetParent( |
| 478 this, &parent_frame, &parent_node_id)) { | 486 this, &parent_frame, &parent_node_id)) { |
| 479 return NULL; | 487 return NULL; |
| 480 } | 488 } |
| 481 | 489 |
| 482 // As a sanity check, make sure the frame we're going to return belongs | 490 // As a sanity check, make sure the frame we're going to return belongs |
| 483 // to the same BrowserContext. | 491 // 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) { | 1478 for (const auto& iter : node_to_browser_plugin_instance_id_map) { |
| 1471 // 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. |
| 1472 int32 node_id = iter.first; | 1480 int32 node_id = iter.first; |
| 1473 // The id of the browser plugin. | 1481 // The id of the browser plugin. |
| 1474 int browser_plugin_instance_id = iter.second; | 1482 int browser_plugin_instance_id = iter.second; |
| 1475 FrameAccessibility::GetInstance()->AddGuestWebContents( | 1483 FrameAccessibility::GetInstance()->AddGuestWebContents( |
| 1476 this, node_id, browser_plugin_instance_id); | 1484 this, node_id, browser_plugin_instance_id); |
| 1477 } | 1485 } |
| 1478 } | 1486 } |
| 1479 | 1487 |
| 1488 bool RenderFrameHostImpl::IsOutOfProcessFrameInSameBrowserContext( | |
|
nasko
2015/01/15 21:44:38
The name is a bit too long and confusing. What abo
dmazzoni
2015/01/15 23:09:22
Done.
| |
| 1489 RenderFrameHostImpl* child_frame) { | |
|
nasko
2015/01/15 21:44:38
This method doesn't really check if child_frame is
dmazzoni
2015/01/15 23:09:23
Is it better now that it's called IsSameSiteInstan
| |
| 1490 if (child_frame->GetProcess()->GetID() == GetProcess()->GetID()) | |
|
nasko
2015/01/15 21:44:38
This check doesn't seem semantically correct. We i
dmazzoni
2015/01/15 23:09:22
Got it - so all that matters is if it's the same S
nasko
2015/01/16 00:20:33
Yes, indeed.
| |
| 1491 return false; | |
| 1492 | |
| 1493 // As a sanity check, make sure the frame belongs to the same BrowserContext. | |
| 1494 if (GetSiteInstance()->GetBrowserContext() != | |
|
nasko
2015/01/15 21:44:38
If this ever fails, we have really really bad prob
dmazzoni
2015/01/15 23:09:22
Done.
| |
| 1495 child_frame->GetSiteInstance()->GetBrowserContext()) { | |
| 1496 NOTREACHED(); | |
| 1497 return false; | |
| 1498 } | |
| 1499 | |
| 1500 return true; | |
| 1501 } | |
| 1502 | |
| 1480 void RenderFrameHostImpl::SetAccessibilityMode(AccessibilityMode mode) { | 1503 void RenderFrameHostImpl::SetAccessibilityMode(AccessibilityMode mode) { |
| 1481 Send(new FrameMsg_SetAccessibilityMode(routing_id_, mode)); | 1504 Send(new FrameMsg_SetAccessibilityMode(routing_id_, mode)); |
| 1482 } | 1505 } |
| 1483 | 1506 |
| 1484 void RenderFrameHostImpl::SetAccessibilityCallbackForTesting( | 1507 void RenderFrameHostImpl::SetAccessibilityCallbackForTesting( |
| 1485 const base::Callback<void(ui::AXEvent, int)>& callback) { | 1508 const base::Callback<void(ui::AXEvent, int)>& callback) { |
| 1486 accessibility_testing_callback_ = callback; | 1509 accessibility_testing_callback_ = callback; |
| 1487 } | 1510 } |
| 1488 | 1511 |
| 1489 const ui::AXTree* RenderFrameHostImpl::GetAXTreeForTesting() { | 1512 const ui::AXTree* RenderFrameHostImpl::GetAXTreeForTesting() { |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1610 void RenderFrameHostImpl::DidUseGeolocationPermission() { | 1633 void RenderFrameHostImpl::DidUseGeolocationPermission() { |
| 1611 RenderFrameHost* top_frame = frame_tree_node()->frame_tree()->GetMainFrame(); | 1634 RenderFrameHost* top_frame = frame_tree_node()->frame_tree()->GetMainFrame(); |
| 1612 GetContentClient()->browser()->RegisterPermissionUsage( | 1635 GetContentClient()->browser()->RegisterPermissionUsage( |
| 1613 PERMISSION_GEOLOCATION, | 1636 PERMISSION_GEOLOCATION, |
| 1614 delegate_->GetAsWebContents(), | 1637 delegate_->GetAsWebContents(), |
| 1615 GetLastCommittedURL().GetOrigin(), | 1638 GetLastCommittedURL().GetOrigin(), |
| 1616 top_frame->GetLastCommittedURL().GetOrigin()); | 1639 top_frame->GetLastCommittedURL().GetOrigin()); |
| 1617 } | 1640 } |
| 1618 | 1641 |
| 1619 } // namespace content | 1642 } // namespace content |
| OLD | NEW |