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

Unified Diff: chrome/browser/browser.cc

Issue 56094: Fix a case where non-tabbed browser windows could open tabs. Also includes UI... (Closed) Base URL: svn://chrome-svn.corp.google.com/chrome/trunk/src/
Patch Set: '' Created 11 years, 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/browser.h ('k') | chrome/browser/browser_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/browser.cc
===================================================================
--- chrome/browser/browser.cc (revision 13019)
+++ chrome/browser/browser.cc (working copy)
@@ -473,22 +473,26 @@
TabContents* Browser::AddTabWithURL(
const GURL& url, const GURL& referrer, PageTransition::Type transition,
bool foreground, SiteInstance* instance) {
- if ((type_ & TYPE_APP) != 0 && tabstrip_model_.count() == 1) {
- NOTREACHED() << "Cannot add a tab in a mono tab application.";
- return NULL;
+ TabContents* contents = NULL;
+ if (type_ == TYPE_NORMAL) {
+ GURL url_to_load = url;
+ if (url_to_load.is_empty())
+ url_to_load = GetHomePage();
+ contents = CreateTabContentsForURL(url_to_load, referrer, profile_,
+ transition, false, instance);
+ tabstrip_model_.AddTabContents(contents, -1, transition, foreground);
+ // By default, content believes it is not hidden. When adding contents
+ // in the background, tell it that it's hidden.
+ if (!foreground)
+ contents->WasHidden();
+ } else {
+ // We're in an app window or a popup window. Find an existing browser to
+ // open this URL in, creating one if none exists.
+ Browser* b = GetOrCreateTabbedBrowser();
+ contents = b->AddTabWithURL(url, referrer, transition, foreground,
+ instance);
+ b->window()->Show();
}
-
- GURL url_to_load = url;
- if (url_to_load.is_empty())
- url_to_load = GetHomePage();
- TabContents* contents =
- CreateTabContentsForURL(url_to_load, referrer, profile_, transition,
- false, instance);
- tabstrip_model_.AddTabContents(contents, -1, transition, foreground);
- // By default, content believes it is not hidden. When adding contents
- // in the background, tell it that it's hidden.
- if (!foreground)
- contents->WasHidden();
return contents;
}
« no previous file with comments | « chrome/browser/browser.h ('k') | chrome/browser/browser_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698