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

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

Issue 10827107: Allow transitions to WebUI pages which are extension urls (new tab page is the relevant example). (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 years, 4 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 | Annotate | Revision Log
OLDNEW
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
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
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
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
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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
3367 // if the rel=prerender rel type is sticking around. 3368 // if the rel=prerender rel type is sticking around.
3368 if (top_document_state && 3369 if (top_document_state &&
3369 request.targetType() == WebURLRequest::TargetIsPrefetch) 3370 request.targetType() == WebURLRequest::TargetIsPrefetch)
3370 top_document_state->set_was_prefetcher(true); 3371 top_document_state->set_was_prefetcher(true);
3371 3372
3372 request.setRequestorID(routing_id_); 3373 request.setRequestorID(routing_id_);
3373 request.setHasUserGesture(frame->isProcessingUserGesture()); 3374 request.setHasUserGesture(frame->isProcessingUserGesture());
3374 3375
3375 if (!renderer_preferences_.enable_referrers) 3376 if (!renderer_preferences_.enable_referrers)
3376 request.clearHTTPHeaderField("Referer"); 3377 request.clearHTTPHeaderField("Referer");
3378
3379 bool top_level = (request.targetType() == WebURLRequest::TargetIsMainFrame);
3380 if (top_level)
3381 content::GetContentClient()->CustomStreamReset();
3382 content::GetContentClient()->CustomStreamAddURL(request_url, top_level);
3377 } 3383 }
3378 3384
3379 void RenderViewImpl::didReceiveResponse( 3385 void RenderViewImpl::didReceiveResponse(
3380 WebFrame* frame, unsigned identifier, const WebURLResponse& response) { 3386 WebFrame* frame, unsigned identifier, const WebURLResponse& response) {
3381 3387
3382 // Only do this for responses that correspond to a provisional data source 3388 // Only do this for responses that correspond to a provisional data source
3383 // of the top-most frame. If we have a provisional data source, then we 3389 // of the top-most frame. If we have a provisional data source, then we
3384 // can't have any sub-resources yet, so we know that this response must 3390 // can't have any sub-resources yet, so we know that this response must
3385 // correspond to a frame load. 3391 // correspond to a frame load.
3386 if (!frame->provisionalDataSource() || frame->parent()) 3392 if (!frame->provisionalDataSource() || frame->parent())
(...skipping 1120 matching lines...) Expand 10 before | Expand all | Expand 10 after
4507 void RenderViewImpl::OnScriptEvalRequest(const string16& frame_xpath, 4513 void RenderViewImpl::OnScriptEvalRequest(const string16& frame_xpath,
4508 const string16& jscript, 4514 const string16& jscript,
4509 int id, 4515 int id,
4510 bool notify_result) { 4516 bool notify_result) {
4511 EvaluateScript(frame_xpath, jscript, id, notify_result); 4517 EvaluateScript(frame_xpath, jscript, id, notify_result);
4512 } 4518 }
4513 4519
4514 void RenderViewImpl::OnPostMessageEvent( 4520 void RenderViewImpl::OnPostMessageEvent(
4515 const ViewMsg_PostMessage_Params& params) { 4521 const ViewMsg_PostMessage_Params& params) {
4516 // TODO(creis): Support sending to subframes. 4522 // TODO(creis): Support sending to subframes.
4517 WebFrame *frame = webview()->mainFrame(); 4523 WebFrame* frame = webview()->mainFrame();
4518 4524
4519 // Find the source frame if it exists. 4525 // Find the source frame if it exists.
4520 // TODO(creis): Support source subframes. 4526 // TODO(creis): Support source subframes.
4521 WebFrame* source_frame = NULL; 4527 WebFrame* source_frame = NULL;
4522 if (params.source_routing_id != MSG_ROUTING_NONE) { 4528 if (params.source_routing_id != MSG_ROUTING_NONE) {
4523 RenderViewImpl* source_view = FromRoutingID(params.source_routing_id); 4529 RenderViewImpl* source_view = FromRoutingID(params.source_routing_id);
4524 if (source_view) 4530 if (source_view)
4525 source_frame = source_view->webview()->mainFrame(); 4531 source_frame = source_view->webview()->mainFrame();
4526 } 4532 }
4527 4533
(...skipping 735 matching lines...) Expand 10 before | Expand all | Expand 10 after
5263 for (plugin_it = plugin_delegates_.begin(); 5269 for (plugin_it = plugin_delegates_.begin();
5264 plugin_it != plugin_delegates_.end(); ++plugin_it) { 5270 plugin_it != plugin_delegates_.end(); ++plugin_it) {
5265 #if defined(OS_MACOSX) 5271 #if defined(OS_MACOSX)
5266 // RenderWidget's call to setFocus can cause the underlying webview's 5272 // RenderWidget's call to setFocus can cause the underlying webview's
5267 // activation state to change just like a call to setIsActive. 5273 // activation state to change just like a call to setIsActive.
5268 if (enable) 5274 if (enable)
5269 (*plugin_it)->SetWindowFocus(true); 5275 (*plugin_it)->SetWindowFocus(true);
5270 #endif 5276 #endif
5271 (*plugin_it)->SetContentAreaFocus(enable); 5277 (*plugin_it)->SetContentAreaFocus(enable);
5272 } 5278 }
5273
5274 } 5279 }
5275 // Notify all Pepper plugins. 5280 // Notify all Pepper plugins.
5276 pepper_delegate_.OnSetFocus(enable); 5281 pepper_delegate_.OnSetFocus(enable);
5277 } 5282 }
5278 5283
5279 void RenderViewImpl::PpapiPluginFocusChanged() { 5284 void RenderViewImpl::PpapiPluginFocusChanged() {
5280 UpdateTextInputState(); 5285 UpdateTextInputState();
5281 UpdateSelectionBounds(); 5286 UpdateSelectionBounds();
5282 } 5287 }
5283 5288
(...skipping 452 matching lines...) Expand 10 before | Expand all | Expand 10 after
5736 bool RenderViewImpl::WebWidgetHandlesCompositorScheduling() const { 5741 bool RenderViewImpl::WebWidgetHandlesCompositorScheduling() const {
5737 return !!RenderThreadImpl::current()->compositor_thread(); 5742 return !!RenderThreadImpl::current()->compositor_thread();
5738 } 5743 }
5739 5744
5740 void RenderViewImpl::OnJavaBridgeInit() { 5745 void RenderViewImpl::OnJavaBridgeInit() {
5741 DCHECK(!java_bridge_dispatcher_); 5746 DCHECK(!java_bridge_dispatcher_);
5742 #if defined(ENABLE_JAVA_BRIDGE) 5747 #if defined(ENABLE_JAVA_BRIDGE)
5743 java_bridge_dispatcher_ = new JavaBridgeDispatcher(this); 5748 java_bridge_dispatcher_ = new JavaBridgeDispatcher(this);
5744 #endif 5749 #endif
5745 } 5750 }
OLDNEW
« content/public/common/content_client.h ('K') | « content/public/renderer/content_renderer_client.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698