summaryrefslogtreecommitdiffstats
path: root/chrome/browser/chrome_browser_application_mac.mm
diff options
context:
space:
mode:
authormark@chromium.org <mark@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-03-24 03:47:59 +0000
committermark@chromium.org <mark@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-03-24 03:47:59 +0000
commit1dd17d77d24a3232976e03b3ec5c7c61a14f1015 (patch)
tree1908be9b6513b74a7b90b1d45b98a2827efa5d12 /chrome/browser/chrome_browser_application_mac.mm
parent051b520a6c03a0bbb1e6385cff114411296b52d1 (diff)
downloadchromium_src-1dd17d77d24a3232976e03b3ec5c7c61a14f1015.zip
chromium_src-1dd17d77d24a3232976e03b3ec5c7c61a14f1015.tar.gz
chromium_src-1dd17d77d24a3232976e03b3ec5c7c61a14f1015.tar.bz2
Fix install-from-dmg.
When installing from a disk image, the browser relaunched from the newly-installed location should follow the proper first-run experience if appropriate. When installing from a disk image, existing dock tiles should be reused, and dock tiles pointing at the application on the disk image should be replaced with ones pointing at the newly-installed location. When installing from a disk image and requesting administrator access (because the user does not have permission to install to /Applications), Keystone should be promoted to a system-level install, and Chrome's Keystone ticket should be promoted to a system Keystone ticket. The custom panel key window tracking stuff doesn't need to maintain strong references to key windows, but does need to be beefed up for thread safety. Chrome doesn't need to wait until it's mostly started up to run the install-from-dmg flow. It should do it early, avoiding delays and reducing the possibility that harmful services will start running. BUG=119325 TEST=obvious from the above and the bug Review URL: http://codereview.chromium.org/9814029 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@128677 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/chrome_browser_application_mac.mm')
-rw-r--r--chrome/browser/chrome_browser_application_mac.mm43
1 files changed, 33 insertions, 10 deletions
diff --git a/chrome/browser/chrome_browser_application_mac.mm b/chrome/browser/chrome_browser_application_mac.mm
index 76c1660..765cec2 100644
--- a/chrome/browser/chrome_browser_application_mac.mm
+++ b/chrome/browser/chrome_browser_application_mac.mm
@@ -211,8 +211,15 @@ void SwizzleInit() {
// Used to determine when a Panel window can become the key window.
@interface NSApplication (PanelsCanBecomeKey)
- (void)_cycleWindowsReversed:(BOOL)arg1;
-- (id)_removeWindow:(id)window;
-- (id)_setKeyWindow:(id)window;
+- (id)_removeWindow:(NSWindow*)window;
+- (id)_setKeyWindow:(NSWindow*)window;
+@end
+
+@interface BrowserCrApplication (PrivateInternal)
+
+// This must be called under the protection of previousKeyWindowsLock_.
+- (void)removePreviousKeyWindow:(NSWindow*)window;
+
@end
@implementation BrowserCrApplication
@@ -227,7 +234,6 @@ void SwizzleInit() {
SwizzleInit();
if ((self = [super init])) {
eventHooks_.reset([[NSMutableArray alloc] init]);
- previousKeyWindows_.reset([[NSMutableArray alloc] init]);
}
// Sanity check to alert if overridden methods are not supported.
@@ -516,8 +522,11 @@ void SwizzleInit() {
return cyclingWindows_;
}
-- (id)_removeWindow:(id)window {
- [previousKeyWindows_ removeObject:window];
+- (id)_removeWindow:(NSWindow*)window {
+ {
+ base::AutoLock lock(previousKeyWindowsLock_);
+ [self removePreviousKeyWindow:window];
+ }
id result = [super _removeWindow:window];
// Ensure app has a key window after a window is removed.
@@ -537,21 +546,35 @@ void SwizzleInit() {
return result;
}
-- (id)_setKeyWindow:(id)window {
+- (id)_setKeyWindow:(NSWindow*)window {
// |window| is nil when the current key window is being closed.
// A separate call follows with a new value when a new key window is set.
// Closed windows are not tracked in previousKeyWindows_.
if (window != nil) {
- [previousKeyWindows_ removeObject:window];
+ base::AutoLock lock(previousKeyWindowsLock_);
+ [self removePreviousKeyWindow:window];
NSWindow* currentKeyWindow = [self keyWindow];
if (currentKeyWindow != nil && currentKeyWindow != window)
- [previousKeyWindows_ addObject:currentKeyWindow];
+ previousKeyWindows_.push_back(window);
}
return [super _setKeyWindow:window];
}
-- (id)previousKeyWindow {
- return [previousKeyWindows_ lastObject];
+- (NSWindow*)previousKeyWindow {
+ base::AutoLock lock(previousKeyWindowsLock_);
+ return previousKeyWindows_.empty() ? nil : previousKeyWindows_.back();
}
+
+- (void)removePreviousKeyWindow:(NSWindow*)window {
+ previousKeyWindowsLock_.AssertAcquired();
+ std::vector<NSWindow*>::iterator window_iterator =
+ std::find(previousKeyWindows_.begin(),
+ previousKeyWindows_.end(),
+ window);
+ if (window_iterator != previousKeyWindows_.end()) {
+ previousKeyWindows_.erase(window_iterator);
+ }
+}
+
@end