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

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

Issue 2798143004: Fix for URL opening code (Closed)
Patch Set: Added test, fixed opening URL case when browser is already started. 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 1262 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 1282
1283 Browser* browser = chrome::GetLastActiveBrowser(); 1283 Profile* profile = [self lastProfile];
1284 // if no browser window exists then create one with no tabs to be filled in 1284 SessionStartupPref pref = StartupBrowserCreator::GetSessionStartupPref(
1285 if (!browser) { 1285 *base::CommandLine::ForCurrentProcess(), profile);
1286 browser = new Browser(Browser::CreateParams([self lastProfile], true)); 1286
1287 browser->window()->Show(); 1287 if (pref.type == SessionStartupPref::LAST &&
1288 SessionRestore::IsRestoring(profile)) {
1289 // In case of session restore, remember |urls|, so they will be opened
1290 // after session is resored, in the tabs next to it.
1291 SessionRestore::AddURLsToOpen(profile, urls);
1292 } else {
1293 Browser* browser = chrome::GetLastActiveBrowser();
1294 // if no browser window exists then create one with no tabs to be filled in
Avi (use Gerrit) 2017/05/04 23:47:43 While you're here, turn this into a sentence with
eugenebng 2017/05/15 06:17:08 Done.
1295 if (!browser && pref.type != SessionStartupPref::LAST) {
Avi (use Gerrit) 2017/05/04 23:47:43 I'm not clear on this line. So if there is no brow
eugenebng 2017/05/15 06:17:08 Fixed this logic, so that it now handles 3 open UR
1296 browser = new Browser(Browser::CreateParams([self lastProfile], true));
1297 browser->window()->Show();
1298 }
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 launch.OpenURLsInBrowser(browser, false, urls);
1288 } 1305 }
1289
1290 base::CommandLine dummy(base::CommandLine::NO_PROGRAM);
1291 chrome::startup::IsFirstRun first_run = first_run::IsChromeFirstRun() ?
1292 chrome::startup::IS_FIRST_RUN : chrome::startup::IS_NOT_FIRST_RUN;
1293 StartupBrowserCreatorImpl launch(base::FilePath(), dummy, first_run);
1294 launch.OpenURLsInBrowser(browser, false, urls);
1295 } 1306 }
1296 1307
1297 - (void)getUrl:(NSAppleEventDescriptor*)event 1308 - (void)getUrl:(NSAppleEventDescriptor*)event
1298 withReply:(NSAppleEventDescriptor*)reply { 1309 withReply:(NSAppleEventDescriptor*)reply {
1299 NSString* urlStr = [[event paramDescriptorForKeyword:keyDirectObject] 1310 NSString* urlStr = [[event paramDescriptorForKeyword:keyDirectObject]
1300 stringValue]; 1311 stringValue];
1301 1312
1302 GURL gurl(base::SysNSStringToUTF8(urlStr)); 1313 GURL gurl(base::SysNSStringToUTF8(urlStr));
1303 std::vector<GURL> gurlVector; 1314 std::vector<GURL> gurlVector;
1304 gurlVector.push_back(gurl); 1315 gurlVector.push_back(gurl);
(...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after
1608 1619
1609 //--------------------------------------------------------------------------- 1620 //---------------------------------------------------------------------------
1610 1621
1611 namespace app_controller_mac { 1622 namespace app_controller_mac {
1612 1623
1613 bool IsOpeningNewWindow() { 1624 bool IsOpeningNewWindow() {
1614 return g_is_opening_new_window; 1625 return g_is_opening_new_window;
1615 } 1626 }
1616 1627
1617 } // namespace app_controller_mac 1628 } // namespace app_controller_mac
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698