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

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

Issue 1446253002: PlzNavigate: inform the WebFrameClient that a form will be submitted (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 1 month 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 2538 matching lines...) Expand 10 before | Expand all | Expand 10 after
2549 void RenderFrameImpl::willSendSubmitEvent(blink::WebLocalFrame* frame, 2549 void RenderFrameImpl::willSendSubmitEvent(blink::WebLocalFrame* frame,
2550 const blink::WebFormElement& form) { 2550 const blink::WebFormElement& form) {
2551 DCHECK(!frame_ || frame_ == frame); 2551 DCHECK(!frame_ || frame_ == frame);
2552 2552
2553 FOR_EACH_OBSERVER(RenderFrameObserver, observers_, WillSendSubmitEvent(form)); 2553 FOR_EACH_OBSERVER(RenderFrameObserver, observers_, WillSendSubmitEvent(form));
2554 } 2554 }
2555 2555
2556 void RenderFrameImpl::willSubmitForm(blink::WebLocalFrame* frame, 2556 void RenderFrameImpl::willSubmitForm(blink::WebLocalFrame* frame,
2557 const blink::WebFormElement& form) { 2557 const blink::WebFormElement& form) {
2558 DCHECK(!frame_ || frame_ == frame); 2558 DCHECK(!frame_ || frame_ == frame);
2559 DocumentState* document_state = 2559 // With PlzNavigate-enabled, this will be called before a DataSource has been
2560 DocumentState::FromDataSource(frame->provisionalDataSource()); 2560 // set-up.
2561 NavigationStateImpl* navigation_state = 2561 // TODO(clamy): make sure the internal state is properly updated at some
2562 static_cast<NavigationStateImpl*>(document_state->navigation_state()); 2562 // point in the navigation.
2563 InternalDocumentStateData* internal_data = 2563 if (!base::CommandLine::ForCurrentProcess()->HasSwitch(
2564 InternalDocumentStateData::FromDocumentState(document_state); 2564 switches::kEnableBrowserSideNavigation)) {
2565 DocumentState* document_state =
2566 DocumentState::FromDataSource(frame->provisionalDataSource());
2567 NavigationStateImpl* navigation_state =
2568 static_cast<NavigationStateImpl*>(document_state->navigation_state());
2569 InternalDocumentStateData* internal_data =
2570 InternalDocumentStateData::FromDocumentState(document_state);
2571 if (ui::PageTransitionCoreTypeIs(navigation_state->GetTransitionType(),
2572 ui::PAGE_TRANSITION_LINK)) {
2573 navigation_state->set_transition_type(ui::PAGE_TRANSITION_FORM_SUBMIT);
Nate Chapin 2015/12/08 23:18:38 I think you can check and modify pending_navigatio
clamy 2015/12/11 14:50:06 At that point pending_navigation_params_ should be
2574 }
2565 2575
2566 if (ui::PageTransitionCoreTypeIs(navigation_state->GetTransitionType(), 2576 // Save these to be processed when the ensuing navigation is committed.
2567 ui::PAGE_TRANSITION_LINK)) { 2577 WebSearchableFormData web_searchable_form_data(form);
2568 navigation_state->set_transition_type(ui::PAGE_TRANSITION_FORM_SUBMIT); 2578 internal_data->set_searchable_form_url(web_searchable_form_data.url());
2579 internal_data->set_searchable_form_encoding(
Nate Chapin 2015/12/08 23:18:38 Can we stash these on one of the navigation params
clamy 2015/12/11 14:50:06 As explained above, we can't use the pending_navig
2580 web_searchable_form_data.encoding().utf8());
2569 } 2581 }
2570 2582
2571 // Save these to be processed when the ensuing navigation is committed.
2572 WebSearchableFormData web_searchable_form_data(form);
2573 internal_data->set_searchable_form_url(web_searchable_form_data.url());
2574 internal_data->set_searchable_form_encoding(
2575 web_searchable_form_data.encoding().utf8());
2576
2577 FOR_EACH_OBSERVER(RenderFrameObserver, observers_, WillSubmitForm(form)); 2583 FOR_EACH_OBSERVER(RenderFrameObserver, observers_, WillSubmitForm(form));
2578 } 2584 }
2579 2585
2580 void RenderFrameImpl::didCreateDataSource(blink::WebLocalFrame* frame, 2586 void RenderFrameImpl::didCreateDataSource(blink::WebLocalFrame* frame,
2581 blink::WebDataSource* datasource) { 2587 blink::WebDataSource* datasource) {
2582 DCHECK(!frame_ || frame_ == frame); 2588 DCHECK(!frame_ || frame_ == frame);
2583 2589
2584 bool content_initiated = !pending_navigation_params_.get(); 2590 bool content_initiated = !pending_navigation_params_.get();
2585 2591
2586 // Make sure any previous redirect URLs end up in our new data source. 2592 // Make sure any previous redirect URLs end up in our new data source.
(...skipping 1961 matching lines...) Expand 10 before | Expand all | Expand 10 after
4548 return blink::WebNavigationPolicyIgnore; 4554 return blink::WebNavigationPolicyIgnore;
4549 } 4555 }
4550 4556
4551 // PlzNavigate: if the navigation is not synchronous, send it to the browser. 4557 // PlzNavigate: if the navigation is not synchronous, send it to the browser.
4552 // This includes navigations with no request being sent to the network stack. 4558 // This includes navigations with no request being sent to the network stack.
4553 if (base::CommandLine::ForCurrentProcess()->HasSwitch( 4559 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
4554 switches::kEnableBrowserSideNavigation) && 4560 switches::kEnableBrowserSideNavigation) &&
4555 info.urlRequest.checkForBrowserSideNavigation() && 4561 info.urlRequest.checkForBrowserSideNavigation() &&
4556 ShouldMakeNetworkRequestForURL(url)) { 4562 ShouldMakeNetworkRequestForURL(url)) {
4557 BeginNavigation(&info.urlRequest); 4563 BeginNavigation(&info.urlRequest);
4558 return blink::WebNavigationPolicyIgnore; 4564 return blink::WebNavigationPolicyHandledByClient;
4559 } 4565 }
4560 4566
4561 return info.defaultPolicy; 4567 return info.defaultPolicy;
4562 } 4568 }
4563 4569
4564 void RenderFrameImpl::OnGetSavableResourceLinks() { 4570 void RenderFrameImpl::OnGetSavableResourceLinks() {
4565 std::vector<GURL> resources_list; 4571 std::vector<GURL> resources_list;
4566 std::vector<SavableSubframe> subframes; 4572 std::vector<SavableSubframe> subframes;
4567 SavableResourcesResult result(&resources_list, &subframes); 4573 SavableResourcesResult result(&resources_list, &subframes);
4568 4574
(...skipping 791 matching lines...) Expand 10 before | Expand all | Expand 10 after
5360 media::ConvertToSwitchOutputDeviceCB(web_callbacks); 5366 media::ConvertToSwitchOutputDeviceCB(web_callbacks);
5361 scoped_refptr<media::AudioOutputDevice> device = 5367 scoped_refptr<media::AudioOutputDevice> device =
5362 AudioDeviceFactory::NewOutputDevice(routing_id_, 0, sink_id.utf8(), 5368 AudioDeviceFactory::NewOutputDevice(routing_id_, 0, sink_id.utf8(),
5363 security_origin); 5369 security_origin);
5364 media::OutputDeviceStatus status = device->GetDeviceStatus(); 5370 media::OutputDeviceStatus status = device->GetDeviceStatus();
5365 device->Stop(); 5371 device->Stop();
5366 callback.Run(status); 5372 callback.Run(status);
5367 } 5373 }
5368 5374
5369 } // namespace content 5375 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698