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

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

Issue 2798143004: Fix for URL opening code (Closed)
Patch Set: Fixed opening local file with Chromium on mac while restore session is enabled. File opens in the t… Created 3 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 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 1255 matching lines...) Expand 10 before | Expand all | Expand 10 after
1266 1266
1267 // Various methods to open URLs that we get in a native fashion. We use 1267 // Various methods to open URLs that we get in a native fashion. We use
1268 // StartupBrowserCreator here because on the other platforms, URLs to open come 1268 // StartupBrowserCreator here because on the other platforms, URLs to open come
1269 // through the ProcessSingleton, and it calls StartupBrowserCreator. It's best 1269 // through the ProcessSingleton, and it calls StartupBrowserCreator. It's best
1270 // to bottleneck the openings through that for uniform handling. 1270 // to bottleneck the openings through that for uniform handling.
1271 - (void)openUrls:(const std::vector<GURL>&)urls { 1271 - (void)openUrls:(const std::vector<GURL>&)urls {
1272 if (!startupComplete_) { 1272 if (!startupComplete_) {
1273 startupUrls_.insert(startupUrls_.end(), urls.begin(), urls.end()); 1273 startupUrls_.insert(startupUrls_.end(), urls.begin(), urls.end());
1274 return; 1274 return;
1275 } 1275 }
1276
1277 Browser* browser = chrome::GetLastActiveBrowser(); 1276 Browser* browser = chrome::GetLastActiveBrowser();
1277 bool show_browser = false;
1278 // if no browser window exists then create one with no tabs to be filled in 1278 // if no browser window exists then create one with no tabs to be filled in
1279 if (!browser) { 1279 if (!browser) {
1280 browser = new Browser(Browser::CreateParams([self lastProfile], true)); 1280 browser = new Browser(Browser::CreateParams([self lastProfile], true));
1281 browser->window()->Show(); 1281 show_browser = true;
1282 } 1282 }
1283 Profile* profile = [self lastProfile];
1284 SessionStartupPref pref = StartupBrowserCreator::GetSessionStartupPref(
1285 *base::CommandLine::ForCurrentProcess(), profile);
1283 1286
1284 base::CommandLine dummy(base::CommandLine::NO_PROGRAM); 1287 if (pref.type == SessionStartupPref::LAST) {
1285 chrome::startup::IsFirstRun first_run = first_run::IsChromeFirstRun() ? 1288 // In case of session restore, remember |urls|, so they will be opened
1286 chrome::startup::IS_FIRST_RUN : chrome::startup::IS_NOT_FIRST_RUN; 1289 // after session is resored, in the tabs next to it.
1287 StartupBrowserCreatorImpl launch(base::FilePath(), dummy, first_run); 1290 StartupBrowserCreatorImpl::OpenURLsAfterSessionRestore(urls);
1288 launch.OpenURLsInBrowser(browser, false, urls); 1291 } else {
1292 base::CommandLine dummy(base::CommandLine::NO_PROGRAM);
1293 chrome::startup::IsFirstRun first_run =
1294 first_run::IsChromeFirstRun() ? chrome::startup::IS_FIRST_RUN
1295 : chrome::startup::IS_NOT_FIRST_RUN;
1296 StartupBrowserCreatorImpl launch(base::FilePath(), dummy, first_run);
1297 if (show_browser)
1298 browser->window()->Show();
1299 launch.OpenURLsInBrowser(browser, false, urls);
1300 }
1289 } 1301 }
1290 1302
1291 - (void)getUrl:(NSAppleEventDescriptor*)event 1303 - (void)getUrl:(NSAppleEventDescriptor*)event
1292 withReply:(NSAppleEventDescriptor*)reply { 1304 withReply:(NSAppleEventDescriptor*)reply {
1293 NSString* urlStr = [[event paramDescriptorForKeyword:keyDirectObject] 1305 NSString* urlStr = [[event paramDescriptorForKeyword:keyDirectObject]
1294 stringValue]; 1306 stringValue];
1295 1307
1296 GURL gurl(base::SysNSStringToUTF8(urlStr)); 1308 GURL gurl(base::SysNSStringToUTF8(urlStr));
1297 std::vector<GURL> gurlVector; 1309 std::vector<GURL> gurlVector;
1298 gurlVector.push_back(gurl); 1310 gurlVector.push_back(gurl);
(...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after
1602 1614
1603 //--------------------------------------------------------------------------- 1615 //---------------------------------------------------------------------------
1604 1616
1605 namespace app_controller_mac { 1617 namespace app_controller_mac {
1606 1618
1607 bool IsOpeningNewWindow() { 1619 bool IsOpeningNewWindow() {
1608 return g_is_opening_new_window; 1620 return g_is_opening_new_window;
1609 } 1621 }
1610 1622
1611 } // namespace app_controller_mac 1623 } // namespace app_controller_mac
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698