diff options
author | mark@chromium.org <mark@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-06-24 15:59:02 +0000 |
---|---|---|
committer | mark@chromium.org <mark@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-06-24 15:59:02 +0000 |
commit | d9fcd263ece8e879e2e98a1cd7477d255abbbdb4 (patch) | |
tree | b5bfaf81c9585881eac788b4df17e362537a95a0 /base/mac | |
parent | ec198d3eb81abf01a75dfb556c505cbb491ec7a0 (diff) | |
download | chromium_src-d9fcd263ece8e879e2e98a1cd7477d255abbbdb4.zip chromium_src-d9fcd263ece8e879e2e98a1cd7477d255abbbdb4.tar.gz chromium_src-d9fcd263ece8e879e2e98a1cd7477d255abbbdb4.tar.bz2 |
Fix relaunches on the Mac.
Relaunches that go through browser_shutdown and relaunches after
install-from-disk-image should both be improved. browser_shutdown relaunches
include those that occur when Chrome detects a new version and offers to
relaunch itself, and those that occur when you change about:flags and click
"Relaunch Now."
When relaunching Chrome in the same location via browser_shutdown, the same
Dock tile should now always be reused, provided that the tile is persistent,
meaning that the user has chosen "Keep in Dock" from the tile's contextual
menu.
The relaunched process' activation status (foreground or background
application) should now track the original process' activation status.
BUG=42962, 85073
TEST=1a. Change something in about:flags and hit "Relaunch Now" at the bottom.
If you had a persistent Dock tile, the same tile should be used for
the relaunched browser every time, without fail.
1b. Same, but once you're running a version of Chrome (including a
canary) with this fix, when an update is applied and you relaunch
from within the application via the "Update Google Chrome" item in
the wrench menu or the "Relaunch" button in the about window, the
same tile should be used for the relaunched browser every time,
without fail.
2. Relaunch after install from disk image. Remove Chrome from
/Applications and double-click the Chrome icon in a read-only disk
image carrying a version that has this fix. (Our official or canary
disk images will work). Chrome will offer to install itself. Let it.
Upon completion of the installation, Chrome should launch out of
/Applications properly. If you had a persistent Dock tile pointing to
a copy in /Applications, it will be used. Activation status
(foreground or background) in the relaunched browser will match the
status in the process that had run out of the disk image at the time
that the installation completed.
Review URL: http://codereview.chromium.org/7215040
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@90371 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/mac')
-rw-r--r-- | base/mac/mac_util.h | 5 | ||||
-rw-r--r-- | base/mac/mac_util.mm | 20 |
2 files changed, 25 insertions, 0 deletions
diff --git a/base/mac/mac_util.h b/base/mac/mac_util.h index 7fe22c5..71d3a6f 100644 --- a/base/mac/mac_util.h +++ b/base/mac/mac_util.h @@ -78,6 +78,11 @@ bool ShouldWindowsMiniaturizeOnDoubleClick(); // Activates the process with the given PID. void ActivateProcess(pid_t pid); +// Returns true if this process is in the foreground, meaning that it's the +// frontmost process, the one whose menu bar is shown at the top of the main +// display. +bool AmIForeground(); + // Excludes the file given by |file_path| from being backed up by Time Machine. bool SetFileBackupExclusion(const FilePath& file_path); diff --git a/base/mac/mac_util.mm b/base/mac/mac_util.mm index d3bb5a6..0f34180 100644 --- a/base/mac/mac_util.mm +++ b/base/mac/mac_util.mm @@ -242,6 +242,26 @@ void ActivateProcess(pid_t pid) { } } +bool AmIForeground() { + ProcessSerialNumber foreground_psn = { 0 }; + OSErr err = GetFrontProcess(&foreground_psn); + if (err != noErr) { + LOG(WARNING) << "GetFrontProcess: " << err; + return false; + } + + ProcessSerialNumber my_psn = { 0, kCurrentProcess }; + + Boolean result = FALSE; + err = SameProcess(&foreground_psn, &my_psn, &result); + if (err != noErr) { + LOG(WARNING) << "SameProcess: " << err; + return false; + } + + return result; +} + bool SetFileBackupExclusion(const FilePath& file_path) { NSString* file_path_ns = [NSString stringWithUTF8String:file_path.value().c_str()]; |