Chromium Code Reviews| 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/startup/startup_browser_creator.h" | 5 #include "chrome/browser/ui/startup/startup_browser_creator.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <algorithm> // For max(). | 9 #include <algorithm> // For max(). |
| 10 #include <memory> | 10 #include <memory> |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 97 | 97 |
| 98 #if defined(OS_MACOSX) | 98 #if defined(OS_MACOSX) |
| 99 #include "chrome/browser/web_applications/web_app_mac.h" | 99 #include "chrome/browser/web_applications/web_app_mac.h" |
| 100 #endif | 100 #endif |
| 101 | 101 |
| 102 #if defined(OS_WIN) | 102 #if defined(OS_WIN) |
| 103 #include "chrome/browser/metrics/jumplist_metrics_win.h" | 103 #include "chrome/browser/metrics/jumplist_metrics_win.h" |
| 104 #include "components/search_engines/desktop_search_utils.h" | 104 #include "components/search_engines/desktop_search_utils.h" |
| 105 #endif | 105 #endif |
| 106 | 106 |
| 107 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) | |
| 108 #include "ui/views/widget/desktop_aura/x11_desktop_handler.h" | |
| 109 #endif | |
| 110 | |
| 107 #if defined(ENABLE_PRINT_PREVIEW) | 111 #if defined(ENABLE_PRINT_PREVIEW) |
| 108 #include "chrome/browser/printing/cloud_print/cloud_print_proxy_service.h" | 112 #include "chrome/browser/printing/cloud_print/cloud_print_proxy_service.h" |
| 109 #include "chrome/browser/printing/cloud_print/cloud_print_proxy_service_factory. h" | 113 #include "chrome/browser/printing/cloud_print/cloud_print_proxy_service_factory. h" |
| 110 #include "chrome/browser/printing/print_dialog_cloud.h" | 114 #include "chrome/browser/printing/print_dialog_cloud.h" |
| 111 #endif | 115 #endif |
| 112 | 116 |
| 113 using content::BrowserThread; | 117 using content::BrowserThread; |
| 114 using content::ChildProcessSecurityPolicy; | 118 using content::ChildProcessSecurityPolicy; |
| 115 | 119 |
| 116 namespace { | 120 namespace { |
| (...skipping 588 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 705 } | 709 } |
| 706 | 710 |
| 707 #if defined(OS_WIN) | 711 #if defined(OS_WIN) |
| 708 // Log whether this process was a result of an action in the Windows Jumplist. | 712 // Log whether this process was a result of an action in the Windows Jumplist. |
| 709 if (command_line.HasSwitch(switches::kWinJumplistAction)) { | 713 if (command_line.HasSwitch(switches::kWinJumplistAction)) { |
| 710 jumplist::LogJumplistActionFromSwitchValue( | 714 jumplist::LogJumplistActionFromSwitchValue( |
| 711 command_line.GetSwitchValueASCII(switches::kWinJumplistAction)); | 715 command_line.GetSwitchValueASCII(switches::kWinJumplistAction)); |
| 712 } | 716 } |
| 713 #endif // defined(OS_WIN) | 717 #endif // defined(OS_WIN) |
| 714 | 718 |
| 719 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) | |
| 720 // Our request to Activate may be discarded on some linux window | |
| 721 // managers unless given a recent timestamp, so update the timestamp if | |
| 722 // we were given one. | |
| 723 if (command_line.HasSwitch(switches::kWmUserTimeMs)) { | |
| 724 uint64_t time; | |
| 725 std::string switchValue = | |
|
sky
2016/05/07 16:58:34
switch_value
Tom (Use chromium acct)
2016/05/09 17:49:59
Done.
| |
| 726 command_line.GetSwitchValueASCII(switches::kWmUserTimeMs); | |
| 727 if (base::StringToUint64(switchValue, &time)) { | |
| 728 views::X11DesktopHandler::get()->set_wm_user_time_ms( | |
| 729 static_cast<Time>(time)); | |
| 730 } | |
| 731 } | |
| 732 #endif | |
| 733 | |
| 715 chrome::startup::IsProcessStartup is_process_startup = process_startup ? | 734 chrome::startup::IsProcessStartup is_process_startup = process_startup ? |
| 716 chrome::startup::IS_PROCESS_STARTUP : | 735 chrome::startup::IS_PROCESS_STARTUP : |
| 717 chrome::startup::IS_NOT_PROCESS_STARTUP; | 736 chrome::startup::IS_NOT_PROCESS_STARTUP; |
| 718 chrome::startup::IsFirstRun is_first_run = first_run::IsChromeFirstRun() ? | 737 chrome::startup::IsFirstRun is_first_run = first_run::IsChromeFirstRun() ? |
| 719 chrome::startup::IS_FIRST_RUN : chrome::startup::IS_NOT_FIRST_RUN; | 738 chrome::startup::IS_FIRST_RUN : chrome::startup::IS_NOT_FIRST_RUN; |
| 720 // |last_opened_profiles| will be empty in the following circumstances: | 739 // |last_opened_profiles| will be empty in the following circumstances: |
| 721 // - This is the first launch. |last_used_profile| is the initial profile. | 740 // - This is the first launch. |last_used_profile| is the initial profile. |
| 722 // - The user exited the browser by closing all windows for all | 741 // - The user exited the browser by closing all windows for all |
| 723 // profiles. |last_used_profile| is the profile which owned the last open | 742 // profiles. |last_used_profile| is the profile which owned the last open |
| 724 // window. | 743 // window. |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 741 // Guest profiles should not be reopened on startup. This can happen if | 760 // Guest profiles should not be reopened on startup. This can happen if |
| 742 // the last used profile was a Guest, but other profiles were also open | 761 // the last used profile was a Guest, but other profiles were also open |
| 743 // when Chrome was closed. In this case, pick a different open profile | 762 // when Chrome was closed. In this case, pick a different open profile |
| 744 // to be the active one, since the Guest profile is never added to the list | 763 // to be the active one, since the Guest profile is never added to the list |
| 745 // of open profiles. | 764 // of open profiles. |
| 746 if (last_used_profile->IsGuestSession()) { | 765 if (last_used_profile->IsGuestSession()) { |
| 747 DCHECK(!last_opened_profiles[0]->IsGuestSession()); | 766 DCHECK(!last_opened_profiles[0]->IsGuestSession()); |
| 748 last_used_profile = last_opened_profiles[0]; | 767 last_used_profile = last_opened_profiles[0]; |
| 749 } | 768 } |
| 750 #endif | 769 #endif |
| 751 | |
| 752 // Launch the last used profile with the full command line, and the other | 770 // Launch the last used profile with the full command line, and the other |
| 753 // opened profiles without the URLs to launch. | 771 // opened profiles without the URLs to launch. |
| 754 base::CommandLine command_line_without_urls(command_line.GetProgram()); | 772 base::CommandLine command_line_without_urls(command_line.GetProgram()); |
| 755 const base::CommandLine::SwitchMap& switches = command_line.GetSwitches(); | 773 const base::CommandLine::SwitchMap& switches = command_line.GetSwitches(); |
| 756 for (base::CommandLine::SwitchMap::const_iterator switch_it = | 774 for (base::CommandLine::SwitchMap::const_iterator switch_it = |
| 757 switches.begin(); | 775 switches.begin(); |
| 758 switch_it != switches.end(); ++switch_it) { | 776 switch_it != switches.end(); ++switch_it) { |
| 759 command_line_without_urls.AppendSwitchNative(switch_it->first, | 777 command_line_without_urls.AppendSwitchNative(switch_it->first, |
| 760 switch_it->second); | 778 switch_it->second); |
| 761 } | 779 } |
| 762 // Launch the profiles in the order they became active. | 780 // Launch the profiles in the order they became active. |
| 763 for (Profiles::const_iterator it = last_opened_profiles.begin(); | 781 for (Profiles::const_iterator it = last_opened_profiles.begin(); |
| 764 it != last_opened_profiles.end(); ++it) { | 782 it != last_opened_profiles.end(); ++it) { |
| 765 DCHECK(!(*it)->IsGuestSession()); | 783 DCHECK(!(*it)->IsGuestSession()); |
| 766 // Don't launch additional profiles which would only open a new tab | 784 // Don't launch additional profiles which would only open a new tab |
| 767 // page. When restarting after an update, all profiles will reopen last | 785 // page. When restarting after an update, all profiles will reopen last |
| 768 // open pages. | 786 // open pages. |
| 769 SessionStartupPref startup_pref = | 787 SessionStartupPref startup_pref = |
| 770 GetSessionStartupPref(command_line, *it); | 788 GetSessionStartupPref(command_line, *it); |
| 771 if (*it != last_used_profile && | 789 if (*it != last_used_profile && |
| 772 startup_pref.type == SessionStartupPref::DEFAULT && | 790 startup_pref.type == SessionStartupPref::DEFAULT && |
| 773 !HasPendingUncleanExit(*it)) | 791 !HasPendingUncleanExit(*it)) |
| 774 continue; | 792 continue; |
| 775 | |
| 776 if (!LaunchBrowser((*it == last_used_profile) ? command_line | 793 if (!LaunchBrowser((*it == last_used_profile) ? command_line |
| 777 : command_line_without_urls, | 794 : command_line_without_urls, |
| 778 *it, cur_dir, is_process_startup, is_first_run)) | 795 *it, cur_dir, is_process_startup, is_first_run)) |
| 779 return false; | 796 return false; |
| 780 // We've launched at least one browser. | 797 // We've launched at least one browser. |
| 781 is_process_startup = chrome::startup::IS_NOT_PROCESS_STARTUP; | 798 is_process_startup = chrome::startup::IS_NOT_PROCESS_STARTUP; |
| 782 } | 799 } |
| 783 // This must be done after all profiles have been launched so the observer | 800 // This must be done after all profiles have been launched so the observer |
| 784 // knows about all profiles to wait for before activating this one. | 801 // knows about all profiles to wait for before activating this one. |
| 785 profile_launch_observer.Get().set_profile_to_activate(last_used_profile); | 802 profile_launch_observer.Get().set_profile_to_activate(last_used_profile); |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 873 } | 890 } |
| 874 | 891 |
| 875 // If we are showing the app list then chrome isn't shown so load the app | 892 // If we are showing the app list then chrome isn't shown so load the app |
| 876 // list's profile rather than chrome's. | 893 // list's profile rather than chrome's. |
| 877 if (command_line.HasSwitch(switches::kShowAppList)) | 894 if (command_line.HasSwitch(switches::kShowAppList)) |
| 878 return AppListService::Get()->GetProfilePath(user_data_dir); | 895 return AppListService::Get()->GetProfilePath(user_data_dir); |
| 879 | 896 |
| 880 return g_browser_process->profile_manager()->GetLastUsedProfileDir( | 897 return g_browser_process->profile_manager()->GetLastUsedProfileDir( |
| 881 user_data_dir); | 898 user_data_dir); |
| 882 } | 899 } |
| OLD | NEW |