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

Side by Side Diff: chrome/browser/app_controller_mac.mm

Issue 2798143004: Fix for URL opening code (Closed)
Patch Set: Removed vlog, that wasn't needed Created 3 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #import "chrome/browser/app_controller_mac.h" 5 #import "chrome/browser/app_controller_mac.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include "base/auto_reset.h" 9 #include "base/auto_reset.h"
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 1261 matching lines...) Expand 10 before | Expand all | Expand 10 after
1272 1272
1273 // Various methods to open URLs that we get in a native fashion. We use 1273 // Various methods to open URLs that we get in a native fashion. We use
1274 // StartupBrowserCreator here because on the other platforms, URLs to open come 1274 // StartupBrowserCreator here because on the other platforms, URLs to open come
1275 // through the ProcessSingleton, and it calls StartupBrowserCreator. It's best 1275 // through the ProcessSingleton, and it calls StartupBrowserCreator. It's best
1276 // to bottleneck the openings through that for uniform handling. 1276 // to bottleneck the openings through that for uniform handling.
1277 - (void)openUrls:(const std::vector<GURL>&)urls { 1277 - (void)openUrls:(const std::vector<GURL>&)urls {
1278 if (!startupComplete_) { 1278 if (!startupComplete_) {
1279 startupUrls_.insert(startupUrls_.end(), urls.begin(), urls.end()); 1279 startupUrls_.insert(startupUrls_.end(), urls.begin(), urls.end());
1280 return; 1280 return;
1281 } 1281 }
1282
1283 Browser* browser = chrome::GetLastActiveBrowser(); 1282 Browser* browser = chrome::GetLastActiveBrowser();
1283 bool show_browser = false;
1284 // if no browser window exists then create one with no tabs to be filled in 1284 // if no browser window exists then create one with no tabs to be filled in
1285 if (!browser) { 1285 if (!browser) {
1286 browser = new Browser(Browser::CreateParams([self lastProfile], true)); 1286 browser = new Browser(Browser::CreateParams([self lastProfile], true));
sky 2017/04/28 17:34:58 Why do we need to open a browser here if triggerin
eugenebng 2017/05/03 16:05:30 Initially I was going to change as few as possible
1287 browser->window()->Show(); 1287 show_browser = true;
1288 } 1288 }
1289 Profile* profile = [self lastProfile];
1290 SessionStartupPref pref = StartupBrowserCreator::GetSessionStartupPref(
1291 *base::CommandLine::ForCurrentProcess(), profile);
1289 1292
1290 base::CommandLine dummy(base::CommandLine::NO_PROGRAM); 1293 if (pref.type == SessionStartupPref::LAST) {
1291 chrome::startup::IsFirstRun first_run = first_run::IsChromeFirstRun() ? 1294 // In case of session restore, remember |urls|, so they will be opened
1292 chrome::startup::IS_FIRST_RUN : chrome::startup::IS_NOT_FIRST_RUN; 1295 // after session is resored, in the tabs next to it.
1293 StartupBrowserCreatorImpl launch(base::FilePath(), dummy, first_run); 1296 DCHECK(SessionRestore::IsRestoring(profile));
1294 launch.OpenURLsInBrowser(browser, false, urls); 1297 SessionRestore::AddURLsToOpen(profile, urls);
1298 } else {
1299 base::CommandLine dummy(base::CommandLine::NO_PROGRAM);
1300 chrome::startup::IsFirstRun first_run =
1301 first_run::IsChromeFirstRun() ? chrome::startup::IS_FIRST_RUN
1302 : chrome::startup::IS_NOT_FIRST_RUN;
1303 StartupBrowserCreatorImpl launch(base::FilePath(), dummy, first_run);
1304 if (show_browser)
1305 browser->window()->Show();
1306 launch.OpenURLsInBrowser(browser, false, urls);
1307 }
1295 } 1308 }
1296 1309
1297 - (void)getUrl:(NSAppleEventDescriptor*)event 1310 - (void)getUrl:(NSAppleEventDescriptor*)event
1298 withReply:(NSAppleEventDescriptor*)reply { 1311 withReply:(NSAppleEventDescriptor*)reply {
1299 NSString* urlStr = [[event paramDescriptorForKeyword:keyDirectObject] 1312 NSString* urlStr = [[event paramDescriptorForKeyword:keyDirectObject]
1300 stringValue]; 1313 stringValue];
1301 1314
1302 GURL gurl(base::SysNSStringToUTF8(urlStr)); 1315 GURL gurl(base::SysNSStringToUTF8(urlStr));
1303 std::vector<GURL> gurlVector; 1316 std::vector<GURL> gurlVector;
1304 gurlVector.push_back(gurl); 1317 gurlVector.push_back(gurl);
(...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after
1608 1621
1609 //--------------------------------------------------------------------------- 1622 //---------------------------------------------------------------------------
1610 1623
1611 namespace app_controller_mac { 1624 namespace app_controller_mac {
1612 1625
1613 bool IsOpeningNewWindow() { 1626 bool IsOpeningNewWindow() {
1614 return g_is_opening_new_window; 1627 return g_is_opening_new_window;
1615 } 1628 }
1616 1629
1617 } // namespace app_controller_mac 1630 } // namespace app_controller_mac
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698