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 1274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1285 if (!webview()) | 1285 if (!webview()) |
1286 return; | 1286 return; |
1287 | 1287 |
1288 handling_select_range_ = true; | 1288 handling_select_range_ = true; |
1289 webview()->focusedFrame()->selectRange(start, end); | 1289 webview()->focusedFrame()->selectRange(start, end); |
1290 handling_select_range_ = false; | 1290 handling_select_range_ = false; |
1291 } | 1291 } |
1292 | 1292 |
1293 void RenderViewImpl::OnSetHistoryLengthAndPrune(int history_length, | 1293 void RenderViewImpl::OnSetHistoryLengthAndPrune(int history_length, |
1294 int32 minimum_page_id) { | 1294 int32 minimum_page_id) { |
1295 DCHECK(history_length >= 0); | 1295 DCHECK_GE(history_length, 0); |
1296 DCHECK(history_list_offset_ == history_list_length_ - 1); | 1296 DCHECK(history_list_offset_ == history_list_length_ - 1); |
1297 DCHECK(minimum_page_id >= -1); | 1297 DCHECK_GE(minimum_page_id, -1); |
1298 | 1298 |
1299 // Generate the new list. | 1299 // Generate the new list. |
1300 std::vector<int32> new_history_page_ids(history_length, -1); | 1300 std::vector<int32> new_history_page_ids(history_length, -1); |
1301 for (size_t i = 0; i < history_page_ids_.size(); ++i) { | 1301 for (size_t i = 0; i < history_page_ids_.size(); ++i) { |
1302 if (minimum_page_id >= 0 && history_page_ids_[i] < minimum_page_id) | 1302 if (minimum_page_id >= 0 && history_page_ids_[i] < minimum_page_id) |
1303 continue; | 1303 continue; |
1304 new_history_page_ids.push_back(history_page_ids_[i]); | 1304 new_history_page_ids.push_back(history_page_ids_[i]); |
1305 } | 1305 } |
1306 new_history_page_ids.swap(history_page_ids_); | 1306 new_history_page_ids.swap(history_page_ids_); |
1307 | 1307 |
(...skipping 1476 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2784 DocumentState* old_document_state = | 2784 DocumentState* old_document_state = |
2785 DocumentState::FromDataSource(webview()->mainFrame()->dataSource()); | 2785 DocumentState::FromDataSource(webview()->mainFrame()->dataSource()); |
2786 if (old_document_state) { | 2786 if (old_document_state) { |
2787 document_state->set_is_overriding_user_agent( | 2787 document_state->set_is_overriding_user_agent( |
2788 old_document_state->is_overriding_user_agent()); | 2788 old_document_state->is_overriding_user_agent()); |
2789 } | 2789 } |
2790 } | 2790 } |
2791 | 2791 |
2792 // The rest of RenderView assumes that a WebDataSource will always have a | 2792 // The rest of RenderView assumes that a WebDataSource will always have a |
2793 // non-null NavigationState. | 2793 // non-null NavigationState. |
2794 if (content_initiated) | 2794 if (content_initiated) { |
2795 document_state->set_navigation_state( | 2795 document_state->set_navigation_state( |
2796 NavigationState::CreateContentInitiated()); | 2796 NavigationState::CreateContentInitiated()); |
2797 else { | 2797 } else { |
2798 document_state->set_navigation_state(CreateNavigationStateFromPending()); | 2798 document_state->set_navigation_state(CreateNavigationStateFromPending()); |
2799 pending_navigation_params_.reset(); | 2799 pending_navigation_params_.reset(); |
2800 } | 2800 } |
2801 | 2801 |
2802 // DocumentState::referred_by_prefetcher_ is true if we are | 2802 // DocumentState::referred_by_prefetcher_ is true if we are |
2803 // navigating from a page that used prefetching using a link on that | 2803 // navigating from a page that used prefetching using a link on that |
2804 // page. We are early enough in the request process here that we | 2804 // page. We are early enough in the request process here that we |
2805 // can still see the DocumentState of the previous page and set | 2805 // can still see the DocumentState of the previous page and set |
2806 // this value appropriately. | 2806 // this value appropriately. |
2807 // TODO(gavinp): catch the important case of navigation in a new | 2807 // TODO(gavinp): catch the important case of navigation in a new |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2921 webview()->settings()->setViewportEnabled(true); | 2921 webview()->settings()->setViewportEnabled(true); |
2922 } else if (enable_fixed_layout) { | 2922 } else if (enable_fixed_layout) { |
2923 std::string str = | 2923 std::string str = |
2924 command_line.GetSwitchValueASCII(switches::kEnableFixedLayout); | 2924 command_line.GetSwitchValueASCII(switches::kEnableFixedLayout); |
2925 std::vector<std::string> tokens; | 2925 std::vector<std::string> tokens; |
2926 base::SplitString(str, ',', &tokens); | 2926 base::SplitString(str, ',', &tokens); |
2927 if (tokens.size() == 2) { | 2927 if (tokens.size() == 2) { |
2928 int width, height; | 2928 int width, height; |
2929 if (base::StringToInt(tokens[0], &width) && | 2929 if (base::StringToInt(tokens[0], &width) && |
2930 base::StringToInt(tokens[1], &height)) | 2930 base::StringToInt(tokens[1], &height)) |
2931 webview()->setFixedLayoutSize(WebSize(width,height)); | 2931 webview()->setFixedLayoutSize(WebSize(width, height)); |
2932 } | 2932 } |
2933 } | 2933 } |
2934 } | 2934 } |
2935 | 2935 |
2936 void RenderViewImpl::didStartProvisionalLoad(WebFrame* frame) { | 2936 void RenderViewImpl::didStartProvisionalLoad(WebFrame* frame) { |
2937 WebDataSource* ds = frame->provisionalDataSource(); | 2937 WebDataSource* ds = frame->provisionalDataSource(); |
2938 DocumentState* document_state = DocumentState::FromDataSource(ds); | 2938 DocumentState* document_state = DocumentState::FromDataSource(ds); |
2939 | 2939 |
2940 // Update the request time if WebKit has better knowledge of it. | 2940 // Update the request time if WebKit has better knowledge of it. |
2941 if (document_state->request_time().is_null()) { | 2941 if (document_state->request_time().is_null()) { |
(...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3301 WebURLRequest& request, | 3301 WebURLRequest& request, |
3302 const WebURLResponse& redirect_response) { | 3302 const WebURLResponse& redirect_response) { |
3303 WebFrame* top_frame = frame->top(); | 3303 WebFrame* top_frame = frame->top(); |
3304 if (!top_frame) | 3304 if (!top_frame) |
3305 top_frame = frame; | 3305 top_frame = frame; |
3306 WebDataSource* provisional_data_source = top_frame->provisionalDataSource(); | 3306 WebDataSource* provisional_data_source = top_frame->provisionalDataSource(); |
3307 WebDataSource* top_data_source = top_frame->dataSource(); | 3307 WebDataSource* top_data_source = top_frame->dataSource(); |
3308 WebDataSource* data_source = | 3308 WebDataSource* data_source = |
3309 provisional_data_source ? provisional_data_source : top_data_source; | 3309 provisional_data_source ? provisional_data_source : top_data_source; |
3310 | 3310 |
3311 GURL request_url(request.url()); | |
3312 GURL new_url; | |
3313 if (content::GetContentClient()->renderer()->WillSendRequest( | |
3314 frame, request_url, &new_url)) { | |
3315 request.setURL(WebURL(new_url)); | |
3316 } | |
3317 | |
3318 content::PageTransition transition_type = content::PAGE_TRANSITION_LINK; | 3311 content::PageTransition transition_type = content::PAGE_TRANSITION_LINK; |
3319 DocumentState* document_state = DocumentState::FromDataSource(data_source); | 3312 DocumentState* document_state = DocumentState::FromDataSource(data_source); |
3320 DCHECK(document_state); | 3313 DCHECK(document_state); |
3321 NavigationState* navigation_state = document_state->navigation_state(); | 3314 NavigationState* navigation_state = document_state->navigation_state(); |
| 3315 transition_type = navigation_state->transition_type(); |
| 3316 |
| 3317 GURL request_url(request.url()); |
| 3318 GURL new_url; |
| 3319 if (content::GetContentClient()->renderer()->WillSendRequest( |
| 3320 frame, transition_type, request_url, &new_url)) { |
| 3321 request.setURL(WebURL(new_url)); |
| 3322 } |
| 3323 |
3322 if (document_state->is_cache_policy_override_set()) | 3324 if (document_state->is_cache_policy_override_set()) |
3323 request.setCachePolicy(document_state->cache_policy_override()); | 3325 request.setCachePolicy(document_state->cache_policy_override()); |
3324 transition_type = navigation_state->transition_type(); | |
3325 | 3326 |
3326 WebKit::WebReferrerPolicy referrer_policy; | 3327 WebKit::WebReferrerPolicy referrer_policy; |
3327 if (document_state && document_state->is_referrer_policy_set()) { | 3328 if (document_state && document_state->is_referrer_policy_set()) { |
3328 referrer_policy = document_state->referrer_policy(); | 3329 referrer_policy = document_state->referrer_policy(); |
3329 document_state->clear_referrer_policy(); | 3330 document_state->clear_referrer_policy(); |
3330 } else { | 3331 } else { |
3331 referrer_policy = frame->document().referrerPolicy(); | 3332 referrer_policy = frame->document().referrerPolicy(); |
3332 } | 3333 } |
3333 | 3334 |
3334 // The request's extra data may indicate that we should set a custom user | 3335 // The request's extra data may indicate that we should set a custom user |
(...skipping 1191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4526 void RenderViewImpl::OnScriptEvalRequest(const string16& frame_xpath, | 4527 void RenderViewImpl::OnScriptEvalRequest(const string16& frame_xpath, |
4527 const string16& jscript, | 4528 const string16& jscript, |
4528 int id, | 4529 int id, |
4529 bool notify_result) { | 4530 bool notify_result) { |
4530 EvaluateScript(frame_xpath, jscript, id, notify_result); | 4531 EvaluateScript(frame_xpath, jscript, id, notify_result); |
4531 } | 4532 } |
4532 | 4533 |
4533 void RenderViewImpl::OnPostMessageEvent( | 4534 void RenderViewImpl::OnPostMessageEvent( |
4534 const ViewMsg_PostMessage_Params& params) { | 4535 const ViewMsg_PostMessage_Params& params) { |
4535 // TODO(creis): Support sending to subframes. | 4536 // TODO(creis): Support sending to subframes. |
4536 WebFrame *frame = webview()->mainFrame(); | 4537 WebFrame* frame = webview()->mainFrame(); |
4537 | 4538 |
4538 // Find the source frame if it exists. | 4539 // Find the source frame if it exists. |
4539 // TODO(creis): Support source subframes. | 4540 // TODO(creis): Support source subframes. |
4540 WebFrame* source_frame = NULL; | 4541 WebFrame* source_frame = NULL; |
4541 if (params.source_routing_id != MSG_ROUTING_NONE) { | 4542 if (params.source_routing_id != MSG_ROUTING_NONE) { |
4542 RenderViewImpl* source_view = FromRoutingID(params.source_routing_id); | 4543 RenderViewImpl* source_view = FromRoutingID(params.source_routing_id); |
4543 if (source_view) | 4544 if (source_view) |
4544 source_frame = source_view->webview()->mainFrame(); | 4545 source_frame = source_view->webview()->mainFrame(); |
4545 } | 4546 } |
4546 | 4547 |
(...skipping 735 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5282 for (plugin_it = plugin_delegates_.begin(); | 5283 for (plugin_it = plugin_delegates_.begin(); |
5283 plugin_it != plugin_delegates_.end(); ++plugin_it) { | 5284 plugin_it != plugin_delegates_.end(); ++plugin_it) { |
5284 #if defined(OS_MACOSX) | 5285 #if defined(OS_MACOSX) |
5285 // RenderWidget's call to setFocus can cause the underlying webview's | 5286 // RenderWidget's call to setFocus can cause the underlying webview's |
5286 // activation state to change just like a call to setIsActive. | 5287 // activation state to change just like a call to setIsActive. |
5287 if (enable) | 5288 if (enable) |
5288 (*plugin_it)->SetWindowFocus(true); | 5289 (*plugin_it)->SetWindowFocus(true); |
5289 #endif | 5290 #endif |
5290 (*plugin_it)->SetContentAreaFocus(enable); | 5291 (*plugin_it)->SetContentAreaFocus(enable); |
5291 } | 5292 } |
5292 | |
5293 } | 5293 } |
5294 // Notify all Pepper plugins. | 5294 // Notify all Pepper plugins. |
5295 pepper_delegate_.OnSetFocus(enable); | 5295 pepper_delegate_.OnSetFocus(enable); |
5296 } | 5296 } |
5297 | 5297 |
5298 void RenderViewImpl::PpapiPluginFocusChanged() { | 5298 void RenderViewImpl::PpapiPluginFocusChanged() { |
5299 UpdateTextInputState(); | 5299 UpdateTextInputState(); |
5300 UpdateSelectionBounds(); | 5300 UpdateSelectionBounds(); |
5301 } | 5301 } |
5302 | 5302 |
(...skipping 452 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5755 bool RenderViewImpl::WebWidgetHandlesCompositorScheduling() const { | 5755 bool RenderViewImpl::WebWidgetHandlesCompositorScheduling() const { |
5756 return !!RenderThreadImpl::current()->compositor_thread(); | 5756 return !!RenderThreadImpl::current()->compositor_thread(); |
5757 } | 5757 } |
5758 | 5758 |
5759 void RenderViewImpl::OnJavaBridgeInit() { | 5759 void RenderViewImpl::OnJavaBridgeInit() { |
5760 DCHECK(!java_bridge_dispatcher_); | 5760 DCHECK(!java_bridge_dispatcher_); |
5761 #if defined(ENABLE_JAVA_BRIDGE) | 5761 #if defined(ENABLE_JAVA_BRIDGE) |
5762 java_bridge_dispatcher_ = new JavaBridgeDispatcher(this); | 5762 java_bridge_dispatcher_ = new JavaBridgeDispatcher(this); |
5763 #endif | 5763 #endif |
5764 } | 5764 } |
OLD | NEW |