Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "chrome/browser/browser_url_handler.h" | 10 #include "chrome/browser/browser_url_handler.h" |
| (...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 339 const GURL& a_url, | 339 const GURL& a_url, |
| 340 PageTransition::Type a_transition) | 340 PageTransition::Type a_transition) |
| 341 : url(a_url), | 341 : url(a_url), |
| 342 target_contents(NULL), | 342 target_contents(NULL), |
| 343 source_contents(NULL), | 343 source_contents(NULL), |
| 344 disposition(CURRENT_TAB), | 344 disposition(CURRENT_TAB), |
| 345 transition(a_transition), | 345 transition(a_transition), |
| 346 tabstrip_index(-1), | 346 tabstrip_index(-1), |
| 347 tabstrip_add_types(TabStripModel::ADD_ACTIVE), | 347 tabstrip_add_types(TabStripModel::ADD_ACTIVE), |
| 348 window_action(NO_ACTION), | 348 window_action(NO_ACTION), |
| 349 user_gesture(true), | |
| 349 path_behavior(RESPECT), | 350 path_behavior(RESPECT), |
| 350 browser(a_browser), | 351 browser(a_browser), |
| 351 profile(NULL) { | 352 profile(NULL) { |
| 352 } | 353 } |
| 353 | 354 |
| 354 NavigateParams::NavigateParams(Browser* a_browser, | 355 NavigateParams::NavigateParams(Browser* a_browser, |
| 355 TabContentsWrapper* a_target_contents) | 356 TabContentsWrapper* a_target_contents) |
| 356 : target_contents(a_target_contents), | 357 : target_contents(a_target_contents), |
| 357 source_contents(NULL), | 358 source_contents(NULL), |
| 358 disposition(CURRENT_TAB), | 359 disposition(CURRENT_TAB), |
| 359 transition(PageTransition::LINK), | 360 transition(PageTransition::LINK), |
| 360 tabstrip_index(-1), | 361 tabstrip_index(-1), |
| 361 tabstrip_add_types(TabStripModel::ADD_ACTIVE), | 362 tabstrip_add_types(TabStripModel::ADD_ACTIVE), |
| 362 window_action(NO_ACTION), | 363 window_action(NO_ACTION), |
| 364 user_gesture(true), | |
| 363 path_behavior(RESPECT), | 365 path_behavior(RESPECT), |
| 364 browser(a_browser), | 366 browser(a_browser), |
| 365 profile(NULL) { | 367 profile(NULL) { |
| 366 } | 368 } |
| 367 | 369 |
| 368 NavigateParams::~NavigateParams() { | 370 NavigateParams::~NavigateParams() { |
| 369 } | 371 } |
| 370 | 372 |
| 371 void Navigate(NavigateParams* params) { | 373 void Navigate(NavigateParams* params) { |
| 372 Browser* source_browser = params->browser; | 374 Browser* source_browser = params->browser; |
| 373 AdjustNavigateParamsForURL(params); | 375 AdjustNavigateParamsForURL(params); |
| 374 | 376 |
| 377 // Adjustments based on size and type of window; may affect disposition. | |
| 378 if (source_browser && source_browser->window()) | |
| 379 source_browser->window()->AdjustNavigateParams(params); | |
|
Ben Goodger (Google)
2011/04/20 19:10:32
I worry that this connection couples the BrowserWi
stevenjb
2011/04/20 20:43:40
Sounds reasonable to me. Done.
On 2011/04/20 19:1
| |
| 380 | |
| 375 params->browser = GetBrowserForDisposition(params); | 381 params->browser = GetBrowserForDisposition(params); |
| 376 if (!params->browser) | 382 if (!params->browser) |
| 377 return; | 383 return; |
| 378 // Navigate() must not return early after this point. | 384 // Navigate() must not return early after this point. |
| 379 | 385 |
| 380 if (GetSourceProfile(params, source_browser) != params->browser->profile()) { | 386 if (GetSourceProfile(params, source_browser) != params->browser->profile()) { |
| 381 // A tab is being opened from a link from a different profile, we must reset | 387 // A tab is being opened from a link from a different profile, we must reset |
| 382 // source information that may cause state to be shared. | 388 // source information that may cause state to be shared. |
| 383 params->source_contents = NULL; | 389 params->source_contents = NULL; |
| 384 params->referrer = GURL(); | 390 params->referrer = GURL(); |
| 385 } | 391 } |
| 386 | 392 |
| 387 if (params->window_action == browser::NavigateParams::NO_ACTION && | |
| 388 source_browser != params->browser && | |
| 389 params->browser->tabstrip_model()->empty()) { | |
| 390 // A new window has been created. So it needs to be displayed. | |
| 391 params->window_action = browser::NavigateParams::SHOW_WINDOW; | |
| 392 } | |
| 393 | |
| 394 // Make sure the Browser is shown if params call for it. | 393 // Make sure the Browser is shown if params call for it. |
| 395 ScopedBrowserDisplayer displayer(params); | 394 ScopedBrowserDisplayer displayer(params); |
| 396 | 395 |
| 397 // Makes sure any TabContents created by this function is destroyed if | 396 // Makes sure any TabContents created by this function is destroyed if |
| 398 // not properly added to a tab strip. | 397 // not properly added to a tab strip. |
| 399 ScopedTargetContentsOwner target_contents_owner(params); | 398 ScopedTargetContentsOwner target_contents_owner(params); |
| 400 | 399 |
| 401 // Some dispositions need coercion to base types. | 400 // Some dispositions need coercion to base types. |
| 402 NormalizeDisposition(params); | 401 NormalizeDisposition(params); |
| 403 | 402 |
| 403 // If a new window has been created, it needs to be displayed. | |
| 404 if (params->window_action == browser::NavigateParams::NO_ACTION && | |
| 405 source_browser != params->browser && | |
| 406 params->browser->tabstrip_model()->empty()) { | |
| 407 params->window_action = browser::NavigateParams::SHOW_WINDOW; | |
| 408 } | |
| 409 | |
| 410 // If we create a popup window from a non user-gesture, don't activate it. | |
| 411 if (params->window_action == browser::NavigateParams::SHOW_WINDOW && | |
| 412 params->disposition == NEW_POPUP && | |
| 413 params->user_gesture == false) { | |
| 414 params->window_action = browser::NavigateParams::SHOW_WINDOW_INACTIVE; | |
| 415 } | |
| 416 | |
| 404 // Determine if the navigation was user initiated. If it was, we need to | 417 // Determine if the navigation was user initiated. If it was, we need to |
| 405 // inform the target TabContents, and we may need to update the UI. | 418 // inform the target TabContents, and we may need to update the UI. |
| 406 PageTransition::Type base_transition = | 419 PageTransition::Type base_transition = |
| 407 PageTransition::StripQualifier(params->transition); | 420 PageTransition::StripQualifier(params->transition); |
| 408 bool user_initiated = base_transition == PageTransition::TYPED || | 421 bool user_initiated = base_transition == PageTransition::TYPED || |
| 409 base_transition == PageTransition::AUTO_BOOKMARK; | 422 base_transition == PageTransition::AUTO_BOOKMARK; |
| 410 | 423 |
| 411 // Check if this is a singleton tab that already exists | 424 // Check if this is a singleton tab that already exists |
| 412 int singleton_index = GetIndexOfSingletonTab(params); | 425 int singleton_index = GetIndexOfSingletonTab(params); |
| 413 | 426 |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 492 params->url, params->referrer, params->transition); | 505 params->url, params->referrer, params->transition); |
| 493 } | 506 } |
| 494 | 507 |
| 495 // If the singleton tab isn't already selected, select it. | 508 // If the singleton tab isn't already selected, select it. |
| 496 if (params->source_contents != params->target_contents) | 509 if (params->source_contents != params->target_contents) |
| 497 params->browser->ActivateTabAt(singleton_index, user_initiated); | 510 params->browser->ActivateTabAt(singleton_index, user_initiated); |
| 498 } | 511 } |
| 499 } | 512 } |
| 500 | 513 |
| 501 } // namespace browser | 514 } // namespace browser |
| OLD | NEW |