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

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
« no previous file with comments | « content/public/renderer/content_renderer_client.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 1283 matching lines...) Expand 10 before | Expand all | Expand 10 after
1294 if (!webview()) 1294 if (!webview())
1295 return; 1295 return;
1296 1296
1297 handling_select_range_ = true; 1297 handling_select_range_ = true;
1298 webview()->focusedFrame()->selectRange(start, end); 1298 webview()->focusedFrame()->selectRange(start, end);
1299 handling_select_range_ = false; 1299 handling_select_range_ = false;
1300 } 1300 }
1301 1301
1302 void RenderViewImpl::OnSetHistoryLengthAndPrune(int history_length, 1302 void RenderViewImpl::OnSetHistoryLengthAndPrune(int history_length,
1303 int32 minimum_page_id) { 1303 int32 minimum_page_id) {
1304 DCHECK(history_length >= 0); 1304 DCHECK_GE(history_length, 0);
1305 DCHECK(history_list_offset_ == history_list_length_ - 1); 1305 DCHECK(history_list_offset_ == history_list_length_ - 1);
1306 DCHECK(minimum_page_id >= -1); 1306 DCHECK_GE(minimum_page_id, -1);
1307 1307
1308 // Generate the new list. 1308 // Generate the new list.
1309 std::vector<int32> new_history_page_ids(history_length, -1); 1309 std::vector<int32> new_history_page_ids(history_length, -1);
1310 for (size_t i = 0; i < history_page_ids_.size(); ++i) { 1310 for (size_t i = 0; i < history_page_ids_.size(); ++i) {
1311 if (minimum_page_id >= 0 && history_page_ids_[i] < minimum_page_id) 1311 if (minimum_page_id >= 0 && history_page_ids_[i] < minimum_page_id)
1312 continue; 1312 continue;
1313 new_history_page_ids.push_back(history_page_ids_[i]); 1313 new_history_page_ids.push_back(history_page_ids_[i]);
1314 } 1314 }
1315 new_history_page_ids.swap(history_page_ids_); 1315 new_history_page_ids.swap(history_page_ids_);
1316 1316
(...skipping 1479 matching lines...) Expand 10 before | Expand all | Expand 10 after
2796 DocumentState* old_document_state = 2796 DocumentState* old_document_state =
2797 DocumentState::FromDataSource(webview()->mainFrame()->dataSource()); 2797 DocumentState::FromDataSource(webview()->mainFrame()->dataSource());
2798 if (old_document_state) { 2798 if (old_document_state) {
2799 document_state->set_is_overriding_user_agent( 2799 document_state->set_is_overriding_user_agent(
2800 old_document_state->is_overriding_user_agent()); 2800 old_document_state->is_overriding_user_agent());
2801 } 2801 }
2802 } 2802 }
2803 2803
2804 // The rest of RenderView assumes that a WebDataSource will always have a 2804 // The rest of RenderView assumes that a WebDataSource will always have a
2805 // non-null NavigationState. 2805 // non-null NavigationState.
2806 if (content_initiated) 2806 if (content_initiated) {
2807 document_state->set_navigation_state( 2807 document_state->set_navigation_state(
2808 NavigationState::CreateContentInitiated()); 2808 NavigationState::CreateContentInitiated());
2809 else { 2809 } else {
2810 document_state->set_navigation_state(CreateNavigationStateFromPending()); 2810 document_state->set_navigation_state(CreateNavigationStateFromPending());
2811 pending_navigation_params_.reset(); 2811 pending_navigation_params_.reset();
2812 } 2812 }
2813 2813
2814 // DocumentState::referred_by_prefetcher_ is true if we are 2814 // DocumentState::referred_by_prefetcher_ is true if we are
2815 // navigating from a page that used prefetching using a link on that 2815 // navigating from a page that used prefetching using a link on that
2816 // page. We are early enough in the request process here that we 2816 // page. We are early enough in the request process here that we
2817 // can still see the DocumentState of the previous page and set 2817 // can still see the DocumentState of the previous page and set
2818 // this value appropriately. 2818 // this value appropriately.
2819 // TODO(gavinp): catch the important case of navigation in a new 2819 // TODO(gavinp): catch the important case of navigation in a new
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
2933 webview()->settings()->setViewportEnabled(true); 2933 webview()->settings()->setViewportEnabled(true);
2934 } else if (enable_fixed_layout) { 2934 } else if (enable_fixed_layout) {
2935 std::string str = 2935 std::string str =
2936 command_line.GetSwitchValueASCII(switches::kEnableFixedLayout); 2936 command_line.GetSwitchValueASCII(switches::kEnableFixedLayout);
2937 std::vector<std::string> tokens; 2937 std::vector<std::string> tokens;
2938 base::SplitString(str, ',', &tokens); 2938 base::SplitString(str, ',', &tokens);
2939 if (tokens.size() == 2) { 2939 if (tokens.size() == 2) {
2940 int width, height; 2940 int width, height;
2941 if (base::StringToInt(tokens[0], &width) && 2941 if (base::StringToInt(tokens[0], &width) &&
2942 base::StringToInt(tokens[1], &height)) 2942 base::StringToInt(tokens[1], &height))
2943 webview()->setFixedLayoutSize(WebSize(width,height)); 2943 webview()->setFixedLayoutSize(WebSize(width, height));
2944 } 2944 }
2945 } 2945 }
2946 } 2946 }
2947 2947
2948 void RenderViewImpl::didStartProvisionalLoad(WebFrame* frame) { 2948 void RenderViewImpl::didStartProvisionalLoad(WebFrame* frame) {
2949 WebDataSource* ds = frame->provisionalDataSource(); 2949 WebDataSource* ds = frame->provisionalDataSource();
2950 DocumentState* document_state = DocumentState::FromDataSource(ds); 2950 DocumentState* document_state = DocumentState::FromDataSource(ds);
2951 2951
2952 // Update the request time if WebKit has better knowledge of it. 2952 // Update the request time if WebKit has better knowledge of it.
2953 if (document_state->request_time().is_null()) { 2953 if (document_state->request_time().is_null()) {
(...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after
3313 WebURLRequest& request, 3313 WebURLRequest& request,
3314 const WebURLResponse& redirect_response) { 3314 const WebURLResponse& redirect_response) {
3315 WebFrame* top_frame = frame->top(); 3315 WebFrame* top_frame = frame->top();
3316 if (!top_frame) 3316 if (!top_frame)
3317 top_frame = frame; 3317 top_frame = frame;
3318 WebDataSource* provisional_data_source = top_frame->provisionalDataSource(); 3318 WebDataSource* provisional_data_source = top_frame->provisionalDataSource();
3319 WebDataSource* top_data_source = top_frame->dataSource(); 3319 WebDataSource* top_data_source = top_frame->dataSource();
3320 WebDataSource* data_source = 3320 WebDataSource* data_source =
3321 provisional_data_source ? provisional_data_source : top_data_source; 3321 provisional_data_source ? provisional_data_source : top_data_source;
3322 3322
3323 GURL request_url(request.url());
3324 GURL new_url;
3325 if (content::GetContentClient()->renderer()->WillSendRequest(
3326 frame, request_url, &new_url)) {
3327 request.setURL(WebURL(new_url));
3328 }
3329
3330 content::PageTransition transition_type = content::PAGE_TRANSITION_LINK; 3323 content::PageTransition transition_type = content::PAGE_TRANSITION_LINK;
3331 DocumentState* document_state = DocumentState::FromDataSource(data_source); 3324 DocumentState* document_state = DocumentState::FromDataSource(data_source);
3332 DCHECK(document_state); 3325 DCHECK(document_state);
3333 NavigationState* navigation_state = document_state->navigation_state(); 3326 NavigationState* navigation_state = document_state->navigation_state();
3327 transition_type = navigation_state->transition_type();
3328
3329 GURL request_url(request.url());
3330 GURL new_url;
3331 if (content::GetContentClient()->renderer()->WillSendRequest(
3332 frame, transition_type, request_url, &new_url)) {
3333 request.setURL(WebURL(new_url));
3334 }
3335
3334 if (document_state->is_cache_policy_override_set()) 3336 if (document_state->is_cache_policy_override_set())
3335 request.setCachePolicy(document_state->cache_policy_override()); 3337 request.setCachePolicy(document_state->cache_policy_override());
3336 transition_type = navigation_state->transition_type();
3337 3338
3338 WebKit::WebReferrerPolicy referrer_policy; 3339 WebKit::WebReferrerPolicy referrer_policy;
3339 if (document_state && document_state->is_referrer_policy_set()) { 3340 if (document_state && document_state->is_referrer_policy_set()) {
3340 referrer_policy = document_state->referrer_policy(); 3341 referrer_policy = document_state->referrer_policy();
3341 document_state->clear_referrer_policy(); 3342 document_state->clear_referrer_policy();
3342 } else { 3343 } else {
3343 referrer_policy = frame->document().referrerPolicy(); 3344 referrer_policy = frame->document().referrerPolicy();
3344 } 3345 }
3345 3346
3346 // The request's extra data may indicate that we should set a custom user 3347 // 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
4538 void RenderViewImpl::OnScriptEvalRequest(const string16& frame_xpath, 4539 void RenderViewImpl::OnScriptEvalRequest(const string16& frame_xpath,
4539 const string16& jscript, 4540 const string16& jscript,
4540 int id, 4541 int id,
4541 bool notify_result) { 4542 bool notify_result) {
4542 EvaluateScript(frame_xpath, jscript, id, notify_result); 4543 EvaluateScript(frame_xpath, jscript, id, notify_result);
4543 } 4544 }
4544 4545
4545 void RenderViewImpl::OnPostMessageEvent( 4546 void RenderViewImpl::OnPostMessageEvent(
4546 const ViewMsg_PostMessage_Params& params) { 4547 const ViewMsg_PostMessage_Params& params) {
4547 // TODO(creis): Support sending to subframes. 4548 // TODO(creis): Support sending to subframes.
4548 WebFrame *frame = webview()->mainFrame(); 4549 WebFrame* frame = webview()->mainFrame();
4549 4550
4550 // Find the source frame if it exists. 4551 // Find the source frame if it exists.
4551 // TODO(creis): Support source subframes. 4552 // TODO(creis): Support source subframes.
4552 WebFrame* source_frame = NULL; 4553 WebFrame* source_frame = NULL;
4553 if (params.source_routing_id != MSG_ROUTING_NONE) { 4554 if (params.source_routing_id != MSG_ROUTING_NONE) {
4554 RenderViewImpl* source_view = FromRoutingID(params.source_routing_id); 4555 RenderViewImpl* source_view = FromRoutingID(params.source_routing_id);
4555 if (source_view) 4556 if (source_view)
4556 source_frame = source_view->webview()->mainFrame(); 4557 source_frame = source_view->webview()->mainFrame();
4557 } 4558 }
4558 4559
(...skipping 735 matching lines...) Expand 10 before | Expand all | Expand 10 after
5294 for (plugin_it = plugin_delegates_.begin(); 5295 for (plugin_it = plugin_delegates_.begin();
5295 plugin_it != plugin_delegates_.end(); ++plugin_it) { 5296 plugin_it != plugin_delegates_.end(); ++plugin_it) {
5296 #if defined(OS_MACOSX) 5297 #if defined(OS_MACOSX)
5297 // RenderWidget's call to setFocus can cause the underlying webview's 5298 // RenderWidget's call to setFocus can cause the underlying webview's
5298 // activation state to change just like a call to setIsActive. 5299 // activation state to change just like a call to setIsActive.
5299 if (enable) 5300 if (enable)
5300 (*plugin_it)->SetWindowFocus(true); 5301 (*plugin_it)->SetWindowFocus(true);
5301 #endif 5302 #endif
5302 (*plugin_it)->SetContentAreaFocus(enable); 5303 (*plugin_it)->SetContentAreaFocus(enable);
5303 } 5304 }
5304
5305 } 5305 }
5306 // Notify all Pepper plugins. 5306 // Notify all Pepper plugins.
5307 pepper_delegate_.OnSetFocus(enable); 5307 pepper_delegate_.OnSetFocus(enable);
5308 } 5308 }
5309 5309
5310 void RenderViewImpl::PpapiPluginFocusChanged() { 5310 void RenderViewImpl::PpapiPluginFocusChanged() {
5311 UpdateTextInputState(); 5311 UpdateTextInputState();
5312 UpdateSelectionBounds(); 5312 UpdateSelectionBounds();
5313 } 5313 }
5314 5314
(...skipping 459 matching lines...) Expand 10 before | Expand all | Expand 10 after
5774 bool RenderViewImpl::WebWidgetHandlesCompositorScheduling() const { 5774 bool RenderViewImpl::WebWidgetHandlesCompositorScheduling() const {
5775 return !!RenderThreadImpl::current()->compositor_thread(); 5775 return !!RenderThreadImpl::current()->compositor_thread();
5776 } 5776 }
5777 5777
5778 void RenderViewImpl::OnJavaBridgeInit() { 5778 void RenderViewImpl::OnJavaBridgeInit() {
5779 DCHECK(!java_bridge_dispatcher_); 5779 DCHECK(!java_bridge_dispatcher_);
5780 #if defined(ENABLE_JAVA_BRIDGE) 5780 #if defined(ENABLE_JAVA_BRIDGE)
5781 java_bridge_dispatcher_ = new JavaBridgeDispatcher(this); 5781 java_bridge_dispatcher_ = new JavaBridgeDispatcher(this);
5782 #endif 5782 #endif
5783 } 5783 }
OLDNEW
« no previous file with comments | « 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