Index: content/browser/frame_host/frame_tree.cc |
diff --git a/content/browser/frame_host/frame_tree.cc b/content/browser/frame_host/frame_tree.cc |
index 332524e76e3e87905a9fcad3edee45b66372355e..1f63688d10a3a59e9114a01ccd3caae1fe393252 100644 |
--- a/content/browser/frame_host/frame_tree.cc |
+++ b/content/browser/frame_host/frame_tree.cc |
@@ -23,7 +23,7 @@ namespace content { |
namespace { |
// Used with FrameTree::ForEach() to search for the FrameTreeNode |
-// corresponding to |frame_tree_node_id| whithin a specific FrameTree. |
+// corresponding to |frame_tree_node_id| within a specific FrameTree. |
bool FrameTreeNodeForId(int64 frame_tree_node_id, |
FrameTreeNode** out_node, |
FrameTreeNode* node) { |
@@ -35,6 +35,19 @@ bool FrameTreeNodeForId(int64 frame_tree_node_id, |
return true; |
} |
+// Used with FrameTree::ForEach() to search for the FrameTreeNode with the given |
+// |name| within a specific FrameTree. |
+bool FrameTreeNodeForName(const std::string& name, |
+ FrameTreeNode** out_node, |
+ FrameTreeNode* node) { |
+ if (node->frame_name() == name) { |
+ *out_node = node; |
+ // Terminate iteration once the node has been found. |
+ return false; |
+ } |
+ return true; |
+} |
+ |
bool CreateProxyForSiteInstance(const scoped_refptr<SiteInstance>& instance, |
FrameTreeNode* node) { |
// If a new frame is created in the current SiteInstance, other frames in |
@@ -104,7 +117,7 @@ FrameTree::~FrameTree() { |
} |
FrameTreeNode* FrameTree::FindByID(int64 frame_tree_node_id) { |
- FrameTreeNode* node = NULL; |
+ FrameTreeNode* node = nullptr; |
ForEach(base::Bind(&FrameTreeNodeForId, frame_tree_node_id, &node)); |
return node; |
} |
@@ -126,12 +139,21 @@ FrameTreeNode* FrameTree::FindByRoutingID(int process_id, int routing_id) { |
return result; |
} |
- return NULL; |
+ return nullptr; |
+} |
+ |
+FrameTreeNode* FrameTree::FindByName(const std::string& name) { |
+ if (name.empty()) |
+ return root_.get(); |
+ |
+ FrameTreeNode* node = nullptr; |
+ ForEach(base::Bind(&FrameTreeNodeForName, name, &node)); |
+ return node; |
} |
void FrameTree::ForEach( |
const base::Callback<bool(FrameTreeNode*)>& on_node) const { |
- ForEach(on_node, NULL); |
+ ForEach(on_node, nullptr); |
} |
void FrameTree::ForEach( |
@@ -277,7 +299,7 @@ RenderViewHostImpl* FrameTree::GetRenderViewHost(SiteInstance* site_instance) { |
render_view_host_map_.find(site_instance->GetId()); |
// TODO(creis): Mirror the frame tree so this check can't fail. |
if (iter == render_view_host_map_.end()) |
- return NULL; |
+ return nullptr; |
return iter->second; |
} |