Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(47)

Unified Diff: content/browser/frame_host/frame_tree.cc

Issue 1104603002: Pick frame to navigate in the browser process. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add test cases Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/browser/frame_host/frame_tree.h ('k') | content/browser/frame_host/frame_tree_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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;
}
« no previous file with comments | « content/browser/frame_host/frame_tree.h ('k') | content/browser/frame_host/frame_tree_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698