OLD | NEW |
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 #include "chrome/browser/ui/browser_init.h" | 5 #include "chrome/browser/ui/browser_init.h" |
6 | 6 |
7 #include <algorithm> // For max(). | 7 #include <algorithm> // For max(). |
8 #include <set> | 8 #include <set> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 880 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
891 } else { | 891 } else { |
892 DLOG(WARNING) << "Invalid http debugger port number " << port; | 892 DLOG(WARNING) << "Invalid http debugger port number " << port; |
893 } | 893 } |
894 } | 894 } |
895 | 895 |
896 // Open the required browser windows and tabs. First, see if | 896 // Open the required browser windows and tabs. First, see if |
897 // we're being run as an application window. If so, the user | 897 // we're being run as an application window. If so, the user |
898 // opened an app shortcut. Don't restore tabs or open initial | 898 // opened an app shortcut. Don't restore tabs or open initial |
899 // URLs in that case. The user should see the window as an app, | 899 // URLs in that case. The user should see the window as an app, |
900 // not as chrome. | 900 // not as chrome. |
901 if (OpenApplicationWindow(profile)) { | 901 // Special case is when app switches are passed but we do want to restore |
| 902 // session. In that case open app window + focus it after session is restored. |
| 903 if (OpenApplicationWindow(profile) && !browser_defaults::kAppRestoreSession) { |
902 RecordLaunchModeHistogram(LM_AS_WEBAPP); | 904 RecordLaunchModeHistogram(LM_AS_WEBAPP); |
903 } else { | 905 } else { |
| 906 Browser* browser_to_focus = NULL; |
| 907 // In case of app mode + session restore we want to focus that app. |
| 908 if (browser_defaults::kAppRestoreSession) |
| 909 browser_to_focus = BrowserList::GetLastActive(); |
| 910 |
904 RecordLaunchModeHistogram(urls_to_open.empty()? | 911 RecordLaunchModeHistogram(urls_to_open.empty()? |
905 LM_TO_BE_DECIDED : LM_WITH_URLS); | 912 LM_TO_BE_DECIDED : LM_WITH_URLS); |
906 | 913 |
907 // Notify user if the Preferences backup is invalid or changes to settings | 914 // Notify user if the Preferences backup is invalid or changes to settings |
908 // affecting browser startup have been detected. | 915 // affecting browser startup have been detected. |
909 CheckPreferencesBackup(profile); | 916 CheckPreferencesBackup(profile); |
910 | 917 |
911 ProcessLaunchURLs(process_startup, urls_to_open); | 918 ProcessLaunchURLs(process_startup, urls_to_open); |
912 | 919 |
913 // If this is an app launch, but we didn't open an app window, it may | 920 // If this is an app launch, but we didn't open an app window, it may |
914 // be an app tab. | 921 // be an app tab. |
915 OpenApplicationTab(profile); | 922 OpenApplicationTab(profile); |
916 | 923 |
| 924 if (browser_to_focus) |
| 925 browser_to_focus->GetSelectedWebContents()->GetView()->SetInitialFocus(); |
| 926 |
917 if (process_startup) { | 927 if (process_startup) { |
918 if (browser_defaults::kOSSupportsOtherBrowsers && | 928 if (browser_defaults::kOSSupportsOtherBrowsers && |
919 !command_line_.HasSwitch(switches::kNoDefaultBrowserCheck)) { | 929 !command_line_.HasSwitch(switches::kNoDefaultBrowserCheck)) { |
920 if (!CheckIfAutoLaunched(profile)) { | 930 if (!CheckIfAutoLaunched(profile)) { |
921 // Check whether we are the default browser. | 931 // Check whether we are the default browser. |
922 CheckDefaultBrowser(profile); | 932 CheckDefaultBrowser(profile); |
923 } | 933 } |
924 } | 934 } |
925 #if defined(OS_MACOSX) | 935 #if defined(OS_MACOSX) |
926 // Check whether the auto-update system needs to be promoted from user | 936 // Check whether the auto-update system needs to be promoted from user |
(...skipping 1004 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1931 | 1941 |
1932 Profile* profile = ProfileManager::GetLastUsedProfile(); | 1942 Profile* profile = ProfileManager::GetLastUsedProfile(); |
1933 if (!profile) { | 1943 if (!profile) { |
1934 // We should only be able to get here if the profile already exists and | 1944 // We should only be able to get here if the profile already exists and |
1935 // has been created. | 1945 // has been created. |
1936 NOTREACHED(); | 1946 NOTREACHED(); |
1937 return; | 1947 return; |
1938 } | 1948 } |
1939 ProcessCmdLineImpl(cmd_line, cur_dir, false, profile, Profiles(), NULL, NULL); | 1949 ProcessCmdLineImpl(cmd_line, cur_dir, false, profile, Profiles(), NULL, NULL); |
1940 } | 1950 } |
OLD | NEW |