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

Side by Side Diff: content/renderer/render_frame_impl.cc

Issue 562603002: Move PageTransition from //content/public/common to //ui/base (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 6 years, 3 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 unified diff | Download patch
OLDNEW
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/renderer/render_frame_impl.h" 5 #include "content/renderer/render_frame_impl.h"
6 6
7 #include <map> 7 #include <map>
8 #include <string> 8 #include <string>
9 9
10 #include "base/auto_reset.h" 10 #include "base/auto_reset.h"
(...skipping 1921 matching lines...) Expand 10 before | Expand all | Expand 10 after
1932 1932
1933 void RenderFrameImpl::willSubmitForm(blink::WebLocalFrame* frame, 1933 void RenderFrameImpl::willSubmitForm(blink::WebLocalFrame* frame,
1934 const blink::WebFormElement& form) { 1934 const blink::WebFormElement& form) {
1935 DCHECK(!frame_ || frame_ == frame); 1935 DCHECK(!frame_ || frame_ == frame);
1936 DocumentState* document_state = 1936 DocumentState* document_state =
1937 DocumentState::FromDataSource(frame->provisionalDataSource()); 1937 DocumentState::FromDataSource(frame->provisionalDataSource());
1938 NavigationState* navigation_state = document_state->navigation_state(); 1938 NavigationState* navigation_state = document_state->navigation_state();
1939 InternalDocumentStateData* internal_data = 1939 InternalDocumentStateData* internal_data =
1940 InternalDocumentStateData::FromDocumentState(document_state); 1940 InternalDocumentStateData::FromDocumentState(document_state);
1941 1941
1942 if (PageTransitionCoreTypeIs(navigation_state->transition_type(), 1942 if (ui::PageTransitionCoreTypeIs(navigation_state->transition_type(),
1943 PAGE_TRANSITION_LINK)) { 1943 ui::PAGE_TRANSITION_LINK)) {
1944 navigation_state->set_transition_type(PAGE_TRANSITION_FORM_SUBMIT); 1944 navigation_state->set_transition_type(ui::PAGE_TRANSITION_FORM_SUBMIT);
1945 } 1945 }
1946 1946
1947 // Save these to be processed when the ensuing navigation is committed. 1947 // Save these to be processed when the ensuing navigation is committed.
1948 WebSearchableFormData web_searchable_form_data(form); 1948 WebSearchableFormData web_searchable_form_data(form);
1949 internal_data->set_searchable_form_url(web_searchable_form_data.url()); 1949 internal_data->set_searchable_form_url(web_searchable_form_data.url());
1950 internal_data->set_searchable_form_encoding( 1950 internal_data->set_searchable_form_encoding(
1951 web_searchable_form_data.encoding().utf8()); 1951 web_searchable_form_data.encoding().utf8());
1952 1952
1953 FOR_EACH_OBSERVER(RenderViewObserver, render_view_->observers(), 1953 FOR_EACH_OBSERVER(RenderViewObserver, render_view_->observers(),
1954 WillSubmitForm(frame, form)); 1954 WillSubmitForm(frame, form));
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
2007 bool is_top_most = !frame->parent(); 2007 bool is_top_most = !frame->parent();
2008 if (is_top_most) { 2008 if (is_top_most) {
2009 render_view_->set_navigation_gesture( 2009 render_view_->set_navigation_gesture(
2010 WebUserGestureIndicator::isProcessingUserGesture() ? 2010 WebUserGestureIndicator::isProcessingUserGesture() ?
2011 NavigationGestureUser : NavigationGestureAuto); 2011 NavigationGestureUser : NavigationGestureAuto);
2012 } else if (ds->replacesCurrentHistoryItem()) { 2012 } else if (ds->replacesCurrentHistoryItem()) {
2013 // Subframe navigations that don't add session history items must be 2013 // Subframe navigations that don't add session history items must be
2014 // marked with AUTO_SUBFRAME. See also didFailProvisionalLoad for how we 2014 // marked with AUTO_SUBFRAME. See also didFailProvisionalLoad for how we
2015 // handle loading of error pages. 2015 // handle loading of error pages.
2016 document_state->navigation_state()->set_transition_type( 2016 document_state->navigation_state()->set_transition_type(
2017 PAGE_TRANSITION_AUTO_SUBFRAME); 2017 ui::PAGE_TRANSITION_AUTO_SUBFRAME);
2018 } 2018 }
2019 2019
2020 FOR_EACH_OBSERVER(RenderViewObserver, render_view_->observers(), 2020 FOR_EACH_OBSERVER(RenderViewObserver, render_view_->observers(),
2021 DidStartProvisionalLoad(frame)); 2021 DidStartProvisionalLoad(frame));
2022 FOR_EACH_OBSERVER(RenderFrameObserver, observers_, DidStartProvisionalLoad()); 2022 FOR_EACH_OBSERVER(RenderFrameObserver, observers_, DidStartProvisionalLoad());
2023 2023
2024 Send(new FrameHostMsg_DidStartProvisionalLoadForFrame( 2024 Send(new FrameHostMsg_DidStartProvisionalLoadForFrame(
2025 routing_id_, ds->request().url(), is_transition_navigation)); 2025 routing_id_, ds->request().url(), is_transition_navigation));
2026 } 2026 }
2027 2027
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
2121 // Otherwise, we do a normal load, which simulates a 'go' navigation as far 2121 // Otherwise, we do a normal load, which simulates a 'go' navigation as far
2122 // as session history is concerned. 2122 // as session history is concerned.
2123 // 2123 //
2124 // AUTO_SUBFRAME loads should always be treated as loads that do not advance 2124 // AUTO_SUBFRAME loads should always be treated as loads that do not advance
2125 // the page id. 2125 // the page id.
2126 // 2126 //
2127 // TODO(davidben): This should also take the failed navigation's replacement 2127 // TODO(davidben): This should also take the failed navigation's replacement
2128 // state into account, if a location.replace() failed. 2128 // state into account, if a location.replace() failed.
2129 bool replace = 2129 bool replace =
2130 navigation_state->pending_page_id() != -1 || 2130 navigation_state->pending_page_id() != -1 ||
2131 PageTransitionCoreTypeIs(navigation_state->transition_type(), 2131 ui::PageTransitionCoreTypeIs(navigation_state->transition_type(),
2132 PAGE_TRANSITION_AUTO_SUBFRAME); 2132 ui::PAGE_TRANSITION_AUTO_SUBFRAME);
2133 2133
2134 // If we failed on a browser initiated request, then make sure that our error 2134 // If we failed on a browser initiated request, then make sure that our error
2135 // page load is regarded as the same browser initiated request. 2135 // page load is regarded as the same browser initiated request.
2136 if (!navigation_state->is_content_initiated()) { 2136 if (!navigation_state->is_content_initiated()) {
2137 render_view_->pending_navigation_params_.reset( 2137 render_view_->pending_navigation_params_.reset(
2138 new FrameMsg_Navigate_Params); 2138 new FrameMsg_Navigate_Params);
2139 render_view_->pending_navigation_params_->page_id = 2139 render_view_->pending_navigation_params_->page_id =
2140 navigation_state->pending_page_id(); 2140 navigation_state->pending_page_id();
2141 render_view_->pending_navigation_params_->pending_history_list_offset = 2141 render_view_->pending_navigation_params_->pending_history_list_offset =
2142 navigation_state->pending_history_list_offset(); 2142 navigation_state->pending_history_list_offset();
(...skipping 497 matching lines...) Expand 10 before | Expand all | Expand 10 after
2640 // TODO(nasko): Hack around asking about top-frame data source. This means 2640 // TODO(nasko): Hack around asking about top-frame data source. This means
2641 // for out-of-process iframes we are treating the current frame as the 2641 // for out-of-process iframes we are treating the current frame as the
2642 // top-level frame, which is wrong. 2642 // top-level frame, which is wrong.
2643 if (!top_frame || top_frame->isWebRemoteFrame()) 2643 if (!top_frame || top_frame->isWebRemoteFrame())
2644 top_frame = frame; 2644 top_frame = frame;
2645 WebDataSource* provisional_data_source = top_frame->provisionalDataSource(); 2645 WebDataSource* provisional_data_source = top_frame->provisionalDataSource();
2646 WebDataSource* top_data_source = top_frame->dataSource(); 2646 WebDataSource* top_data_source = top_frame->dataSource();
2647 WebDataSource* data_source = 2647 WebDataSource* data_source =
2648 provisional_data_source ? provisional_data_source : top_data_source; 2648 provisional_data_source ? provisional_data_source : top_data_source;
2649 2649
2650 PageTransition transition_type = PAGE_TRANSITION_LINK; 2650 ui::PageTransition transition_type = ui::PAGE_TRANSITION_LINK;
2651 DocumentState* document_state = DocumentState::FromDataSource(data_source); 2651 DocumentState* document_state = DocumentState::FromDataSource(data_source);
2652 DCHECK(document_state); 2652 DCHECK(document_state);
2653 InternalDocumentStateData* internal_data = 2653 InternalDocumentStateData* internal_data =
2654 InternalDocumentStateData::FromDocumentState(document_state); 2654 InternalDocumentStateData::FromDocumentState(document_state);
2655 NavigationState* navigation_state = document_state->navigation_state(); 2655 NavigationState* navigation_state = document_state->navigation_state();
2656 transition_type = navigation_state->transition_type(); 2656 transition_type = navigation_state->transition_type();
2657 2657
2658 GURL request_url(request.url()); 2658 GURL request_url(request.url());
2659 GURL new_url; 2659 GURL new_url;
2660 if (GetContentClient()->renderer()->WillSendRequest( 2660 if (GetContentClient()->renderer()->WillSendRequest(
(...skipping 691 matching lines...) Expand 10 before | Expand all | Expand 10 after
3352 // This zoom level was merely recorded transiently for this load. We can 3352 // This zoom level was merely recorded transiently for this load. We can
3353 // erase it now. If at some point we reload this page, the browser will 3353 // erase it now. If at some point we reload this page, the browser will
3354 // send us a new, up-to-date zoom level. 3354 // send us a new, up-to-date zoom level.
3355 render_view_->host_zoom_levels_.erase(host_zoom); 3355 render_view_->host_zoom_levels_.erase(host_zoom);
3356 } 3356 }
3357 3357
3358 // Update contents MIME type for main frame. 3358 // Update contents MIME type for main frame.
3359 params.contents_mime_type = ds->response().mimeType().utf8(); 3359 params.contents_mime_type = ds->response().mimeType().utf8();
3360 3360
3361 params.transition = navigation_state->transition_type(); 3361 params.transition = navigation_state->transition_type();
3362 if (!PageTransitionIsMainFrame(params.transition)) { 3362 if (!ui::PageTransitionIsMainFrame(params.transition)) {
3363 // If the main frame does a load, it should not be reported as a subframe 3363 // If the main frame does a load, it should not be reported as a subframe
3364 // navigation. This can occur in the following case: 3364 // navigation. This can occur in the following case:
3365 // 1. You're on a site with frames. 3365 // 1. You're on a site with frames.
3366 // 2. You do a subframe navigation. This is stored with transition type 3366 // 2. You do a subframe navigation. This is stored with transition type
3367 // MANUAL_SUBFRAME. 3367 // MANUAL_SUBFRAME.
3368 // 3. You navigate to some non-frame site, say, google.com. 3368 // 3. You navigate to some non-frame site, say, google.com.
3369 // 4. You navigate back to the page from step 2. Since it was initially 3369 // 4. You navigate back to the page from step 2. Since it was initially
3370 // MANUAL_SUBFRAME, it will be that same transition type here. 3370 // MANUAL_SUBFRAME, it will be that same transition type here.
3371 // We don't want that, because any navigation that changes the toplevel 3371 // We don't want that, because any navigation that changes the toplevel
3372 // frame should be tracked as a toplevel navigation (this allows us to 3372 // frame should be tracked as a toplevel navigation (this allows us to
3373 // update the URL bar, etc). 3373 // update the URL bar, etc).
3374 params.transition = PAGE_TRANSITION_LINK; 3374 params.transition = ui::PAGE_TRANSITION_LINK;
3375 } 3375 }
3376 3376
3377 // If the page contained a client redirect (meta refresh, document.loc...), 3377 // If the page contained a client redirect (meta refresh, document.loc...),
3378 // set the referrer and transition appropriately. 3378 // set the referrer and transition appropriately.
3379 if (ds->isClientRedirect()) { 3379 if (ds->isClientRedirect()) {
3380 params.referrer = 3380 params.referrer =
3381 Referrer(params.redirects[0], ds->request().referrerPolicy()); 3381 Referrer(params.redirects[0], ds->request().referrerPolicy());
3382 params.transition = static_cast<PageTransition>( 3382 params.transition = ui::PageTransitionFromInt(
3383 params.transition | PAGE_TRANSITION_CLIENT_REDIRECT); 3383 params.transition | ui::PAGE_TRANSITION_CLIENT_REDIRECT);
3384 } else { 3384 } else {
3385 params.referrer = RenderViewImpl::GetReferrerFromRequest( 3385 params.referrer = RenderViewImpl::GetReferrerFromRequest(
3386 frame, ds->request()); 3386 frame, ds->request());
3387 } 3387 }
3388 3388
3389 base::string16 method = request.httpMethod(); 3389 base::string16 method = request.httpMethod();
3390 if (EqualsASCII(method, "POST")) { 3390 if (EqualsASCII(method, "POST")) {
3391 params.is_post = true; 3391 params.is_post = true;
3392 params.post_id = ExtractPostId(entry->root()); 3392 params.post_id = ExtractPostId(entry->root());
3393 } 3393 }
(...skipping 20 matching lines...) Expand all
3414 // after the FrameHostMsg_DidCommitProvisionalLoad message. 3414 // after the FrameHostMsg_DidCommitProvisionalLoad message.
3415 Send(new FrameHostMsg_DidCommitProvisionalLoad(routing_id_, params)); 3415 Send(new FrameHostMsg_DidCommitProvisionalLoad(routing_id_, params));
3416 } else { 3416 } else {
3417 // Subframe navigation: the type depends on whether this navigation 3417 // Subframe navigation: the type depends on whether this navigation
3418 // generated a new session history entry. When they do generate a session 3418 // generated a new session history entry. When they do generate a session
3419 // history entry, it means the user initiated the navigation and we should 3419 // history entry, it means the user initiated the navigation and we should
3420 // mark it as such. This test checks if this is the first time 3420 // mark it as such. This test checks if this is the first time
3421 // SendDidCommitProvisionalLoad has been called since WillNavigateToURL was 3421 // SendDidCommitProvisionalLoad has been called since WillNavigateToURL was
3422 // called to initiate the load. 3422 // called to initiate the load.
3423 if (render_view_->page_id_ > render_view_->last_page_id_sent_to_browser_) 3423 if (render_view_->page_id_ > render_view_->last_page_id_sent_to_browser_)
3424 params.transition = PAGE_TRANSITION_MANUAL_SUBFRAME; 3424 params.transition = ui::PAGE_TRANSITION_MANUAL_SUBFRAME;
3425 else 3425 else
3426 params.transition = PAGE_TRANSITION_AUTO_SUBFRAME; 3426 params.transition = ui::PAGE_TRANSITION_AUTO_SUBFRAME;
3427 3427
3428 DCHECK(!navigation_state->history_list_was_cleared()); 3428 DCHECK(!navigation_state->history_list_was_cleared());
3429 params.history_list_was_cleared = false; 3429 params.history_list_was_cleared = false;
3430 3430
3431 // Don't send this message while the subframe is swapped out. 3431 // Don't send this message while the subframe is swapped out.
3432 if (!is_swapped_out()) 3432 if (!is_swapped_out())
3433 Send(new FrameHostMsg_DidCommitProvisionalLoad(routing_id_, params)); 3433 Send(new FrameHostMsg_DidCommitProvisionalLoad(routing_id_, params));
3434 } 3434 }
3435 3435
3436 render_view_->last_page_id_sent_to_browser_ = 3436 render_view_->last_page_id_sent_to_browser_ =
3437 std::max(render_view_->last_page_id_sent_to_browser_, 3437 std::max(render_view_->last_page_id_sent_to_browser_,
3438 render_view_->page_id_); 3438 render_view_->page_id_);
3439 3439
3440 // If we end up reusing this WebRequest (for example, due to a #ref click), 3440 // If we end up reusing this WebRequest (for example, due to a #ref click),
3441 // we don't want the transition type to persist. Just clear it. 3441 // we don't want the transition type to persist. Just clear it.
3442 navigation_state->set_transition_type(PAGE_TRANSITION_LINK); 3442 navigation_state->set_transition_type(ui::PAGE_TRANSITION_LINK);
3443 } 3443 }
3444 3444
3445 WebElement RenderFrameImpl::GetFocusedElement() { 3445 WebElement RenderFrameImpl::GetFocusedElement() {
3446 WebDocument doc = frame_->document(); 3446 WebDocument doc = frame_->document();
3447 if (!doc.isNull()) 3447 if (!doc.isNull())
3448 return doc.focusedElement(); 3448 return doc.focusedElement();
3449 3449
3450 return WebElement(); 3450 return WebElement();
3451 } 3451 }
3452 3452
(...skipping 461 matching lines...) Expand 10 before | Expand all | Expand 10 after
3914 3914
3915 #if defined(ENABLE_BROWSER_CDMS) 3915 #if defined(ENABLE_BROWSER_CDMS)
3916 RendererCdmManager* RenderFrameImpl::GetCdmManager() { 3916 RendererCdmManager* RenderFrameImpl::GetCdmManager() {
3917 if (!cdm_manager_) 3917 if (!cdm_manager_)
3918 cdm_manager_ = new RendererCdmManager(this); 3918 cdm_manager_ = new RendererCdmManager(this);
3919 return cdm_manager_; 3919 return cdm_manager_;
3920 } 3920 }
3921 #endif // defined(ENABLE_BROWSER_CDMS) 3921 #endif // defined(ENABLE_BROWSER_CDMS)
3922 3922
3923 } // namespace content 3923 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/accessibility/renderer_accessibility_browsertest.cc ('k') | content/renderer/render_view_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698