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

Side by Side Diff: chrome/browser/ui/startup/startup_browser_creator.cc

Issue 1949393007: X11: Better timestamp handling for _NET_ACTIVE_WINDOW (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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 #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
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
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 =
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 #endif
732
715 chrome::startup::IsProcessStartup is_process_startup = process_startup ? 733 chrome::startup::IsProcessStartup is_process_startup = process_startup ?
716 chrome::startup::IS_PROCESS_STARTUP : 734 chrome::startup::IS_PROCESS_STARTUP :
717 chrome::startup::IS_NOT_PROCESS_STARTUP; 735 chrome::startup::IS_NOT_PROCESS_STARTUP;
718 chrome::startup::IsFirstRun is_first_run = first_run::IsChromeFirstRun() ? 736 chrome::startup::IsFirstRun is_first_run = first_run::IsChromeFirstRun() ?
719 chrome::startup::IS_FIRST_RUN : chrome::startup::IS_NOT_FIRST_RUN; 737 chrome::startup::IS_FIRST_RUN : chrome::startup::IS_NOT_FIRST_RUN;
720 // |last_opened_profiles| will be empty in the following circumstances: 738 // |last_opened_profiles| will be empty in the following circumstances:
721 // - This is the first launch. |last_used_profile| is the initial profile. 739 // - This is the first launch. |last_used_profile| is the initial profile.
722 // - The user exited the browser by closing all windows for all 740 // - The user exited the browser by closing all windows for all
723 // profiles. |last_used_profile| is the profile which owned the last open 741 // profiles. |last_used_profile| is the profile which owned the last open
724 // window. 742 // window.
(...skipping 16 matching lines...) Expand all
741 // Guest profiles should not be reopened on startup. This can happen if 759 // 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 760 // 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 761 // 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 762 // to be the active one, since the Guest profile is never added to the list
745 // of open profiles. 763 // of open profiles.
746 if (last_used_profile->IsGuestSession()) { 764 if (last_used_profile->IsGuestSession()) {
747 DCHECK(!last_opened_profiles[0]->IsGuestSession()); 765 DCHECK(!last_opened_profiles[0]->IsGuestSession());
748 last_used_profile = last_opened_profiles[0]; 766 last_used_profile = last_opened_profiles[0];
749 } 767 }
750 #endif 768 #endif
751
752 // Launch the last used profile with the full command line, and the other 769 // Launch the last used profile with the full command line, and the other
753 // opened profiles without the URLs to launch. 770 // opened profiles without the URLs to launch.
754 base::CommandLine command_line_without_urls(command_line.GetProgram()); 771 base::CommandLine command_line_without_urls(command_line.GetProgram());
755 const base::CommandLine::SwitchMap& switches = command_line.GetSwitches(); 772 const base::CommandLine::SwitchMap& switches = command_line.GetSwitches();
756 for (base::CommandLine::SwitchMap::const_iterator switch_it = 773 for (base::CommandLine::SwitchMap::const_iterator switch_it =
757 switches.begin(); 774 switches.begin();
758 switch_it != switches.end(); ++switch_it) { 775 switch_it != switches.end(); ++switch_it) {
759 command_line_without_urls.AppendSwitchNative(switch_it->first, 776 command_line_without_urls.AppendSwitchNative(switch_it->first,
760 switch_it->second); 777 switch_it->second);
761 } 778 }
762 // Launch the profiles in the order they became active. 779 // Launch the profiles in the order they became active.
763 for (Profiles::const_iterator it = last_opened_profiles.begin(); 780 for (Profiles::const_iterator it = last_opened_profiles.begin();
764 it != last_opened_profiles.end(); ++it) { 781 it != last_opened_profiles.end(); ++it) {
765 DCHECK(!(*it)->IsGuestSession()); 782 DCHECK(!(*it)->IsGuestSession());
766 // Don't launch additional profiles which would only open a new tab 783 // Don't launch additional profiles which would only open a new tab
767 // page. When restarting after an update, all profiles will reopen last 784 // page. When restarting after an update, all profiles will reopen last
768 // open pages. 785 // open pages.
769 SessionStartupPref startup_pref = 786 SessionStartupPref startup_pref =
770 GetSessionStartupPref(command_line, *it); 787 GetSessionStartupPref(command_line, *it);
771 if (*it != last_used_profile && 788 if (*it != last_used_profile &&
772 startup_pref.type == SessionStartupPref::DEFAULT && 789 startup_pref.type == SessionStartupPref::DEFAULT &&
773 !HasPendingUncleanExit(*it)) 790 !HasPendingUncleanExit(*it))
774 continue; 791 continue;
775
776 if (!LaunchBrowser((*it == last_used_profile) ? command_line 792 if (!LaunchBrowser((*it == last_used_profile) ? command_line
777 : command_line_without_urls, 793 : command_line_without_urls,
778 *it, cur_dir, is_process_startup, is_first_run)) 794 *it, cur_dir, is_process_startup, is_first_run))
779 return false; 795 return false;
780 // We've launched at least one browser. 796 // We've launched at least one browser.
781 is_process_startup = chrome::startup::IS_NOT_PROCESS_STARTUP; 797 is_process_startup = chrome::startup::IS_NOT_PROCESS_STARTUP;
782 } 798 }
783 // This must be done after all profiles have been launched so the observer 799 // 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. 800 // knows about all profiles to wait for before activating this one.
785 profile_launch_observer.Get().set_profile_to_activate(last_used_profile); 801 profile_launch_observer.Get().set_profile_to_activate(last_used_profile);
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
873 } 889 }
874 890
875 // If we are showing the app list then chrome isn't shown so load the app 891 // If we are showing the app list then chrome isn't shown so load the app
876 // list's profile rather than chrome's. 892 // list's profile rather than chrome's.
877 if (command_line.HasSwitch(switches::kShowAppList)) 893 if (command_line.HasSwitch(switches::kShowAppList))
878 return AppListService::Get()->GetProfilePath(user_data_dir); 894 return AppListService::Get()->GetProfilePath(user_data_dir);
879 895
880 return g_browser_process->profile_manager()->GetLastUsedProfileDir( 896 return g_browser_process->profile_manager()->GetLastUsedProfileDir(
881 user_data_dir); 897 user_data_dir);
882 } 898 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698