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 "base/stringprintf.h" | 10 #include "base/stringprintf.h" |
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
235 return source_browser->profile(); | 235 return source_browser->profile(); |
236 | 236 |
237 if (params->profile) | 237 if (params->profile) |
238 return params->profile; | 238 return params->profile; |
239 | 239 |
240 // We couldn't find one in any of the source metadata, so we'll fall back to | 240 // We couldn't find one in any of the source metadata, so we'll fall back to |
241 // the profile associated with the target browser. | 241 // the profile associated with the target browser. |
242 return params->browser->profile(); | 242 return params->browser->profile(); |
243 } | 243 } |
244 | 244 |
| 245 void LoadURLInContents(TabContents* target_contents, |
| 246 const GURL& url, |
| 247 browser::NavigateParams* params, |
| 248 const std::string& extra_headers) { |
| 249 if (params->transferred_global_request_id != GlobalRequestID()) { |
| 250 target_contents->controller().TransferURL( |
| 251 url, params->referrer, params->transition, extra_headers, |
| 252 params->transferred_global_request_id, |
| 253 params->is_renderer_initiated); |
| 254 } else if (params->is_renderer_initiated) { |
| 255 target_contents->controller().LoadURLFromRenderer( |
| 256 url, params->referrer, params->transition, extra_headers); |
| 257 } else { |
| 258 target_contents->controller().LoadURL( |
| 259 url, params->referrer, params->transition, extra_headers); |
| 260 } |
| 261 |
| 262 } |
245 | 263 |
246 // This class makes sure the Browser object held in |params| is made visible | 264 // This class makes sure the Browser object held in |params| is made visible |
247 // by the time it goes out of scope, provided |params| wants it to be shown. | 265 // by the time it goes out of scope, provided |params| wants it to be shown. |
248 class ScopedBrowserDisplayer { | 266 class ScopedBrowserDisplayer { |
249 public: | 267 public: |
250 explicit ScopedBrowserDisplayer(browser::NavigateParams* params) | 268 explicit ScopedBrowserDisplayer(browser::NavigateParams* params) |
251 : params_(params) { | 269 : params_(params) { |
252 } | 270 } |
253 ~ScopedBrowserDisplayer() { | 271 ~ScopedBrowserDisplayer() { |
254 if (params_->window_action == browser::NavigateParams::SHOW_WINDOW_INACTIVE) | 272 if (params_->window_action == browser::NavigateParams::SHOW_WINDOW_INACTIVE) |
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
492 } | 510 } |
493 | 511 |
494 InitializeExtraHeaders(params, params->target_contents->profile(), | 512 InitializeExtraHeaders(params, params->target_contents->profile(), |
495 &extra_headers); | 513 &extra_headers); |
496 | 514 |
497 // Try to handle non-navigational URLs that popup dialogs and such, these | 515 // Try to handle non-navigational URLs that popup dialogs and such, these |
498 // should not actually navigate. | 516 // should not actually navigate. |
499 if (!HandleNonNavigationAboutURL(url)) { | 517 if (!HandleNonNavigationAboutURL(url)) { |
500 // Perform the actual navigation, tracking whether it came from the | 518 // Perform the actual navigation, tracking whether it came from the |
501 // renderer. | 519 // renderer. |
502 if (params->is_renderer_initiated) { | 520 |
503 params->target_contents->controller().LoadURLFromRenderer( | 521 LoadURLInContents(params->target_contents->tab_contents(), |
504 url, params->referrer, params->transition, extra_headers); | 522 url, params, extra_headers); |
505 } else { | |
506 params->target_contents->controller().LoadURL( | |
507 url, params->referrer, params->transition, extra_headers); | |
508 } | |
509 } | 523 } |
510 } else { | 524 } else { |
511 // |target_contents| was specified non-NULL, and so we assume it has already | 525 // |target_contents| was specified non-NULL, and so we assume it has already |
512 // been navigated appropriately. We need to do nothing more other than | 526 // been navigated appropriately. We need to do nothing more other than |
513 // add it to the appropriate tabstrip. | 527 // add it to the appropriate tabstrip. |
514 } | 528 } |
515 | 529 |
516 // If the user navigated from the omnibox, and the selected tab is going to | 530 // If the user navigated from the omnibox, and the selected tab is going to |
517 // lose focus, then make sure the focus for the source tab goes away from the | 531 // lose focus, then make sure the focus for the source tab goes away from the |
518 // omnibox. | 532 // omnibox. |
(...skipping 27 matching lines...) Expand all Loading... |
546 } | 560 } |
547 | 561 |
548 if (singleton_index >= 0) { | 562 if (singleton_index >= 0) { |
549 TabContents* target = params->browser->GetTabContentsAt(singleton_index); | 563 TabContents* target = params->browser->GetTabContentsAt(singleton_index); |
550 | 564 |
551 if (target->is_crashed()) { | 565 if (target->is_crashed()) { |
552 target->controller().Reload(true); | 566 target->controller().Reload(true); |
553 } else if (params->path_behavior == NavigateParams::IGNORE_AND_NAVIGATE && | 567 } else if (params->path_behavior == NavigateParams::IGNORE_AND_NAVIGATE && |
554 target->GetURL() != params->url) { | 568 target->GetURL() != params->url) { |
555 InitializeExtraHeaders(params, NULL, &extra_headers); | 569 InitializeExtraHeaders(params, NULL, &extra_headers); |
556 if (params->is_renderer_initiated) { | 570 LoadURLInContents(target, params->url, params, extra_headers); |
557 target->controller().LoadURLFromRenderer( | |
558 params->url, params->referrer, params->transition, extra_headers); | |
559 } else { | |
560 target->controller().LoadURL( | |
561 params->url, params->referrer, params->transition, extra_headers); | |
562 } | |
563 } | 571 } |
564 | 572 |
565 // If the singleton tab isn't already selected, select it. | 573 // If the singleton tab isn't already selected, select it. |
566 if (params->source_contents != params->target_contents) | 574 if (params->source_contents != params->target_contents) |
567 params->browser->ActivateTabAt(singleton_index, user_initiated); | 575 params->browser->ActivateTabAt(singleton_index, user_initiated); |
568 } | 576 } |
569 | 577 |
570 if (params->disposition != CURRENT_TAB) { | 578 if (params->disposition != CURRENT_TAB) { |
571 content::NotificationService::current()->Notify( | 579 content::NotificationService::current()->Notify( |
572 content::NOTIFICATION_TAB_ADDED, | 580 content::NOTIFICATION_TAB_ADDED, |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
626 // chrome://settings. | 634 // chrome://settings. |
627 | 635 |
628 return !(url.scheme() == chrome::kChromeUIScheme && | 636 return !(url.scheme() == chrome::kChromeUIScheme && |
629 (url.host() == chrome::kChromeUISettingsHost || | 637 (url.host() == chrome::kChromeUISettingsHost || |
630 url.host() == chrome::kChromeUIExtensionsHost || | 638 url.host() == chrome::kChromeUIExtensionsHost || |
631 url.host() == chrome::kChromeUIBookmarksHost || | 639 url.host() == chrome::kChromeUIBookmarksHost || |
632 url.host() == chrome::kChromeUISyncPromoHost)); | 640 url.host() == chrome::kChromeUISyncPromoHost)); |
633 } | 641 } |
634 | 642 |
635 } // namespace browser | 643 } // namespace browser |
OLD | NEW |