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..1adfa6b2534cc34d6f3b5bd277201a44d4802337 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" |
+ // |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 omnibar will stay focused if we |
Alexei Svitkine (slow)
2014/04/22 15:42:00
Nit: omnibox
|
+ // 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_]; |
+ [self clearStartupUrls]; |
Alexei Svitkine (slow)
2014/04/22 15:42:00
Doesn't seem like -clearStartupUrls is used from a
|
+ } |
+ |
+ if (startupIndex != TabStripModel::kNoTab && |
+ startupContent->GetVisibleURL() == GURL(chrome::kChromeUINewTabURL)) { |
Alexei Svitkine (slow)
2014/04/22 15:42:00
I see other code doing the following check instead
wjywbs
2014/04/22 21:51:51
I tested this current method with a NTP override e
|
+ 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) { |