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

Side by Side Diff: chrome/browser/ui/browser_navigator.cc

Issue 21378002: Support POST in browser navaigation. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: move PageNavigator Destructor body back Created 7 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 "chrome/browser/ui/browser_navigator.h" 5 #include "chrome/browser/ui/browser_navigator.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/prefs/pref_service.h" 10 #include "base/prefs/pref_service.h"
(...skipping 27 matching lines...) Expand all
38 #include "content/public/browser/notification_service.h" 38 #include "content/public/browser/notification_service.h"
39 #include "content/public/browser/render_view_host.h" 39 #include "content/public/browser/render_view_host.h"
40 #include "content/public/browser/web_contents.h" 40 #include "content/public/browser/web_contents.h"
41 #include "content/public/browser/web_contents_view.h" 41 #include "content/public/browser/web_contents_view.h"
42 42
43 #if defined(USE_AURA) 43 #if defined(USE_AURA)
44 #include "ui/aura/window.h" 44 #include "ui/aura/window.h"
45 #endif 45 #endif
46 46
47 using content::GlobalRequestID; 47 using content::GlobalRequestID;
48 using content::NavigationController;
48 using content::WebContents; 49 using content::WebContents;
49 50
50 class BrowserNavigatorWebContentsAdoption { 51 class BrowserNavigatorWebContentsAdoption {
51 public: 52 public:
52 static void AttachTabHelpers(content::WebContents* contents) { 53 static void AttachTabHelpers(content::WebContents* contents) {
53 BrowserTabContents::AttachTabHelpers(contents); 54 BrowserTabContents::AttachTabHelpers(contents);
54 } 55 }
55 }; 56 };
56 57
57 namespace { 58 namespace {
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
236 return Profile::FromBrowserContext( 237 return Profile::FromBrowserContext(
237 params->source_contents->GetBrowserContext()); 238 params->source_contents->GetBrowserContext());
238 } 239 }
239 240
240 return params->initiating_profile; 241 return params->initiating_profile;
241 } 242 }
242 243
243 void LoadURLInContents(WebContents* target_contents, 244 void LoadURLInContents(WebContents* target_contents,
244 const GURL& url, 245 const GURL& url,
245 chrome::NavigateParams* params) { 246 chrome::NavigateParams* params) {
246 content::NavigationController::LoadURLParams load_url_params(url); 247 NavigationController::LoadURLParams load_url_params(url);
247 load_url_params.referrer = params->referrer; 248 load_url_params.referrer = params->referrer;
248 load_url_params.transition_type = params->transition; 249 load_url_params.transition_type = params->transition;
249 load_url_params.extra_headers = params->extra_headers; 250 load_url_params.extra_headers = params->extra_headers;
250 load_url_params.should_replace_current_entry = 251 load_url_params.should_replace_current_entry =
251 params->should_replace_current_entry; 252 params->should_replace_current_entry;
252 253
253 if (params->transferred_global_request_id != GlobalRequestID()) { 254 if (params->transferred_global_request_id != GlobalRequestID()) {
254 load_url_params.is_renderer_initiated = params->is_renderer_initiated; 255 load_url_params.is_renderer_initiated = params->is_renderer_initiated;
255 load_url_params.transferred_global_request_id = 256 load_url_params.transferred_global_request_id =
256 params->transferred_global_request_id; 257 params->transferred_global_request_id;
257 } else if (params->is_renderer_initiated) { 258 } else if (params->is_renderer_initiated) {
258 load_url_params.is_renderer_initiated = true; 259 load_url_params.is_renderer_initiated = true;
259 } 260 }
261
262 // Only allows the browser-initiated navigation to use POST.
263 if (params->uses_post && !params->is_renderer_initiated) {
264 load_url_params.load_type =
265 NavigationController::LOAD_TYPE_BROWSER_INITIATED_HTTP_POST;
266 load_url_params.browser_initiated_post_data =
267 params->browser_initiated_post_data;
268 }
260 target_contents->GetController().LoadURLWithParams(load_url_params); 269 target_contents->GetController().LoadURLWithParams(load_url_params);
261 } 270 }
262 271
263 // This class makes sure the Browser object held in |params| is made visible 272 // This class makes sure the Browser object held in |params| is made visible
264 // by the time it goes out of scope, provided |params| wants it to be shown. 273 // by the time it goes out of scope, provided |params| wants it to be shown.
265 class ScopedBrowserDisplayer { 274 class ScopedBrowserDisplayer {
266 public: 275 public:
267 explicit ScopedBrowserDisplayer(chrome::NavigateParams* params) 276 explicit ScopedBrowserDisplayer(chrome::NavigateParams* params)
268 : params_(params) { 277 : params_(params) {
269 } 278 }
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
375 } 384 }
376 385
377 } // namespace 386 } // namespace
378 387
379 namespace chrome { 388 namespace chrome {
380 389
381 NavigateParams::NavigateParams(Browser* a_browser, 390 NavigateParams::NavigateParams(Browser* a_browser,
382 const GURL& a_url, 391 const GURL& a_url,
383 content::PageTransition a_transition) 392 content::PageTransition a_transition)
384 : url(a_url), 393 : url(a_url),
394 uses_post(false),
385 target_contents(NULL), 395 target_contents(NULL),
386 source_contents(NULL), 396 source_contents(NULL),
387 disposition(CURRENT_TAB), 397 disposition(CURRENT_TAB),
388 transition(a_transition), 398 transition(a_transition),
389 is_renderer_initiated(false), 399 is_renderer_initiated(false),
390 tabstrip_index(-1), 400 tabstrip_index(-1),
391 tabstrip_add_types(TabStripModel::ADD_ACTIVE), 401 tabstrip_add_types(TabStripModel::ADD_ACTIVE),
392 window_action(NO_ACTION), 402 window_action(NO_ACTION),
393 user_gesture(true), 403 user_gesture(true),
394 path_behavior(RESPECT), 404 path_behavior(RESPECT),
395 ref_behavior(IGNORE_REF), 405 ref_behavior(IGNORE_REF),
396 browser(a_browser), 406 browser(a_browser),
397 initiating_profile(NULL), 407 initiating_profile(NULL),
398 host_desktop_type(GetHostDesktop(a_browser)), 408 host_desktop_type(GetHostDesktop(a_browser)),
399 should_replace_current_entry(false), 409 should_replace_current_entry(false),
400 should_set_opener(false) { 410 should_set_opener(false) {
401 } 411 }
402 412
403 NavigateParams::NavigateParams(Browser* a_browser, 413 NavigateParams::NavigateParams(Browser* a_browser,
404 WebContents* a_target_contents) 414 WebContents* a_target_contents)
405 : target_contents(a_target_contents), 415 : uses_post(false),
416 target_contents(a_target_contents),
406 source_contents(NULL), 417 source_contents(NULL),
407 disposition(CURRENT_TAB), 418 disposition(CURRENT_TAB),
408 transition(content::PAGE_TRANSITION_LINK), 419 transition(content::PAGE_TRANSITION_LINK),
409 is_renderer_initiated(false), 420 is_renderer_initiated(false),
410 tabstrip_index(-1), 421 tabstrip_index(-1),
411 tabstrip_add_types(TabStripModel::ADD_ACTIVE), 422 tabstrip_add_types(TabStripModel::ADD_ACTIVE),
412 window_action(NO_ACTION), 423 window_action(NO_ACTION),
413 user_gesture(true), 424 user_gesture(true),
414 path_behavior(RESPECT), 425 path_behavior(RESPECT),
415 ref_behavior(IGNORE_REF), 426 ref_behavior(IGNORE_REF),
416 browser(a_browser), 427 browser(a_browser),
417 initiating_profile(NULL), 428 initiating_profile(NULL),
418 host_desktop_type(GetHostDesktop(a_browser)), 429 host_desktop_type(GetHostDesktop(a_browser)),
419 should_replace_current_entry(false), 430 should_replace_current_entry(false),
420 should_set_opener(false) { 431 should_set_opener(false) {
421 } 432 }
422 433
423 NavigateParams::NavigateParams(Profile* a_profile, 434 NavigateParams::NavigateParams(Profile* a_profile,
424 const GURL& a_url, 435 const GURL& a_url,
425 content::PageTransition a_transition) 436 content::PageTransition a_transition)
426 : url(a_url), 437 : url(a_url),
438 uses_post(false),
427 target_contents(NULL), 439 target_contents(NULL),
428 source_contents(NULL), 440 source_contents(NULL),
429 disposition(NEW_FOREGROUND_TAB), 441 disposition(NEW_FOREGROUND_TAB),
430 transition(a_transition), 442 transition(a_transition),
431 is_renderer_initiated(false), 443 is_renderer_initiated(false),
432 tabstrip_index(-1), 444 tabstrip_index(-1),
433 tabstrip_add_types(TabStripModel::ADD_ACTIVE), 445 tabstrip_add_types(TabStripModel::ADD_ACTIVE),
434 window_action(SHOW_WINDOW), 446 window_action(SHOW_WINDOW),
435 user_gesture(true), 447 user_gesture(true),
436 path_behavior(RESPECT), 448 path_behavior(RESPECT),
(...skipping 11 matching lines...) Expand all
448 const content::OpenURLParams& params) { 460 const content::OpenURLParams& params) {
449 nav_params->referrer = params.referrer; 461 nav_params->referrer = params.referrer;
450 nav_params->extra_headers = params.extra_headers; 462 nav_params->extra_headers = params.extra_headers;
451 nav_params->disposition = params.disposition; 463 nav_params->disposition = params.disposition;
452 nav_params->override_encoding = params.override_encoding; 464 nav_params->override_encoding = params.override_encoding;
453 nav_params->is_renderer_initiated = params.is_renderer_initiated; 465 nav_params->is_renderer_initiated = params.is_renderer_initiated;
454 nav_params->transferred_global_request_id = 466 nav_params->transferred_global_request_id =
455 params.transferred_global_request_id; 467 params.transferred_global_request_id;
456 nav_params->should_replace_current_entry = 468 nav_params->should_replace_current_entry =
457 params.should_replace_current_entry; 469 params.should_replace_current_entry;
470 nav_params->uses_post = params.uses_post;
471 nav_params->browser_initiated_post_data = params.browser_initiated_post_data;
458 } 472 }
459 473
460 void Navigate(NavigateParams* params) { 474 void Navigate(NavigateParams* params) {
461 Browser* source_browser = params->browser; 475 Browser* source_browser = params->browser;
462 if (source_browser) 476 if (source_browser)
463 params->initiating_profile = source_browser->profile(); 477 params->initiating_profile = source_browser->profile();
464 DCHECK(params->initiating_profile); 478 DCHECK(params->initiating_profile);
465 479
466 if (!AdjustNavigateParamsForURL(params)) 480 if (!AdjustNavigateParamsForURL(params))
467 return; 481 return;
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after
676 bool reverse_on_redirect = false; 690 bool reverse_on_redirect = false;
677 content::BrowserURLHandler::GetInstance()->RewriteURLIfNecessary( 691 content::BrowserURLHandler::GetInstance()->RewriteURLIfNecessary(
678 &rewritten_url, browser_context, &reverse_on_redirect); 692 &rewritten_url, browser_context, &reverse_on_redirect);
679 693
680 // Some URLs are mapped to uber subpages. Do not allow them in incognito. 694 // Some URLs are mapped to uber subpages. Do not allow them in incognito.
681 return !(rewritten_url.scheme() == chrome::kChromeUIScheme && 695 return !(rewritten_url.scheme() == chrome::kChromeUIScheme &&
682 rewritten_url.host() == chrome::kChromeUIUberHost); 696 rewritten_url.host() == chrome::kChromeUIUberHost);
683 } 697 }
684 698
685 } // namespace chrome 699 } // namespace chrome
OLDNEW
« no previous file with comments | « chrome/browser/ui/browser_navigator.h ('k') | chrome/browser/ui/browser_navigator_browsertest.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698