OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_view_impl.h" | 5 #include "content/renderer/render_view_impl.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <cmath> | 8 #include <cmath> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
(...skipping 1430 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1441 original_request.httpHeaderField(WebString::fromUTF8("Referer"))), | 1441 original_request.httpHeaderField(WebString::fromUTF8("Referer"))), |
1442 GetReferrerPolicyFromRequest(frame, original_request)); | 1442 GetReferrerPolicyFromRequest(frame, original_request)); |
1443 } | 1443 } |
1444 | 1444 |
1445 string16 method = request.httpMethod(); | 1445 string16 method = request.httpMethod(); |
1446 if (EqualsASCII(method, "POST")) { | 1446 if (EqualsASCII(method, "POST")) { |
1447 params.is_post = true; | 1447 params.is_post = true; |
1448 params.post_id = ExtractPostId(item); | 1448 params.post_id = ExtractPostId(item); |
1449 } | 1449 } |
1450 | 1450 |
1451 // Send the user agent override back. | |
1452 params.is_overriding_user_agent = | |
1453 document_state->is_overriding_user_agent(); | |
1454 | |
1451 // Save some histogram data so we can compute the average memory used per | 1455 // Save some histogram data so we can compute the average memory used per |
1452 // page load of the glyphs. | 1456 // page load of the glyphs. |
1453 UMA_HISTOGRAM_COUNTS_10000("Memory.GlyphPagesPerLoad", | 1457 UMA_HISTOGRAM_COUNTS_10000("Memory.GlyphPagesPerLoad", |
1454 webkit_glue::GetGlyphPageCount()); | 1458 webkit_glue::GetGlyphPageCount()); |
1455 | 1459 |
1456 // This message needs to be sent before any of allowScripts(), | 1460 // This message needs to be sent before any of allowScripts(), |
1457 // allowImages(), allowPlugins() is called for the new page, so that when | 1461 // allowImages(), allowPlugins() is called for the new page, so that when |
1458 // these functions send a ViewHostMsg_ContentBlocked message, it arrives | 1462 // these functions send a ViewHostMsg_ContentBlocked message, it arrives |
1459 // after the ViewHostMsg_FrameNavigate message. | 1463 // after the ViewHostMsg_FrameNavigate message. |
1460 Send(new ViewHostMsg_FrameNavigate(routing_id_, params)); | 1464 Send(new ViewHostMsg_FrameNavigate(routing_id_, params)); |
(...skipping 1272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2733 bool content_initiated = !pending_navigation_params_.get(); | 2737 bool content_initiated = !pending_navigation_params_.get(); |
2734 | 2738 |
2735 DocumentState* document_state = DocumentState::FromDataSource(ds); | 2739 DocumentState* document_state = DocumentState::FromDataSource(ds); |
2736 if (!document_state) { | 2740 if (!document_state) { |
2737 document_state = new DocumentState; | 2741 document_state = new DocumentState; |
2738 ds->setExtraData(document_state); | 2742 ds->setExtraData(document_state); |
2739 if (!content_initiated) | 2743 if (!content_initiated) |
2740 PopulateDocumentStateFromPending(document_state); | 2744 PopulateDocumentStateFromPending(document_state); |
2741 } | 2745 } |
2742 | 2746 |
2747 // Carry over the user agent override flag, if it exists. | |
2748 if (content_initiated && webview() && webview()->mainFrame() && | |
2749 webview()->mainFrame()->dataSource()) { | |
darin (slow to review)
2012/06/19 18:36:34
why do you need to null-check mainFrame()->dataSou
gone
2012/06/19 21:44:22
Oddly, yes. At least in my Android build, I get i
| |
2750 DocumentState* old_document_state = | |
2751 DocumentState::FromDataSource(webview()->mainFrame()->dataSource()); | |
2752 if (old_document_state) { | |
2753 document_state->set_is_overriding_user_agent( | |
2754 old_document_state->is_overriding_user_agent()); | |
2755 } | |
2756 } | |
2757 | |
2743 // The rest of RenderView assumes that a WebDataSource will always have a | 2758 // The rest of RenderView assumes that a WebDataSource will always have a |
2744 // non-null NavigationState. | 2759 // non-null NavigationState. |
2745 if (content_initiated) | 2760 if (content_initiated) |
2746 document_state->set_navigation_state( | 2761 document_state->set_navigation_state( |
2747 NavigationState::CreateContentInitiated()); | 2762 NavigationState::CreateContentInitiated()); |
2748 else { | 2763 else { |
2749 document_state->set_navigation_state(CreateNavigationStateFromPending()); | 2764 document_state->set_navigation_state(CreateNavigationStateFromPending()); |
2750 pending_navigation_params_.reset(); | 2765 pending_navigation_params_.reset(); |
2751 } | 2766 } |
2752 | 2767 |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2816 } | 2831 } |
2817 | 2832 |
2818 if (IsReload(params)) | 2833 if (IsReload(params)) |
2819 document_state->set_load_type(DocumentState::RELOAD); | 2834 document_state->set_load_type(DocumentState::RELOAD); |
2820 else if (!params.state.empty()) | 2835 else if (!params.state.empty()) |
2821 document_state->set_load_type(DocumentState::HISTORY_LOAD); | 2836 document_state->set_load_type(DocumentState::HISTORY_LOAD); |
2822 else | 2837 else |
2823 document_state->set_load_type(DocumentState::NORMAL_LOAD); | 2838 document_state->set_load_type(DocumentState::NORMAL_LOAD); |
2824 | 2839 |
2825 document_state->set_referrer_policy(params.referrer.policy); | 2840 document_state->set_referrer_policy(params.referrer.policy); |
2841 document_state->set_is_overriding_user_agent(params.is_overriding_user_agent); | |
2826 } | 2842 } |
2827 | 2843 |
2828 NavigationState* RenderViewImpl::CreateNavigationStateFromPending() { | 2844 NavigationState* RenderViewImpl::CreateNavigationStateFromPending() { |
2829 const ViewMsg_Navigate_Params& params = *pending_navigation_params_.get(); | 2845 const ViewMsg_Navigate_Params& params = *pending_navigation_params_.get(); |
2830 NavigationState* navigation_state = NULL; | 2846 NavigationState* navigation_state = NULL; |
2831 | 2847 |
2832 // A navigation resulting from loading a javascript URL should not be treated | 2848 // A navigation resulting from loading a javascript URL should not be treated |
2833 // as a browser initiated event. Instead, we want it to look as if the page | 2849 // as a browser initiated event. Instead, we want it to look as if the page |
2834 // initiated any load resulting from JS execution. | 2850 // initiated any load resulting from JS execution. |
2835 if (!params.url.SchemeIs(chrome::kJavaScriptScheme)) { | 2851 if (!params.url.SchemeIs(chrome::kJavaScriptScheme)) { |
(...skipping 856 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3692 | 3708 |
3693 Send(new ViewHostMsg_RouteMessageEvent(routing_id_, params)); | 3709 Send(new ViewHostMsg_RouteMessageEvent(routing_id_, params)); |
3694 return true; | 3710 return true; |
3695 } | 3711 } |
3696 | 3712 |
3697 void RenderViewImpl::willOpenSocketStream( | 3713 void RenderViewImpl::willOpenSocketStream( |
3698 WebSocketStreamHandle* handle) { | 3714 WebSocketStreamHandle* handle) { |
3699 SocketStreamHandleData::AddToHandle(handle, routing_id_); | 3715 SocketStreamHandleData::AddToHandle(handle, routing_id_); |
3700 } | 3716 } |
3701 | 3717 |
3718 WebKit::WebString RenderViewImpl::userAgentOverride( | |
3719 WebKit::WebFrame* frame, | |
3720 const WebKit::WebURL& url) { | |
3721 if (webview() && webview()->mainFrame() && | |
darin (slow to review)
2012/06/19 18:36:34
nit: return early to minimize indentation for the
gone
2012/06/19 21:44:22
Done.
| |
3722 !renderer_preferences_.user_agent_override.empty()) { | |
3723 WebFrame* main_frame = webview()->mainFrame(); | |
3724 WebDataSource* data_source = NULL; | |
3725 | |
3726 // If we're in the middle of committing a load, the data source we need | |
3727 // will still be provisional. | |
3728 if (main_frame->provisionalDataSource()) { | |
3729 data_source = main_frame->provisionalDataSource(); | |
3730 } else { | |
3731 data_source = main_frame->dataSource(); | |
3732 } | |
3733 | |
3734 DocumentState* document_state = | |
3735 data_source ? DocumentState::FromDataSource(data_source) : NULL; | |
3736 if (document_state && document_state->is_overriding_user_agent()) { | |
3737 return WebString::fromUTF8(renderer_preferences_.user_agent_override); | |
3738 } | |
3739 } | |
3740 | |
3741 return WebKit::WebString(); | |
3742 } | |
3743 | |
3702 // WebKit::WebPageSerializerClient implementation ------------------------------ | 3744 // WebKit::WebPageSerializerClient implementation ------------------------------ |
3703 | 3745 |
3704 void RenderViewImpl::didSerializeDataForFrame( | 3746 void RenderViewImpl::didSerializeDataForFrame( |
3705 const WebURL& frame_url, | 3747 const WebURL& frame_url, |
3706 const WebCString& data, | 3748 const WebCString& data, |
3707 WebPageSerializerClient::PageSerializationStatus status) { | 3749 WebPageSerializerClient::PageSerializationStatus status) { |
3708 Send(new ViewHostMsg_SendSerializedHtmlData( | 3750 Send(new ViewHostMsg_SendSerializedHtmlData( |
3709 routing_id(), | 3751 routing_id(), |
3710 frame_url, | 3752 frame_url, |
3711 data.data(), | 3753 data.data(), |
(...skipping 1915 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5627 bool RenderViewImpl::WebWidgetHandlesCompositorScheduling() const { | 5669 bool RenderViewImpl::WebWidgetHandlesCompositorScheduling() const { |
5628 return !!RenderThreadImpl::current()->compositor_thread(); | 5670 return !!RenderThreadImpl::current()->compositor_thread(); |
5629 } | 5671 } |
5630 | 5672 |
5631 void RenderViewImpl::OnJavaBridgeInit() { | 5673 void RenderViewImpl::OnJavaBridgeInit() { |
5632 DCHECK(!java_bridge_dispatcher_); | 5674 DCHECK(!java_bridge_dispatcher_); |
5633 #if defined(ENABLE_JAVA_BRIDGE) | 5675 #if defined(ENABLE_JAVA_BRIDGE) |
5634 java_bridge_dispatcher_ = new JavaBridgeDispatcher(this); | 5676 java_bridge_dispatcher_ = new JavaBridgeDispatcher(this); |
5635 #endif | 5677 #endif |
5636 } | 5678 } |
OLD | NEW |