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

Unified Diff: content/renderer/render_frame_impl.cc

Issue 2714943004: Move unique name generation and tracking into //content. (Closed)
Patch Set: . Created 3 years, 10 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
Index: content/renderer/render_frame_impl.cc
diff --git a/content/renderer/render_frame_impl.cc b/content/renderer/render_frame_impl.cc
index 4af9b671725620814b3f5d10384a881f4c68d83a..3c665456418e58d5724984d1691542187cad115f 100644
--- a/content/renderer/render_frame_impl.cc
+++ b/content/renderer/render_frame_impl.cc
@@ -978,9 +978,10 @@ void RenderFrameImpl::CreateFrame(
render_frame =
RenderFrameImpl::Create(parent_proxy->render_view(), routing_id);
render_frame->InitializeBlameContext(FromRoutingID(parent_routing_id));
+ render_frame->unique_name_helper_.set_from_replicated_state(
+ replicated_state.unique_name);
web_frame = parent_web_frame->createLocalChild(
replicated_state.scope, WebString::fromUTF8(replicated_state.name),
- WebString::fromUTF8(replicated_state.unique_name),
replicated_state.sandbox_flags, render_frame,
render_frame->blink_interface_provider_.get(),
render_frame->blink_interface_registry_.get(),
@@ -1079,6 +1080,7 @@ blink::WebURL RenderFrameImpl::overrideFlashEmbedWithHTML(
RenderFrameImpl::RenderFrameImpl(const CreateParams& params)
: frame_(NULL),
is_main_frame_(true),
+ unique_name_helper_(this),
in_browser_initiated_detach_(false),
in_frame_tree_(false),
render_view_(params.render_view),
@@ -3019,7 +3021,7 @@ blink::WebLocalFrame* RenderFrameImpl::createChildFrame(
blink::WebLocalFrame* parent,
blink::WebTreeScopeType scope,
const blink::WebString& name,
- const blink::WebString& unique_name,
+ const blink::WebString& fallback_name,
blink::WebSandboxFlags sandbox_flags,
const blink::WebFrameOwnerProperties& frame_owner_properties) {
// Synchronously notify the browser of a child frame creation to get the
@@ -3029,7 +3031,9 @@ blink::WebLocalFrame* RenderFrameImpl::createChildFrame(
params.parent_routing_id = routing_id_;
params.scope = scope;
params.frame_name = name.utf8();
- params.frame_unique_name = unique_name.utf8();
+ params.frame_unique_name = UniqueNameHelper::GenerateNameForNewChildFrame(
+ parent,
+ params.frame_name.empty() ? fallback_name.utf8() : params.frame_name);
params.sandbox_flags = sandbox_flags;
params.frame_owner_properties =
ConvertWebFrameOwnerPropertiesToFrameOwnerProperties(
@@ -3054,6 +3058,8 @@ blink::WebLocalFrame* RenderFrameImpl::createChildFrame(
// Create the RenderFrame and WebLocalFrame, linking the two.
RenderFrameImpl* child_render_frame =
RenderFrameImpl::Create(render_view_, child_routing_id);
+ child_render_frame->unique_name_helper_.set_from_replicated_state(
+ params.frame_unique_name);
child_render_frame->InitializeBlameContext(this);
blink::WebLocalFrame* web_frame = WebLocalFrame::create(
scope, child_render_frame,
@@ -3164,10 +3170,11 @@ void RenderFrameImpl::willCommitProvisionalLoad(blink::WebLocalFrame* frame) {
observer.WillCommitProvisionalLoad();
}
-void RenderFrameImpl::didChangeName(const blink::WebString& name,
- const blink::WebString& unique_name) {
- Send(new FrameHostMsg_DidChangeName(
- routing_id_, name.utf8(), unique_name.utf8()));
+void RenderFrameImpl::didChangeName(const blink::WebString& name) {
+ if (!committed_first_load_)
+ unique_name_helper_.UpdateName(name.utf8());
+ Send(new FrameHostMsg_DidChangeName(routing_id_, name.utf8(),
+ unique_name_helper_.value()));
if (!committed_first_load_)
name_changed_before_first_commit_ = true;
@@ -3620,6 +3627,8 @@ void RenderFrameImpl::didCommitProvisionalLoad(
// Update the current history item for this frame (both in default Chrome and
// subframe FrameNavigationEntry modes).
current_history_item_ = item;
+ current_history_item_.setTarget(
+ blink::WebString::fromUTF8(unique_name_helper_.value()));
dcheng 2017/03/01 23:57:25 target should move out of WebHistoryItem, but doin
InternalDocumentStateData* internal_data =
InternalDocumentStateData::FromDocumentState(document_state);
@@ -5290,13 +5299,13 @@ WebNavigationPolicy RenderFrameImpl::decidePolicyForNavigation(
// just staying at the initial about:blank document.
bool should_ask_browser = false;
RenderFrameImpl* parent = RenderFrameImpl::FromWebFrame(frame_->parent());
- const auto& iter = parent->history_subframe_unique_names_.find(
- frame_->uniqueName().utf8());
+ auto iter = parent->history_subframe_unique_names_.find(
+ unique_name_helper_.value());
if (iter != parent->history_subframe_unique_names_.end()) {
bool history_item_is_about_blank = iter->second;
should_ask_browser =
!history_item_is_about_blank || url != url::kAboutBlankURL;
- parent->history_subframe_unique_names_.erase(frame_->uniqueName().utf8());
+ parent->history_subframe_unique_names_.erase(iter);
}
if (should_ask_browser) {

Powered by Google App Engine
This is Rietveld 408576698