OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 1104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1115 // will also call us back which will cause us to send a message to | 1115 // will also call us back which will cause us to send a message to |
1116 // update TabContents. | 1116 // update TabContents. |
1117 webview()->zoomLimitsChanged( | 1117 webview()->zoomLimitsChanged( |
1118 WebView::zoomFactorToZoomLevel(WebView::minTextSizeMultiplier), | 1118 WebView::zoomFactorToZoomLevel(WebView::minTextSizeMultiplier), |
1119 WebView::zoomFactorToZoomLevel(WebView::maxTextSizeMultiplier)); | 1119 WebView::zoomFactorToZoomLevel(WebView::maxTextSizeMultiplier)); |
1120 | 1120 |
1121 // Update contents MIME type for main frame. | 1121 // Update contents MIME type for main frame. |
1122 params.contents_mime_type = ds->response().mimeType().utf8(); | 1122 params.contents_mime_type = ds->response().mimeType().utf8(); |
1123 | 1123 |
1124 params.transition = navigation_state->transition_type(); | 1124 params.transition = navigation_state->transition_type(); |
1125 if (!PageTransition::IsMainFrame(params.transition)) { | 1125 if (!content::PageTransitionIsMainFrame(params.transition)) { |
1126 // If the main frame does a load, it should not be reported as a subframe | 1126 // If the main frame does a load, it should not be reported as a subframe |
1127 // navigation. This can occur in the following case: | 1127 // navigation. This can occur in the following case: |
1128 // 1. You're on a site with frames. | 1128 // 1. You're on a site with frames. |
1129 // 2. You do a subframe navigation. This is stored with transition type | 1129 // 2. You do a subframe navigation. This is stored with transition type |
1130 // MANUAL_SUBFRAME. | 1130 // MANUAL_SUBFRAME. |
1131 // 3. You navigate to some non-frame site, say, google.com. | 1131 // 3. You navigate to some non-frame site, say, google.com. |
1132 // 4. You navigate back to the page from step 2. Since it was initially | 1132 // 4. You navigate back to the page from step 2. Since it was initially |
1133 // MANUAL_SUBFRAME, it will be that same transition type here. | 1133 // MANUAL_SUBFRAME, it will be that same transition type here. |
1134 // We don't want that, because any navigation that changes the toplevel | 1134 // We don't want that, because any navigation that changes the toplevel |
1135 // frame should be tracked as a toplevel navigation (this allows us to | 1135 // frame should be tracked as a toplevel navigation (this allows us to |
1136 // update the URL bar, etc). | 1136 // update the URL bar, etc). |
1137 params.transition = PageTransition::LINK; | 1137 params.transition = content::PAGE_TRANSITION_LINK; |
1138 } | 1138 } |
1139 | 1139 |
1140 // If we have a valid consumed client redirect source, | 1140 // If we have a valid consumed client redirect source, |
1141 // the page contained a client redirect (meta refresh, document.loc...), | 1141 // the page contained a client redirect (meta refresh, document.loc...), |
1142 // so we set the referrer and transition to match. | 1142 // so we set the referrer and transition to match. |
1143 if (completed_client_redirect_src_.is_valid()) { | 1143 if (completed_client_redirect_src_.is_valid()) { |
1144 DCHECK(completed_client_redirect_src_ == params.redirects[0]); | 1144 DCHECK(completed_client_redirect_src_ == params.redirects[0]); |
1145 params.referrer = completed_client_redirect_src_; | 1145 params.referrer = completed_client_redirect_src_; |
1146 params.transition = static_cast<PageTransition::Type>( | 1146 params.transition = static_cast<content::PageTransition>( |
1147 params.transition | PageTransition::CLIENT_REDIRECT); | 1147 params.transition | content::PAGE_TRANSITION_CLIENT_REDIRECT); |
1148 } else { | 1148 } else { |
1149 // Bug 654101: the referrer will be empty on https->http transitions. It | 1149 // Bug 654101: the referrer will be empty on https->http transitions. It |
1150 // would be nice if we could get the real referrer from somewhere. | 1150 // would be nice if we could get the real referrer from somewhere. |
1151 params.referrer = GURL( | 1151 params.referrer = GURL( |
1152 original_request.httpHeaderField(WebString::fromUTF8("Referer"))); | 1152 original_request.httpHeaderField(WebString::fromUTF8("Referer"))); |
1153 } | 1153 } |
1154 | 1154 |
1155 string16 method = request.httpMethod(); | 1155 string16 method = request.httpMethod(); |
1156 if (EqualsASCII(method, "POST")) | 1156 if (EqualsASCII(method, "POST")) |
1157 params.is_post = true; | 1157 params.is_post = true; |
1158 | 1158 |
1159 // Save some histogram data so we can compute the average memory used per | 1159 // Save some histogram data so we can compute the average memory used per |
1160 // page load of the glyphs. | 1160 // page load of the glyphs. |
1161 UMA_HISTOGRAM_COUNTS_10000("Memory.GlyphPagesPerLoad", | 1161 UMA_HISTOGRAM_COUNTS_10000("Memory.GlyphPagesPerLoad", |
1162 webkit_glue::GetGlyphPageCount()); | 1162 webkit_glue::GetGlyphPageCount()); |
1163 | 1163 |
1164 // This message needs to be sent before any of allowScripts(), | 1164 // This message needs to be sent before any of allowScripts(), |
1165 // allowImages(), allowPlugins() is called for the new page, so that when | 1165 // allowImages(), allowPlugins() is called for the new page, so that when |
1166 // these functions send a ViewHostMsg_ContentBlocked message, it arrives | 1166 // these functions send a ViewHostMsg_ContentBlocked message, it arrives |
1167 // after the ViewHostMsg_FrameNavigate message. | 1167 // after the ViewHostMsg_FrameNavigate message. |
1168 Send(new ViewHostMsg_FrameNavigate(routing_id_, params)); | 1168 Send(new ViewHostMsg_FrameNavigate(routing_id_, params)); |
1169 } else { | 1169 } else { |
1170 // Subframe navigation: the type depends on whether this navigation | 1170 // Subframe navigation: the type depends on whether this navigation |
1171 // generated a new session history entry. When they do generate a session | 1171 // generated a new session history entry. When they do generate a session |
1172 // history entry, it means the user initiated the navigation and we should | 1172 // history entry, it means the user initiated the navigation and we should |
1173 // mark it as such. This test checks if this is the first time UpdateURL | 1173 // mark it as such. This test checks if this is the first time UpdateURL |
1174 // has been called since WillNavigateToURL was called to initiate the load. | 1174 // has been called since WillNavigateToURL was called to initiate the load. |
1175 if (page_id_ > last_page_id_sent_to_browser_) | 1175 if (page_id_ > last_page_id_sent_to_browser_) |
1176 params.transition = PageTransition::MANUAL_SUBFRAME; | 1176 params.transition = content::PAGE_TRANSITION_MANUAL_SUBFRAME; |
1177 else | 1177 else |
1178 params.transition = PageTransition::AUTO_SUBFRAME; | 1178 params.transition = content::PAGE_TRANSITION_AUTO_SUBFRAME; |
1179 | 1179 |
1180 Send(new ViewHostMsg_FrameNavigate(routing_id_, params)); | 1180 Send(new ViewHostMsg_FrameNavigate(routing_id_, params)); |
1181 } | 1181 } |
1182 | 1182 |
1183 last_page_id_sent_to_browser_ = | 1183 last_page_id_sent_to_browser_ = |
1184 std::max(last_page_id_sent_to_browser_, page_id_); | 1184 std::max(last_page_id_sent_to_browser_, page_id_); |
1185 | 1185 |
1186 // If we end up reusing this WebRequest (for example, due to a #ref click), | 1186 // If we end up reusing this WebRequest (for example, due to a #ref click), |
1187 // we don't want the transition type to persist. Just clear it. | 1187 // we don't want the transition type to persist. Just clear it. |
1188 navigation_state->set_transition_type(PageTransition::LINK); | 1188 navigation_state->set_transition_type(content::PAGE_TRANSITION_LINK); |
1189 } | 1189 } |
1190 | 1190 |
1191 // Tell the embedding application that the title of the active page has changed | 1191 // Tell the embedding application that the title of the active page has changed |
1192 void RenderViewImpl::UpdateTitle(WebFrame* frame, | 1192 void RenderViewImpl::UpdateTitle(WebFrame* frame, |
1193 const string16& title, | 1193 const string16& title, |
1194 WebTextDirection title_direction) { | 1194 WebTextDirection title_direction) { |
1195 // Ignore all but top level navigations. | 1195 // Ignore all but top level navigations. |
1196 if (frame->parent()) | 1196 if (frame->parent()) |
1197 return; | 1197 return; |
1198 | 1198 |
(...skipping 971 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2170 NavigationState::FromDataSource(frame->dataSource()); | 2170 NavigationState::FromDataSource(frame->dataSource()); |
2171 navigation_state->set_password_form_data( | 2171 navigation_state->set_password_form_data( |
2172 PasswordFormDomManager::CreatePasswordForm(form)); | 2172 PasswordFormDomManager::CreatePasswordForm(form)); |
2173 } | 2173 } |
2174 | 2174 |
2175 void RenderViewImpl::willSubmitForm(WebFrame* frame, | 2175 void RenderViewImpl::willSubmitForm(WebFrame* frame, |
2176 const WebFormElement& form) { | 2176 const WebFormElement& form) { |
2177 NavigationState* navigation_state = | 2177 NavigationState* navigation_state = |
2178 NavigationState::FromDataSource(frame->provisionalDataSource()); | 2178 NavigationState::FromDataSource(frame->provisionalDataSource()); |
2179 | 2179 |
2180 if (navigation_state->transition_type() == PageTransition::LINK) | 2180 if (navigation_state->transition_type() == content::PAGE_TRANSITION_LINK) |
2181 navigation_state->set_transition_type(PageTransition::FORM_SUBMIT); | 2181 navigation_state->set_transition_type(content::PAGE_TRANSITION_FORM_SUBMIT); |
2182 | 2182 |
2183 // Save these to be processed when the ensuing navigation is committed. | 2183 // Save these to be processed when the ensuing navigation is committed. |
2184 WebSearchableFormData web_searchable_form_data(form); | 2184 WebSearchableFormData web_searchable_form_data(form); |
2185 navigation_state->set_searchable_form_url(web_searchable_form_data.url()); | 2185 navigation_state->set_searchable_form_url(web_searchable_form_data.url()); |
2186 navigation_state->set_searchable_form_encoding( | 2186 navigation_state->set_searchable_form_encoding( |
2187 web_searchable_form_data.encoding().utf8()); | 2187 web_searchable_form_data.encoding().utf8()); |
2188 PasswordForm* password_form_data = | 2188 PasswordForm* password_form_data = |
2189 PasswordFormDomManager::CreatePasswordForm(form); | 2189 PasswordFormDomManager::CreatePasswordForm(form); |
2190 navigation_state->set_password_form_data(password_form_data); | 2190 navigation_state->set_password_form_data(password_form_data); |
2191 | 2191 |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2304 bool is_top_most = !frame->parent(); | 2304 bool is_top_most = !frame->parent(); |
2305 if (is_top_most) { | 2305 if (is_top_most) { |
2306 navigation_gesture_ = frame->isProcessingUserGesture() ? | 2306 navigation_gesture_ = frame->isProcessingUserGesture() ? |
2307 NavigationGestureUser : NavigationGestureAuto; | 2307 NavigationGestureUser : NavigationGestureAuto; |
2308 | 2308 |
2309 // Make sure redirect tracking state is clear for the new load. | 2309 // Make sure redirect tracking state is clear for the new load. |
2310 completed_client_redirect_src_ = GURL(); | 2310 completed_client_redirect_src_ = GURL(); |
2311 } else if (frame->parent()->isLoading()) { | 2311 } else if (frame->parent()->isLoading()) { |
2312 // Take note of AUTO_SUBFRAME loads here, so that we can know how to | 2312 // Take note of AUTO_SUBFRAME loads here, so that we can know how to |
2313 // load an error page. See didFailProvisionalLoad. | 2313 // load an error page. See didFailProvisionalLoad. |
2314 navigation_state->set_transition_type(PageTransition::AUTO_SUBFRAME); | 2314 navigation_state->set_transition_type( |
| 2315 content::PAGE_TRANSITION_AUTO_SUBFRAME); |
2315 } | 2316 } |
2316 | 2317 |
2317 FOR_EACH_OBSERVER( | 2318 FOR_EACH_OBSERVER( |
2318 RenderViewObserver, observers_, DidStartProvisionalLoad(frame)); | 2319 RenderViewObserver, observers_, DidStartProvisionalLoad(frame)); |
2319 | 2320 |
2320 Send(new ViewHostMsg_DidStartProvisionalLoadForFrame( | 2321 Send(new ViewHostMsg_DidStartProvisionalLoadForFrame( |
2321 routing_id_, frame->identifier(), is_top_most, GetOpenerUrl(), | 2322 routing_id_, frame->identifier(), is_top_most, GetOpenerUrl(), |
2322 ds->request().url())); | 2323 ds->request().url())); |
2323 } | 2324 } |
2324 | 2325 |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2388 // If this is a failed back/forward/reload navigation, then we need to do a | 2389 // If this is a failed back/forward/reload navigation, then we need to do a |
2389 // 'replace' load. This is necessary to avoid messing up session history. | 2390 // 'replace' load. This is necessary to avoid messing up session history. |
2390 // Otherwise, we do a normal load, which simulates a 'go' navigation as far | 2391 // Otherwise, we do a normal load, which simulates a 'go' navigation as far |
2391 // as session history is concerned. | 2392 // as session history is concerned. |
2392 // | 2393 // |
2393 // AUTO_SUBFRAME loads should always be treated as loads that do not advance | 2394 // AUTO_SUBFRAME loads should always be treated as loads that do not advance |
2394 // the page id. | 2395 // the page id. |
2395 // | 2396 // |
2396 bool replace = | 2397 bool replace = |
2397 navigation_state->pending_page_id() != -1 || | 2398 navigation_state->pending_page_id() != -1 || |
2398 navigation_state->transition_type() == PageTransition::AUTO_SUBFRAME; | 2399 navigation_state->transition_type() == |
| 2400 content::PAGE_TRANSITION_AUTO_SUBFRAME; |
2399 | 2401 |
2400 // If we failed on a browser initiated request, then make sure that our error | 2402 // If we failed on a browser initiated request, then make sure that our error |
2401 // page load is regarded as the same browser initiated request. | 2403 // page load is regarded as the same browser initiated request. |
2402 if (!navigation_state->is_content_initiated()) { | 2404 if (!navigation_state->is_content_initiated()) { |
2403 pending_navigation_state_.reset(NavigationState::CreateBrowserInitiated( | 2405 pending_navigation_state_.reset(NavigationState::CreateBrowserInitiated( |
2404 navigation_state->pending_page_id(), | 2406 navigation_state->pending_page_id(), |
2405 navigation_state->pending_history_list_offset(), | 2407 navigation_state->pending_history_list_offset(), |
2406 navigation_state->transition_type(), | 2408 navigation_state->transition_type(), |
2407 navigation_state->request_time())); | 2409 navigation_state->request_time())); |
2408 } | 2410 } |
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2609 WebDataSource* data_source = | 2611 WebDataSource* data_source = |
2610 provisional_data_source ? provisional_data_source : top_data_source; | 2612 provisional_data_source ? provisional_data_source : top_data_source; |
2611 | 2613 |
2612 GURL request_url(request.url()); | 2614 GURL request_url(request.url()); |
2613 GURL new_url; | 2615 GURL new_url; |
2614 if (content::GetContentClient()->renderer()->WillSendRequest( | 2616 if (content::GetContentClient()->renderer()->WillSendRequest( |
2615 frame, request_url, &new_url)) { | 2617 frame, request_url, &new_url)) { |
2616 request.setURL(WebURL(new_url)); | 2618 request.setURL(WebURL(new_url)); |
2617 } | 2619 } |
2618 | 2620 |
2619 PageTransition::Type transition_type = PageTransition::LINK; | 2621 content::PageTransition transition_type = content::PAGE_TRANSITION_LINK; |
2620 NavigationState* data_state = NavigationState::FromDataSource(data_source); | 2622 NavigationState* data_state = NavigationState::FromDataSource(data_source); |
2621 if (data_state) { | 2623 if (data_state) { |
2622 if (data_state->is_cache_policy_override_set()) | 2624 if (data_state->is_cache_policy_override_set()) |
2623 request.setCachePolicy(data_state->cache_policy_override()); | 2625 request.setCachePolicy(data_state->cache_policy_override()); |
2624 transition_type = data_state->transition_type(); | 2626 transition_type = data_state->transition_type(); |
2625 } | 2627 } |
2626 | 2628 |
2627 request.setExtraData(new RequestExtraData((frame == top_frame), | 2629 request.setExtraData(new RequestExtraData((frame == top_frame), |
2628 frame->identifier(), transition_type)); | 2630 frame->identifier(), transition_type)); |
2629 | 2631 |
(...skipping 1946 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4576 pepper_delegate_.OnLockMouseACK(succeeded); | 4578 pepper_delegate_.OnLockMouseACK(succeeded); |
4577 } | 4579 } |
4578 | 4580 |
4579 void RenderViewImpl::OnMouseLockLost() { | 4581 void RenderViewImpl::OnMouseLockLost() { |
4580 pepper_delegate_.OnMouseLockLost(); | 4582 pepper_delegate_.OnMouseLockLost(); |
4581 } | 4583 } |
4582 | 4584 |
4583 bool RenderViewImpl::WebWidgetHandlesCompositorScheduling() const { | 4585 bool RenderViewImpl::WebWidgetHandlesCompositorScheduling() const { |
4584 return webview()->settings()->useThreadedCompositor(); | 4586 return webview()->settings()->useThreadedCompositor(); |
4585 } | 4587 } |
OLD | NEW |