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

Unified Diff: chrome/browser/browser.cc

Issue 1986006: Reuse existing NTP if one exists (Closed) Base URL: git://codf21.jail/chromium.git
Patch Set: backwardify Created 10 years, 7 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/browser.cc
diff --git a/chrome/browser/browser.cc b/chrome/browser/browser.cc
index 0561187fc62fe0cb5f7a99d3929d0fdd744e6596..2de6237e833e74ebaa8ea526e85f0d6f30aa44f2 100644
--- a/chrome/browser/browser.cc
+++ b/chrome/browser/browser.cc
@@ -2092,6 +2092,22 @@ void Browser::ExecuteCommand(int id) {
// Browser, TabStripModelDelegate implementation:
TabContents* Browser::AddBlankTab(bool foreground) {
+ // To make a more "launchy" experience, try to reuse an existing NTP if there
+ // is one.
+ if (CommandLine::ForCurrentProcess()->HasSwitch(
+ switches::kEnableExtensionApps)) {
+ for (int i = tabstrip_model_.count() - 1; i >= 0; --i) {
+ TabContents* contents = tabstrip_model_.GetTabContentsAt(i);
+ if (StartsWithASCII(contents->GetURL().spec(),
+ chrome::kChromeUINewTabURL, true)) {
+ if (foreground)
+ SelectTabContentsAt(i, true);
+
+ return contents;
+ }
+ }
+ }
+
return AddBlankTabAt(-1, foreground);
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698