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

Unified Diff: chrome/browser/app_controller_mac.mm

Issue 2798143004: Fix for URL opening code (Closed)
Patch Set: Fixed class name usage. Created 3 years, 6 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 89d8409fcf58fd33b51390156268053040754eb5..a9651a34b3a9351b8b9546282d464293ff84f673 100644
--- a/chrome/browser/app_controller_mac.mm
+++ b/chrome/browser/app_controller_mac.mm
@@ -209,6 +209,10 @@ - (void)profileWasRemoved:(const base::FilePath&)profilePath;
// Opens a tab for each GURL in |urls|.
- (void)openUrls:(const std::vector<GURL>&)urls;
+// Creates StartupBrowserCreator and opens |urls| with it.
+- (void)openUrlsViaStartupBrowserCreator:(const std::vector<GURL>&)urls
+ inBrowser:(Browser*)browser;
+
// This class cannot open urls until startup has finished. The urls that cannot
// be opened are cached in |startupUrls_|. This method must be called exactly
// once after startup has completed. It opens the urls in |startupUrls_|, and
@@ -1275,6 +1279,16 @@ - (bool)canOpenNewBrowser {
prefs->GetBoolean(prefs::kBrowserGuestModeEnabled);
}
+- (void)openUrlsViaStartupBrowserCreator:(const std::vector<GURL>&)urls
+ inBrowser:(Browser*)browser {
+ base::CommandLine dummy(base::CommandLine::NO_PROGRAM);
+ chrome::startup::IsFirstRun first_run =
+ first_run::IsChromeFirstRun() ? chrome::startup::IS_FIRST_RUN
+ : chrome::startup::IS_NOT_FIRST_RUN;
+ StartupBrowserCreatorImpl launch(base::FilePath(), dummy, first_run);
+ launch.OpenURLsInBrowser(browser, false, urls);
+}
+
// Various methods to open URLs that we get in a native fashion. We use
// StartupBrowserCreator here because on the other platforms, URLs to open come
// through the ProcessSingleton, and it calls StartupBrowserCreator. It's best
@@ -1285,19 +1299,36 @@ - (void)openUrls:(const std::vector<GURL>&)urls {
return;
}
- Browser* browser = chrome::GetLastActiveBrowser();
- // if no browser window exists then create one with no tabs to be filled in
- if (!browser) {
- browser = new Browser(
- Browser::CreateParams([self safeLastProfileForNewWindows], true));
- browser->window()->Show();
+ Profile* profile = [self safeLastProfileForNewWindows];
+ SessionStartupPref pref = StartupBrowserCreator::GetSessionStartupPref(
+ *base::CommandLine::ForCurrentProcess(), profile);
+
+ if (pref.type == SessionStartupPref::LAST) {
+ if (SessionRestore::IsRestoring(profile)) {
+ // In case of session restore, remember |urls|, so they will be opened
+ // after session is resored, in the tabs next to it.
+ SessionRestore::AddURLsToOpen(profile, urls);
+ } else {
+ Browser* browser = chrome::GetLastActiveBrowser();
+ if (!browser) {
+ // This behavior is needed for the case when chromium app is launched,
+ // but there are no open indows.
+ browser = new Browser(Browser::CreateParams(profile, true));
+ browser->window()->Show();
+ SessionRestore::AddURLsToOpen(profile, urls);
+ } else {
+ [self openUrlsViaStartupBrowserCreator:urls inBrowser:browser];
+ }
+ }
+ } else {
+ Browser* browser = chrome::GetLastActiveBrowser();
+ // If no browser window exists then create one with no tabs to be filled in.
+ if (!browser) {
+ browser = new Browser(Browser::CreateParams(profile, true));
+ browser->window()->Show();
+ }
+ [self openUrlsViaStartupBrowserCreator:urls inBrowser:browser];
}
-
- base::CommandLine dummy(base::CommandLine::NO_PROGRAM);
- chrome::startup::IsFirstRun first_run = first_run::IsChromeFirstRun() ?
- chrome::startup::IS_FIRST_RUN : chrome::startup::IS_NOT_FIRST_RUN;
- StartupBrowserCreatorImpl launch(base::FilePath(), dummy, first_run);
- launch.OpenURLsInBrowser(browser, false, urls);
}
- (void)getUrl:(NSAppleEventDescriptor*)event
« 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