Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 "content/browser/frame_host/frame_accessibility.h" | 5 #include "content/browser/frame_host/frame_accessibility.h" |
| 6 | 6 |
| 7 #include "content/browser/frame_host/frame_tree.h" | 7 #include "content/browser/frame_host/frame_tree.h" |
| 8 #include "content/browser/frame_host/frame_tree_node.h" | 8 #include "content/browser/frame_host/frame_tree_node.h" |
| 9 #include "content/browser/frame_host/render_frame_host_delegate.h" | 9 #include "content/browser/frame_host/render_frame_host_delegate.h" |
| 10 #include "content/browser/frame_host/render_frame_host_impl.h" | 10 #include "content/browser/frame_host/render_frame_host_impl.h" |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 98 int accessibility_node_id) { | 98 int accessibility_node_id) { |
| 99 for (std::vector<ChildFrameMapping>::iterator iter = mappings_.begin(); | 99 for (std::vector<ChildFrameMapping>::iterator iter = mappings_.begin(); |
| 100 iter != mappings_.end(); | 100 iter != mappings_.end(); |
| 101 ++iter) { | 101 ++iter) { |
| 102 if (iter->parent_frame_host != parent_frame_host || | 102 if (iter->parent_frame_host != parent_frame_host || |
| 103 iter->accessibility_node_id != accessibility_node_id) { | 103 iter->accessibility_node_id != accessibility_node_id) { |
| 104 continue; | 104 continue; |
| 105 } | 105 } |
| 106 | 106 |
| 107 if (iter->child_frame_tree_node_id) { | 107 if (iter->child_frame_tree_node_id) { |
| 108 FrameTreeNode* child_node = | 108 return GetRFHIFromFrameTreeNodeId( |
| 109 FrameTree::GloballyFindByID(iter->child_frame_tree_node_id); | 109 parent_frame_host, iter->child_frame_tree_node_id); |
| 110 if (!child_node) | |
| 111 return NULL; | |
| 112 | 110 |
| 113 // We should have gotten a node in the same frame tree. | |
| 114 if (child_node->frame_tree() != | |
| 115 parent_frame_host->frame_tree_node()->frame_tree()) { | |
| 116 NOTREACHED(); | |
| 117 return NULL; | |
| 118 } | |
| 119 | |
| 120 return child_node->current_frame_host(); | |
| 121 } | 111 } |
| 122 | 112 |
| 123 if (iter->browser_plugin_instance_id) { | 113 if (iter->browser_plugin_instance_id) { |
| 124 RenderFrameHost* guest = | 114 RenderFrameHost* guest = |
| 125 parent_frame_host->delegate()->GetGuestByInstanceID( | 115 parent_frame_host->delegate()->GetGuestByInstanceID( |
| 126 iter->browser_plugin_instance_id); | 116 iter->browser_plugin_instance_id); |
| 127 if (guest) | 117 if (guest) |
| 128 return static_cast<RenderFrameHostImpl*>(guest); | 118 return static_cast<RenderFrameHostImpl*>(guest); |
| 129 } | 119 } |
| 130 } | 120 } |
| 131 | 121 |
| 132 return NULL; | 122 return NULL; |
| 133 } | 123 } |
| 134 | 124 |
| 125 void FrameAccessibility::GetAllChildFrames( | |
| 126 RenderFrameHostImpl* parent_frame_host, | |
| 127 std::vector<RenderFrameHostImpl*>* child_frame_hosts) { | |
| 128 CHECK(child_frame_hosts); | |
| 129 | |
| 130 for (std::vector<ChildFrameMapping>::iterator iter = mappings_.begin(); | |
| 131 iter != mappings_.end(); | |
| 132 ++iter) { | |
| 133 if (iter->parent_frame_host != parent_frame_host) | |
| 134 continue; | |
| 135 | |
| 136 if (iter->child_frame_tree_node_id) { | |
| 137 RenderFrameHostImpl* child_frame_host = GetRFHIFromFrameTreeNodeId( | |
| 138 parent_frame_host, iter->child_frame_tree_node_id); | |
| 139 if (child_frame_host) | |
| 140 child_frame_hosts->push_back(child_frame_host); | |
| 141 } | |
| 142 | |
| 143 if (iter->browser_plugin_instance_id) { | |
| 144 RenderFrameHost* guest = | |
| 145 parent_frame_host->delegate()->GetGuestByInstanceID( | |
| 146 iter->browser_plugin_instance_id); | |
| 147 if (guest) | |
| 148 child_frame_hosts->push_back(static_cast<RenderFrameHostImpl*>(guest)); | |
| 149 } | |
| 150 } | |
| 151 } | |
| 152 | |
| 135 bool FrameAccessibility::GetParent( | 153 bool FrameAccessibility::GetParent( |
| 136 RenderFrameHostImpl* child_frame_host, | 154 RenderFrameHostImpl* child_frame_host, |
| 137 RenderFrameHostImpl** out_parent_frame_host, | 155 RenderFrameHostImpl** out_parent_frame_host, |
| 138 int* out_accessibility_node_id) { | 156 int* out_accessibility_node_id) { |
| 139 for (std::vector<ChildFrameMapping>::iterator iter = mappings_.begin(); | 157 for (std::vector<ChildFrameMapping>::iterator iter = mappings_.begin(); |
| 140 iter != mappings_.end(); | 158 iter != mappings_.end(); |
| 141 ++iter) { | 159 ++iter) { |
| 142 if (iter->child_frame_tree_node_id) { | 160 if (iter->child_frame_tree_node_id) { |
| 143 FrameTreeNode* child_node = | 161 FrameTreeNode* child_node = |
| 144 FrameTree::GloballyFindByID(iter->child_frame_tree_node_id); | 162 FrameTree::GloballyFindByID(iter->child_frame_tree_node_id); |
| (...skipping 24 matching lines...) Expand all Loading... | |
| 169 if (out_accessibility_node_id) | 187 if (out_accessibility_node_id) |
| 170 *out_accessibility_node_id = iter->accessibility_node_id; | 188 *out_accessibility_node_id = iter->accessibility_node_id; |
| 171 return true; | 189 return true; |
| 172 } | 190 } |
| 173 } | 191 } |
| 174 } | 192 } |
| 175 | 193 |
| 176 return false; | 194 return false; |
| 177 } | 195 } |
| 178 | 196 |
| 197 RenderFrameHostImpl* FrameAccessibility::GetRFHIFromFrameTreeNodeId( | |
| 198 RenderFrameHostImpl* parent_frame_host, | |
| 199 int64 child_frame_tree_node_id) { | |
| 200 FrameTreeNode* child_node = | |
| 201 FrameTree::GloballyFindByID(child_frame_tree_node_id); | |
| 202 if (!child_node) | |
| 203 return NULL; | |
|
nasko
2015/01/15 21:44:38
s/NULL/nullptr/
dmazzoni
2015/01/15 23:09:22
Done.
| |
| 204 | |
| 205 // We should have gotten a node in the same frame tree. | |
| 206 if (child_node->frame_tree() != | |
| 207 parent_frame_host->frame_tree_node()->frame_tree()) { | |
| 208 NOTREACHED(); | |
| 209 return NULL; | |
|
nasko
2015/01/15 21:44:38
s/NULL/nullptr/
dmazzoni
2015/01/15 23:09:22
Done.
| |
| 210 } | |
| 211 | |
| 212 return child_node->current_frame_host(); | |
|
nasko
2015/01/15 21:44:38
There is no verification that the frame found is a
dmazzoni
2015/01/15 23:09:22
True. Note that this is not new logic, I just refa
nasko
2015/01/16 00:20:33
Yeah, I saw it is just moved, but it is useful to
| |
| 213 } | |
| 214 | |
| 179 } // namespace content | 215 } // namespace content |
| OLD | NEW |