Chromium Code Reviews| 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 "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/memory/ref_counted_memory.h" | |
| 10 #include "base/prefs/pref_service.h" | 11 #include "base/prefs/pref_service.h" |
| 11 #include "base/strings/stringprintf.h" | 12 #include "base/strings/stringprintf.h" |
| 12 #include "base/strings/utf_string_conversions.h" | 13 #include "base/strings/utf_string_conversions.h" |
| 13 #include "chrome/browser/browser_about_handler.h" | 14 #include "chrome/browser/browser_about_handler.h" |
| 14 #include "chrome/browser/chrome_notification_types.h" | 15 #include "chrome/browser/chrome_notification_types.h" |
| 15 #include "chrome/browser/extensions/extension_service.h" | 16 #include "chrome/browser/extensions/extension_service.h" |
| 16 #include "chrome/browser/extensions/tab_helper.h" | 17 #include "chrome/browser/extensions/tab_helper.h" |
| 17 #include "chrome/browser/google/google_url_tracker.h" | 18 #include "chrome/browser/google/google_url_tracker.h" |
| 18 #include "chrome/browser/prefs/incognito_mode_prefs.h" | 19 #include "chrome/browser/prefs/incognito_mode_prefs.h" |
| 19 #include "chrome/browser/prerender/prerender_manager.h" | 20 #include "chrome/browser/prerender/prerender_manager.h" |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 38 #include "content/public/browser/notification_service.h" | 39 #include "content/public/browser/notification_service.h" |
| 39 #include "content/public/browser/render_view_host.h" | 40 #include "content/public/browser/render_view_host.h" |
| 40 #include "content/public/browser/web_contents.h" | 41 #include "content/public/browser/web_contents.h" |
| 41 #include "content/public/browser/web_contents_view.h" | 42 #include "content/public/browser/web_contents_view.h" |
| 42 | 43 |
| 43 #if defined(USE_AURA) | 44 #if defined(USE_AURA) |
| 44 #include "ui/aura/window.h" | 45 #include "ui/aura/window.h" |
| 45 #endif | 46 #endif |
| 46 | 47 |
| 47 using content::GlobalRequestID; | 48 using content::GlobalRequestID; |
| 49 using content::NavigationController; | |
| 48 using content::WebContents; | 50 using content::WebContents; |
| 49 | 51 |
| 50 class BrowserNavigatorWebContentsAdoption { | 52 class BrowserNavigatorWebContentsAdoption { |
| 51 public: | 53 public: |
| 52 static void AttachTabHelpers(content::WebContents* contents) { | 54 static void AttachTabHelpers(content::WebContents* contents) { |
| 53 BrowserTabContents::AttachTabHelpers(contents); | 55 BrowserTabContents::AttachTabHelpers(contents); |
| 54 } | 56 } |
| 55 }; | 57 }; |
| 56 | 58 |
| 57 namespace { | 59 namespace { |
| (...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 236 return Profile::FromBrowserContext( | 238 return Profile::FromBrowserContext( |
| 237 params->source_contents->GetBrowserContext()); | 239 params->source_contents->GetBrowserContext()); |
| 238 } | 240 } |
| 239 | 241 |
| 240 return params->initiating_profile; | 242 return params->initiating_profile; |
| 241 } | 243 } |
| 242 | 244 |
| 243 void LoadURLInContents(WebContents* target_contents, | 245 void LoadURLInContents(WebContents* target_contents, |
| 244 const GURL& url, | 246 const GURL& url, |
| 245 chrome::NavigateParams* params) { | 247 chrome::NavigateParams* params) { |
| 246 content::NavigationController::LoadURLParams load_url_params(url); | 248 NavigationController::LoadURLParams load_url_params(url); |
| 247 load_url_params.referrer = params->referrer; | 249 load_url_params.referrer = params->referrer; |
| 248 load_url_params.transition_type = params->transition; | 250 load_url_params.transition_type = params->transition; |
| 249 load_url_params.extra_headers = params->extra_headers; | 251 load_url_params.extra_headers = params->extra_headers; |
| 250 load_url_params.should_replace_current_entry = | 252 load_url_params.should_replace_current_entry = |
| 251 params->should_replace_current_entry; | 253 params->should_replace_current_entry; |
| 252 | 254 |
| 253 if (params->transferred_global_request_id != GlobalRequestID()) { | 255 if (params->transferred_global_request_id != GlobalRequestID()) { |
| 254 load_url_params.is_renderer_initiated = params->is_renderer_initiated; | 256 load_url_params.is_renderer_initiated = params->is_renderer_initiated; |
| 255 load_url_params.transferred_global_request_id = | 257 load_url_params.transferred_global_request_id = |
| 256 params->transferred_global_request_id; | 258 params->transferred_global_request_id; |
| 257 } else if (params->is_renderer_initiated) { | 259 } else if (params->is_renderer_initiated) { |
| 258 load_url_params.is_renderer_initiated = true; | 260 load_url_params.is_renderer_initiated = true; |
| 259 } | 261 } |
| 262 | |
| 263 if (params->uses_post) { | |
| 264 // Only allows the user-initiated navigation to use POST? | |
|
Charlie Reis
2013/08/02 16:36:41
Why is there a question here? Is this unresolved?
Johnny(Jianning) Ding
2013/08/02 23:22:55
Done.
| |
| 265 load_url_params.load_type = | |
| 266 NavigationController::LOAD_TYPE_BROWSER_INITIATED_HTTP_POST; | |
| 267 load_url_params.browser_initiated_post_data = | |
| 268 base::RefCountedString::TakeString(¶ms->post_data); | |
|
Charlie Reis
2013/08/02 16:36:41
I agree with joth. Is it possible to use scoped_r
Johnny(Jianning) Ding
2013/08/02 23:22:55
Done.
| |
| 269 } | |
| 260 target_contents->GetController().LoadURLWithParams(load_url_params); | 270 target_contents->GetController().LoadURLWithParams(load_url_params); |
| 261 } | 271 } |
| 262 | 272 |
| 263 // This class makes sure the Browser object held in |params| is made visible | 273 // 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. | 274 // by the time it goes out of scope, provided |params| wants it to be shown. |
| 265 class ScopedBrowserDisplayer { | 275 class ScopedBrowserDisplayer { |
| 266 public: | 276 public: |
| 267 explicit ScopedBrowserDisplayer(chrome::NavigateParams* params) | 277 explicit ScopedBrowserDisplayer(chrome::NavigateParams* params) |
| 268 : params_(params) { | 278 : params_(params) { |
| 269 } | 279 } |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 386 is_renderer_initiated(false), | 396 is_renderer_initiated(false), |
| 387 tabstrip_index(-1), | 397 tabstrip_index(-1), |
| 388 tabstrip_add_types(TabStripModel::ADD_ACTIVE), | 398 tabstrip_add_types(TabStripModel::ADD_ACTIVE), |
| 389 window_action(NO_ACTION), | 399 window_action(NO_ACTION), |
| 390 user_gesture(true), | 400 user_gesture(true), |
| 391 path_behavior(RESPECT), | 401 path_behavior(RESPECT), |
| 392 ref_behavior(IGNORE_REF), | 402 ref_behavior(IGNORE_REF), |
| 393 browser(a_browser), | 403 browser(a_browser), |
| 394 initiating_profile(NULL), | 404 initiating_profile(NULL), |
| 395 host_desktop_type(GetHostDesktop(a_browser)), | 405 host_desktop_type(GetHostDesktop(a_browser)), |
| 396 should_replace_current_entry(false) { | 406 should_replace_current_entry(false), |
| 407 uses_post(false) { | |
| 397 } | 408 } |
| 398 | 409 |
| 399 NavigateParams::NavigateParams(Browser* a_browser, | 410 NavigateParams::NavigateParams(Browser* a_browser, |
| 400 WebContents* a_target_contents) | 411 WebContents* a_target_contents) |
| 401 : target_contents(a_target_contents), | 412 : target_contents(a_target_contents), |
| 402 source_contents(NULL), | 413 source_contents(NULL), |
| 403 disposition(CURRENT_TAB), | 414 disposition(CURRENT_TAB), |
| 404 transition(content::PAGE_TRANSITION_LINK), | 415 transition(content::PAGE_TRANSITION_LINK), |
| 405 is_renderer_initiated(false), | 416 is_renderer_initiated(false), |
| 406 tabstrip_index(-1), | 417 tabstrip_index(-1), |
| 407 tabstrip_add_types(TabStripModel::ADD_ACTIVE), | 418 tabstrip_add_types(TabStripModel::ADD_ACTIVE), |
| 408 window_action(NO_ACTION), | 419 window_action(NO_ACTION), |
| 409 user_gesture(true), | 420 user_gesture(true), |
| 410 path_behavior(RESPECT), | 421 path_behavior(RESPECT), |
| 411 ref_behavior(IGNORE_REF), | 422 ref_behavior(IGNORE_REF), |
| 412 browser(a_browser), | 423 browser(a_browser), |
| 413 initiating_profile(NULL), | 424 initiating_profile(NULL), |
| 414 host_desktop_type(GetHostDesktop(a_browser)), | 425 host_desktop_type(GetHostDesktop(a_browser)), |
| 415 should_replace_current_entry(false) { | 426 should_replace_current_entry(false), |
| 427 uses_post(false) { | |
| 416 } | 428 } |
| 417 | 429 |
| 418 NavigateParams::NavigateParams(Profile* a_profile, | 430 NavigateParams::NavigateParams(Profile* a_profile, |
| 419 const GURL& a_url, | 431 const GURL& a_url, |
| 420 content::PageTransition a_transition) | 432 content::PageTransition a_transition) |
| 421 : url(a_url), | 433 : url(a_url), |
| 422 target_contents(NULL), | 434 target_contents(NULL), |
| 423 source_contents(NULL), | 435 source_contents(NULL), |
| 424 disposition(NEW_FOREGROUND_TAB), | 436 disposition(NEW_FOREGROUND_TAB), |
| 425 transition(a_transition), | 437 transition(a_transition), |
| 426 is_renderer_initiated(false), | 438 is_renderer_initiated(false), |
| 427 tabstrip_index(-1), | 439 tabstrip_index(-1), |
| 428 tabstrip_add_types(TabStripModel::ADD_ACTIVE), | 440 tabstrip_add_types(TabStripModel::ADD_ACTIVE), |
| 429 window_action(SHOW_WINDOW), | 441 window_action(SHOW_WINDOW), |
| 430 user_gesture(true), | 442 user_gesture(true), |
| 431 path_behavior(RESPECT), | 443 path_behavior(RESPECT), |
| 432 ref_behavior(IGNORE_REF), | 444 ref_behavior(IGNORE_REF), |
| 433 browser(NULL), | 445 browser(NULL), |
| 434 initiating_profile(a_profile), | 446 initiating_profile(a_profile), |
| 435 host_desktop_type(chrome::GetActiveDesktop()), | 447 host_desktop_type(chrome::GetActiveDesktop()), |
| 436 should_replace_current_entry(false) { | 448 should_replace_current_entry(false), |
| 449 uses_post(false) { | |
| 437 } | 450 } |
| 438 | 451 |
| 439 NavigateParams::~NavigateParams() {} | 452 NavigateParams::~NavigateParams() {} |
| 440 | 453 |
| 441 void FillNavigateParamsFromOpenURLParams(chrome::NavigateParams* nav_params, | 454 void FillNavigateParamsFromOpenURLParams(chrome::NavigateParams* nav_params, |
| 442 const content::OpenURLParams& params) { | 455 const content::OpenURLParams& params) { |
| 443 nav_params->referrer = params.referrer; | 456 nav_params->referrer = params.referrer; |
| 444 nav_params->extra_headers = params.extra_headers; | 457 nav_params->extra_headers = params.extra_headers; |
| 445 nav_params->disposition = params.disposition; | 458 nav_params->disposition = params.disposition; |
| 446 nav_params->override_encoding = params.override_encoding; | 459 nav_params->override_encoding = params.override_encoding; |
| 447 nav_params->is_renderer_initiated = params.is_renderer_initiated; | 460 nav_params->is_renderer_initiated = params.is_renderer_initiated; |
| 448 nav_params->transferred_global_request_id = | 461 nav_params->transferred_global_request_id = |
| 449 params.transferred_global_request_id; | 462 params.transferred_global_request_id; |
| 450 nav_params->should_replace_current_entry = | 463 nav_params->should_replace_current_entry = |
| 451 params.should_replace_current_entry; | 464 params.should_replace_current_entry; |
| 465 nav_params->uses_post = params.uses_post; | |
| 466 nav_params->post_data = params.post_data; | |
| 452 } | 467 } |
| 453 | 468 |
| 454 void Navigate(NavigateParams* params) { | 469 void Navigate(NavigateParams* params) { |
| 455 Browser* source_browser = params->browser; | 470 Browser* source_browser = params->browser; |
| 456 if (source_browser) | 471 if (source_browser) |
| 457 params->initiating_profile = source_browser->profile(); | 472 params->initiating_profile = source_browser->profile(); |
| 458 DCHECK(params->initiating_profile); | 473 DCHECK(params->initiating_profile); |
| 459 | 474 |
| 460 if (!AdjustNavigateParamsForURL(params)) | 475 if (!AdjustNavigateParamsForURL(params)) |
| 461 return; | 476 return; |
| (...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 670 bool reverse_on_redirect = false; | 685 bool reverse_on_redirect = false; |
| 671 content::BrowserURLHandler::GetInstance()->RewriteURLIfNecessary( | 686 content::BrowserURLHandler::GetInstance()->RewriteURLIfNecessary( |
| 672 &rewritten_url, browser_context, &reverse_on_redirect); | 687 &rewritten_url, browser_context, &reverse_on_redirect); |
| 673 | 688 |
| 674 // Some URLs are mapped to uber subpages. Do not allow them in incognito. | 689 // Some URLs are mapped to uber subpages. Do not allow them in incognito. |
| 675 return !(rewritten_url.scheme() == chrome::kChromeUIScheme && | 690 return !(rewritten_url.scheme() == chrome::kChromeUIScheme && |
| 676 rewritten_url.host() == chrome::kChromeUIUberHost); | 691 rewritten_url.host() == chrome::kChromeUIUberHost); |
| 677 } | 692 } |
| 678 | 693 |
| 679 } // namespace chrome | 694 } // namespace chrome |
| OLD | NEW |