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

Unified Diff: chrome/browser/app_controller_mac.mm

Issue 240273002: Close the ntp during startup when opening a link on Mac. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: reorder test header Created 6 years, 8 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
Index: chrome/browser/app_controller_mac.mm
diff --git a/chrome/browser/app_controller_mac.mm b/chrome/browser/app_controller_mac.mm
index a4fa0f59a09f22d3b303c47fef6d1635af2c2134..3614d398ee3f56460d1a81935f89015213d70996 100644
--- a/chrome/browser/app_controller_mac.mm
+++ b/chrome/browser/app_controller_mac.mm
@@ -681,6 +681,38 @@ class AppControllerProfileObserver : public ProfileInfoCacheObserver {
#endif
}
+- (void)openStartupUrls {
+ // TODO(viettrungluu): This is very temporary, since this should be done "in"
Alexei Svitkine (slow) 2014/04/24 18:59:28 Nit: Remove the "This is very temporary" part of t
+ // |BrowserMain()|, i.e., this list of startup URLs should be appended to the
+ // (probably-empty) list of URLs from the command line.
+ if (startupUrls_.empty())
+ return;
+
+ // The browser is already loaded at this point.
+ // If there's only 1 tab and the tab is NTP, close this NTP tab and open all
+ // startup urls in new tabs, because the omnibox will stay focused if we
+ // load url in NTP tab.
+ Browser* browser = chrome::GetLastActiveBrowser();
+ int startupIndex = TabStripModel::kNoTab;
+ content::WebContents* startupContent = NULL;
+
+ if (browser && browser->tab_strip_model()->count() == 1) {
+ startupIndex = browser->tab_strip_model()->active_index();
+ startupContent = browser->tab_strip_model()->GetActiveWebContents();
+ }
+
+ if (startupUrls_.size()) {
+ [self openUrls:startupUrls_];
+ startupUrls_.clear();
+ }
+
+ if (startupIndex != TabStripModel::kNoTab &&
+ startupContent->GetVisibleURL() == GURL(chrome::kChromeUINewTabURL)) {
+ browser->tab_strip_model()->CloseWebContentsAt(startupIndex,
+ TabStripModel::CLOSE_NONE);
+ }
+}
+
// This is called after profiles have been loaded and preferences registered.
// It is safe to access the default profile here.
- (void)applicationDidFinishLaunching:(NSNotification*)notify {
@@ -725,13 +757,7 @@ class AppControllerProfileObserver : public ProfileInfoCacheObserver {
startupComplete_ = YES;
- // TODO(viettrungluu): This is very temporary, since this should be done "in"
- // |BrowserMain()|, i.e., this list of startup URLs should be appended to the
- // (probably-empty) list of URLs from the command line.
- if (startupUrls_.size()) {
- [self openUrls:startupUrls_];
- [self clearStartupUrls];
- }
+ [self openStartupUrls];
PrefService* localState = g_browser_process->local_state();
if (localState) {
@@ -1458,10 +1484,6 @@ class AppControllerProfileObserver : public ProfileInfoCacheObserver {
return startupUrls_;
}
-- (void)clearStartupUrls {
- startupUrls_.clear();
-}
-
- (BookmarkMenuBridge*)bookmarkMenuBridge {
return bookmarkMenuBridge_.get();
}

Powered by Google App Engine
This is Rietveld 408576698