| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "chrome/browser/browser_list.h" | 8 #include "chrome/browser/browser_list.h" |
| 9 #include "chrome/browser/browser_url_handler.h" | 9 #include "chrome/browser/browser_url_handler.h" |
| 10 #include "chrome/browser/browser_window.h" | 10 #include "chrome/browser/browser_window.h" |
| (...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 196 (params->disposition == NEW_BACKGROUND_TAB || | 196 (params->disposition == NEW_BACKGROUND_TAB || |
| 197 params->disposition == CURRENT_TAB || | 197 params->disposition == CURRENT_TAB || |
| 198 params->disposition == SINGLETON_TAB)) { | 198 params->disposition == SINGLETON_TAB)) { |
| 199 params->disposition = NEW_FOREGROUND_TAB; | 199 params->disposition = NEW_FOREGROUND_TAB; |
| 200 } | 200 } |
| 201 if (params->browser->profile()->IsOffTheRecord() && | 201 if (params->browser->profile()->IsOffTheRecord() && |
| 202 params->disposition == OFF_THE_RECORD) { | 202 params->disposition == OFF_THE_RECORD) { |
| 203 params->disposition = NEW_FOREGROUND_TAB; | 203 params->disposition = NEW_FOREGROUND_TAB; |
| 204 } | 204 } |
| 205 | 205 |
| 206 // Disposition trumps add types. ADD_SELECTED is a default, so we need to | 206 switch (params->disposition) { |
| 207 // remove it if disposition implies the tab is going to open in the | 207 case NEW_BACKGROUND_TAB: |
| 208 // background. | 208 // Disposition trumps add types. ADD_SELECTED is a default, so we need to |
| 209 if (params->disposition == NEW_BACKGROUND_TAB) | 209 // remove it if disposition implies the tab is going to open in the |
| 210 params->tabstrip_add_types &= ~TabStripModel::ADD_SELECTED; | 210 // background. |
| 211 params->tabstrip_add_types &= ~TabStripModel::ADD_SELECTED; |
| 212 break; |
| 211 | 213 |
| 212 // Code that wants to open a new window typically expects it to be shown | 214 case NEW_WINDOW: |
| 213 // automatically. | 215 case NEW_POPUP: |
| 214 if (params->disposition == NEW_WINDOW || params->disposition == NEW_POPUP) { | 216 // Code that wants to open a new window typically expects it to be shown |
| 215 params->show_window = true; | 217 // automatically. |
| 216 params->tabstrip_add_types |= TabStripModel::ADD_SELECTED; | 218 params->show_window = true; |
| 219 // Fall-through. |
| 220 case NEW_FOREGROUND_TAB: |
| 221 case SINGLETON_TAB: |
| 222 params->tabstrip_add_types |= TabStripModel::ADD_SELECTED; |
| 223 break; |
| 224 |
| 225 default: |
| 226 break; |
| 217 } | 227 } |
| 218 } | 228 } |
| 219 | 229 |
| 220 // This class makes sure the Browser object held in |params| is made visible | 230 // This class makes sure the Browser object held in |params| is made visible |
| 221 // by the time it goes out of scope, provided |params| wants it to be shown. | 231 // by the time it goes out of scope, provided |params| wants it to be shown. |
| 222 class ScopedBrowserDisplayer { | 232 class ScopedBrowserDisplayer { |
| 223 public: | 233 public: |
| 224 explicit ScopedBrowserDisplayer(browser::NavigateParams* params) | 234 explicit ScopedBrowserDisplayer(browser::NavigateParams* params) |
| 225 : params_(params) { | 235 : params_(params) { |
| 226 } | 236 } |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 297 tabstrip_add_types(TabStripModel::ADD_SELECTED), | 307 tabstrip_add_types(TabStripModel::ADD_SELECTED), |
| 298 show_window(false), | 308 show_window(false), |
| 299 browser(a_browser), | 309 browser(a_browser), |
| 300 profile(NULL) { | 310 profile(NULL) { |
| 301 } | 311 } |
| 302 | 312 |
| 303 NavigateParams::~NavigateParams() { | 313 NavigateParams::~NavigateParams() { |
| 304 } | 314 } |
| 305 | 315 |
| 306 void Navigate(NavigateParams* params) { | 316 void Navigate(NavigateParams* params) { |
| 317 Browser* browser = params->browser; |
| 307 AdjustNavigateParamsForURL(params); | 318 AdjustNavigateParamsForURL(params); |
| 308 | 319 |
| 309 params->browser = GetBrowserForDisposition(params); | 320 params->browser = GetBrowserForDisposition(params); |
| 310 if (!params->browser) | 321 if (!params->browser) |
| 311 return; | 322 return; |
| 312 // Navigate() must not return early after this point. | 323 // Navigate() must not return early after this point. |
| 313 | 324 |
| 325 if (browser != params->browser && |
| 326 params->browser->tabstrip_model()->empty()) { |
| 327 // A new window has been created. So it needs to be displayed. |
| 328 params->show_window = true; |
| 329 } |
| 330 |
| 314 // Make sure the Browser is shown if params call for it. | 331 // Make sure the Browser is shown if params call for it. |
| 315 ScopedBrowserDisplayer displayer(params); | 332 ScopedBrowserDisplayer displayer(params); |
| 316 | 333 |
| 317 // Makes sure any TabContents created by this function is destroyed if | 334 // Makes sure any TabContents created by this function is destroyed if |
| 318 // not properly added to a tab strip. | 335 // not properly added to a tab strip. |
| 319 ScopedTargetContentsOwner target_contents_owner(params); | 336 ScopedTargetContentsOwner target_contents_owner(params); |
| 320 | 337 |
| 321 // Some dispositions need coercion to base types. | 338 // Some dispositions need coercion to base types. |
| 322 NormalizeDisposition(params); | 339 NormalizeDisposition(params); |
| 323 | 340 |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 398 params->transition, | 415 params->transition, |
| 399 params->tabstrip_add_types); | 416 params->tabstrip_add_types); |
| 400 // Now that the |params->target_contents| is safely owned by the target | 417 // Now that the |params->target_contents| is safely owned by the target |
| 401 // Browser's TabStripModel, we can release ownership. | 418 // Browser's TabStripModel, we can release ownership. |
| 402 target_contents_owner.ReleaseOwnership(); | 419 target_contents_owner.ReleaseOwnership(); |
| 403 } | 420 } |
| 404 } | 421 } |
| 405 } | 422 } |
| 406 | 423 |
| 407 } // namespace browser | 424 } // namespace browser |
| OLD | NEW |