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.h" | 8 #include "chrome/browser/browser.h" |
9 #include "chrome/browser/browser_list.h" | 9 #include "chrome/browser/browser_list.h" |
10 #include "chrome/browser/browser_url_handler.h" | 10 #include "chrome/browser/browser_url_handler.h" |
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
173 (params->disposition == NEW_BACKGROUND_TAB || | 173 (params->disposition == NEW_BACKGROUND_TAB || |
174 params->disposition == CURRENT_TAB || | 174 params->disposition == CURRENT_TAB || |
175 params->disposition == SINGLETON_TAB)) { | 175 params->disposition == SINGLETON_TAB)) { |
176 params->disposition = NEW_FOREGROUND_TAB; | 176 params->disposition = NEW_FOREGROUND_TAB; |
177 } | 177 } |
178 if (params->browser->profile()->IsOffTheRecord() && | 178 if (params->browser->profile()->IsOffTheRecord() && |
179 params->disposition == OFF_THE_RECORD) { | 179 params->disposition == OFF_THE_RECORD) { |
180 params->disposition = NEW_FOREGROUND_TAB; | 180 params->disposition = NEW_FOREGROUND_TAB; |
181 } | 181 } |
182 | 182 |
183 // Disposition trumps add types. ADD_SELECTED is a default, so we need to | 183 switch (params->disposition) { |
184 // remove it if disposition implies the tab is going to open in the | 184 case NEW_BACKGROUND_TAB: |
185 // background. | 185 // Disposition trumps add types. ADD_SELECTED is a default, so we need to |
186 if (params->disposition == NEW_BACKGROUND_TAB) | 186 // remove it if disposition implies the tab is going to open in the |
187 params->tabstrip_add_types &= ~TabStripModel::ADD_SELECTED; | 187 // background. |
188 params->tabstrip_add_types &= ~TabStripModel::ADD_SELECTED; | |
189 break; | |
188 | 190 |
189 // Code that wants to open a new window typically expects it to be shown | 191 case NEW_WINDOW: |
190 // automatically. | 192 case NEW_POPUP: |
191 if (params->disposition == NEW_WINDOW || params->disposition == NEW_POPUP) { | 193 // Code that wants to open a new window typically expects it to be shown |
192 params->show_window = true; | 194 // automatically. |
193 params->tabstrip_add_types |= TabStripModel::ADD_SELECTED; | 195 params->show_window = true; |
196 // Fall-through. | |
197 case NEW_FOREGROUND_TAB: | |
198 case SINGLETON_TAB: | |
199 params->tabstrip_add_types |= TabStripModel::ADD_SELECTED; | |
200 break; | |
201 | |
202 default: | |
203 break; | |
194 } | 204 } |
195 } | 205 } |
196 | 206 |
197 // This class makes sure the Browser object held in |params| is made visible | 207 // This class makes sure the Browser object held in |params| is made visible |
198 // by the time it goes out of scope, provided |params| wants it to be shown. | 208 // by the time it goes out of scope, provided |params| wants it to be shown. |
199 class ScopedBrowserDisplayer { | 209 class ScopedBrowserDisplayer { |
200 public: | 210 public: |
201 explicit ScopedBrowserDisplayer(browser::NavigateParams* params) | 211 explicit ScopedBrowserDisplayer(browser::NavigateParams* params) |
202 : params_(params) { | 212 : params_(params) { |
203 } | 213 } |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
274 tabstrip_add_types(TabStripModel::ADD_SELECTED), | 284 tabstrip_add_types(TabStripModel::ADD_SELECTED), |
275 show_window(false), | 285 show_window(false), |
276 browser(a_browser), | 286 browser(a_browser), |
277 profile(NULL) { | 287 profile(NULL) { |
278 } | 288 } |
279 | 289 |
280 NavigateParams::~NavigateParams() { | 290 NavigateParams::~NavigateParams() { |
281 } | 291 } |
282 | 292 |
283 void Navigate(NavigateParams* params) { | 293 void Navigate(NavigateParams* params) { |
294 Browser* browser = params->browser; | |
284 params->browser = GetBrowserForDisposition(params); | 295 params->browser = GetBrowserForDisposition(params); |
285 if (!params->browser) | 296 if (!params->browser) |
286 return; | 297 return; |
287 // Navigate() must not return early after this point. | 298 // Navigate() must not return early after this point. |
288 | 299 |
300 if (browser != params->browser && | |
301 params->browser->tabstrip_model()->empty()) { | |
302 // A new window has been created. So it needs to be displayed. | |
303 params->show_window = true; | |
Ben Goodger (Google)
2010/11/17 15:57:50
Did you evaluate all cases relating to startup (in
sadrul
2010/11/17 17:02:23
I cannot honestly claim I covered all the places,
| |
304 } | |
305 | |
289 // Make sure the Browser is shown if params call for it. | 306 // Make sure the Browser is shown if params call for it. |
290 ScopedBrowserDisplayer displayer(params); | 307 ScopedBrowserDisplayer displayer(params); |
291 | 308 |
292 // Makes sure any TabContents created by this function is destroyed if | 309 // Makes sure any TabContents created by this function is destroyed if |
293 // not properly added to a tab strip. | 310 // not properly added to a tab strip. |
294 ScopedTargetContentsOwner target_contents_owner(params); | 311 ScopedTargetContentsOwner target_contents_owner(params); |
295 | 312 |
296 // Some dispositions need coercion to base types. | 313 // Some dispositions need coercion to base types. |
297 NormalizeDisposition(params); | 314 NormalizeDisposition(params); |
298 | 315 |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
373 params->transition, | 390 params->transition, |
374 params->tabstrip_add_types); | 391 params->tabstrip_add_types); |
375 // Now that the |params->target_contents| is safely owned by the target | 392 // Now that the |params->target_contents| is safely owned by the target |
376 // Browser's TabStripModel, we can release ownership. | 393 // Browser's TabStripModel, we can release ownership. |
377 target_contents_owner.ReleaseOwnership(); | 394 target_contents_owner.ReleaseOwnership(); |
378 } | 395 } |
379 } | 396 } |
380 } | 397 } |
381 | 398 |
382 } // namespace browser | 399 } // namespace browser |
OLD | NEW |