Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(110)

Side by Side Diff: chrome/browser/ui/browser_navigator.cc

Issue 10702029: Move tab functions off Browser into browser_tabstrip and browser_tabrestore. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/stringprintf.h" 10 #include "base/stringprintf.h"
11 #include "base/utf_string_conversions.h" 11 #include "base/utf_string_conversions.h"
12 #include "chrome/browser/browser_about_handler.h" 12 #include "chrome/browser/browser_about_handler.h"
13 #include "chrome/browser/extensions/extension_service.h" 13 #include "chrome/browser/extensions/extension_service.h"
14 #include "chrome/browser/extensions/extension_tab_helper.h" 14 #include "chrome/browser/extensions/extension_tab_helper.h"
15 #include "chrome/browser/google/google_url_tracker.h" 15 #include "chrome/browser/google/google_url_tracker.h"
16 #include "chrome/browser/google/google_util.h" 16 #include "chrome/browser/google/google_util.h"
17 #include "chrome/browser/prefs/incognito_mode_prefs.h" 17 #include "chrome/browser/prefs/incognito_mode_prefs.h"
18 #include "chrome/browser/prefs/pref_service.h" 18 #include "chrome/browser/prefs/pref_service.h"
19 #include "chrome/browser/prerender/prerender_manager.h" 19 #include "chrome/browser/prerender/prerender_manager.h"
20 #include "chrome/browser/prerender/prerender_manager_factory.h" 20 #include "chrome/browser/prerender/prerender_manager_factory.h"
21 #include "chrome/browser/profiles/profile.h" 21 #include "chrome/browser/profiles/profile.h"
22 #include "chrome/browser/rlz/rlz.h" 22 #include "chrome/browser/rlz/rlz.h"
23 #include "chrome/browser/tab_contents/tab_util.h" 23 #include "chrome/browser/tab_contents/tab_util.h"
24 #include "chrome/browser/ui/browser.h" 24 #include "chrome/browser/ui/browser.h"
25 #include "chrome/browser/ui/browser_finder.h" 25 #include "chrome/browser/ui/browser_finder.h"
26 #include "chrome/browser/ui/browser_tabstrip.h"
26 #include "chrome/browser/ui/browser_window.h" 27 #include "chrome/browser/ui/browser_window.h"
27 #include "chrome/browser/ui/omnibox/location_bar.h" 28 #include "chrome/browser/ui/omnibox/location_bar.h"
28 #include "chrome/browser/ui/singleton_tabs.h" 29 #include "chrome/browser/ui/singleton_tabs.h"
29 #include "chrome/browser/ui/status_bubble.h" 30 #include "chrome/browser/ui/status_bubble.h"
30 #include "chrome/browser/ui/tab_contents/tab_contents.h" 31 #include "chrome/browser/ui/tab_contents/tab_contents.h"
31 #include "chrome/browser/ui/tabs/tab_strip_model.h" 32 #include "chrome/browser/ui/tabs/tab_strip_model.h"
32 #include "chrome/browser/web_applications/web_app.h" 33 #include "chrome/browser/web_applications/web_app.h"
33 #include "chrome/common/chrome_notification_types.h" 34 #include "chrome/common/chrome_notification_types.h"
34 #include "chrome/common/extensions/extension.h" 35 #include "chrome/common/extensions/extension.h"
35 #include "chrome/common/pref_names.h" 36 #include "chrome/common/pref_names.h"
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 98
98 // Returns a Browser that can host the navigation or tab addition specified in 99 // Returns a Browser that can host the navigation or tab addition specified in
99 // |params|. This might just return the same Browser specified in |params|, or 100 // |params|. This might just return the same Browser specified in |params|, or
100 // some other if that Browser is deemed incompatible. 101 // some other if that Browser is deemed incompatible.
101 Browser* GetBrowserForDisposition(browser::NavigateParams* params) { 102 Browser* GetBrowserForDisposition(browser::NavigateParams* params) {
102 // If no source TabContents was specified, we use the selected one from 103 // If no source TabContents was specified, we use the selected one from
103 // the target browser. This must happen first, before 104 // the target browser. This must happen first, before
104 // GetBrowserForDisposition() has a chance to replace |params->browser| with 105 // GetBrowserForDisposition() has a chance to replace |params->browser| with
105 // another one. 106 // another one.
106 if (!params->source_contents && params->browser) 107 if (!params->source_contents && params->browser)
107 params->source_contents = 108 params->source_contents = chrome::GetActiveTabContents(params->browser);
108 params->browser->GetActiveTabContents();
109 109
110 Profile* profile = 110 Profile* profile =
111 params->browser ? params->browser->profile() : params->profile; 111 params->browser ? params->browser->profile() : params->profile;
112 112
113 switch (params->disposition) { 113 switch (params->disposition) {
114 case CURRENT_TAB: 114 case CURRENT_TAB:
115 if (!params->browser && profile) { 115 if (!params->browser && profile) {
116 // We specified a profile instead of a browser; find or create one. 116 // We specified a profile instead of a browser; find or create one.
117 params->browser = browser::FindOrCreateTabbedBrowser(profile); 117 params->browser = browser::FindOrCreateTabbedBrowser(profile);
118 } 118 }
(...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after
495 params->transition = content::PageTransitionFromInt( 495 params->transition = content::PageTransitionFromInt(
496 params->transition | content::PAGE_TRANSITION_HOME_PAGE); 496 params->transition | content::PAGE_TRANSITION_HOME_PAGE);
497 } else { 497 } else {
498 url = params->url; 498 url = params->url;
499 } 499 }
500 500
501 if (params->disposition != CURRENT_TAB) { 501 if (params->disposition != CURRENT_TAB) {
502 WebContents* source_contents = params->source_contents ? 502 WebContents* source_contents = params->source_contents ?
503 params->source_contents->web_contents() : NULL; 503 params->source_contents->web_contents() : NULL;
504 params->target_contents = 504 params->target_contents =
505 Browser::TabContentsFactory( 505 chrome::TabContentsFactory(
506 params->browser->profile(), 506 params->browser->profile(),
507 tab_util::GetSiteInstanceForNewTab( 507 tab_util::GetSiteInstanceForNewTab(
508 params->browser->profile(), url), 508 params->browser->profile(), url),
509 MSG_ROUTING_NONE, 509 MSG_ROUTING_NONE,
510 source_contents, 510 source_contents,
511 NULL); 511 NULL);
512 // This function takes ownership of |params->target_contents| until it 512 // This function takes ownership of |params->target_contents| until it
513 // is added to a TabStripModel. 513 // is added to a TabStripModel.
514 target_contents_owner.TakeOwnership(); 514 target_contents_owner.TakeOwnership();
515 params->target_contents->extension_tab_helper()-> 515 params->target_contents->extension_tab_helper()->
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
579 params->target_contents, 579 params->target_contents,
580 params->tabstrip_index, 580 params->tabstrip_index,
581 params->transition, 581 params->transition,
582 params->tabstrip_add_types); 582 params->tabstrip_add_types);
583 // Now that the |params->target_contents| is safely owned by the target 583 // Now that the |params->target_contents| is safely owned by the target
584 // Browser's TabStripModel, we can release ownership. 584 // Browser's TabStripModel, we can release ownership.
585 target_contents_owner.ReleaseOwnership(); 585 target_contents_owner.ReleaseOwnership();
586 } 586 }
587 587
588 if (singleton_index >= 0) { 588 if (singleton_index >= 0) {
589 WebContents* target = params->browser->GetWebContentsAt(singleton_index); 589 WebContents* target =
590 chrome::GetWebContentsAt(params->browser, singleton_index);
590 591
591 if (target->IsCrashed()) { 592 if (target->IsCrashed()) {
592 target->GetController().Reload(true); 593 target->GetController().Reload(true);
593 } else if (params->path_behavior == NavigateParams::IGNORE_AND_NAVIGATE && 594 } else if (params->path_behavior == NavigateParams::IGNORE_AND_NAVIGATE &&
594 target->GetURL() != params->url) { 595 target->GetURL() != params->url) {
595 InitializeExtraHeaders(params, NULL, &extra_headers); 596 InitializeExtraHeaders(params, NULL, &extra_headers);
596 LoadURLInContents(target, params->url, params, extra_headers); 597 LoadURLInContents(target, params->url, params, extra_headers);
597 } 598 }
598 599
599 // If the singleton tab isn't already selected, select it. 600 // If the singleton tab isn't already selected, select it.
600 if (params->source_contents != params->target_contents) 601 if (params->source_contents != params->target_contents)
601 params->browser->ActivateTabAt(singleton_index, user_initiated); 602 chrome::ActivateTabAt(params->browser, singleton_index, user_initiated);
602 } 603 }
603 604
604 if (params->disposition != CURRENT_TAB) { 605 if (params->disposition != CURRENT_TAB) {
605 content::NotificationService::current()->Notify( 606 content::NotificationService::current()->Notify(
606 chrome::NOTIFICATION_TAB_ADDED, 607 chrome::NOTIFICATION_TAB_ADDED,
607 content::Source<content::WebContentsDelegate>(params->browser), 608 content::Source<content::WebContentsDelegate>(params->browser),
608 content::Details<WebContents>(params->target_contents->web_contents())); 609 content::Details<WebContents>(params->target_contents->web_contents()));
609 } 610 }
610 } 611 }
611 612
612 bool IsURLAllowedInIncognito(const GURL& url) { 613 bool IsURLAllowedInIncognito(const GURL& url) {
613 // Most URLs are allowed in incognito; the following are exceptions. 614 // Most URLs are allowed in incognito; the following are exceptions.
614 // chrome://extensions is on the list because it redirects to 615 // chrome://extensions is on the list because it redirects to
615 // chrome://settings. 616 // chrome://settings.
616 617
617 return !(url.scheme() == chrome::kChromeUIScheme && 618 return !(url.scheme() == chrome::kChromeUIScheme &&
618 (url.host() == chrome::kChromeUISettingsHost || 619 (url.host() == chrome::kChromeUISettingsHost ||
619 url.host() == chrome::kChromeUISettingsFrameHost || 620 url.host() == chrome::kChromeUISettingsFrameHost ||
620 url.host() == chrome::kChromeUIExtensionsHost || 621 url.host() == chrome::kChromeUIExtensionsHost ||
621 url.host() == chrome::kChromeUIBookmarksHost || 622 url.host() == chrome::kChromeUIBookmarksHost ||
622 url.host() == chrome::kChromeUISyncPromoHost || 623 url.host() == chrome::kChromeUISyncPromoHost ||
623 url.host() == chrome::kChromeUIUberHost)); 624 url.host() == chrome::kChromeUIUberHost));
624 } 625 }
625 626
626 } // namespace browser 627 } // namespace browser
OLDNEW
« no previous file with comments | « chrome/browser/ui/browser_content_setting_bubble_model_delegate.cc ('k') | chrome/browser/ui/browser_navigator_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698