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

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: fix comment 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
« no previous file with comments | « no previous file | chrome/browser/app_controller_mac_browsertest.mm » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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) {
« no previous file with comments | « no previous file | chrome/browser/app_controller_mac_browsertest.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698