From 06d02b11b0bf54ea3a5ab9735626367607e5f122 Mon Sep 17 00:00:00 2001 From: "malcolm.2.wang@gmail.com" Date: Thu, 19 Jun 2014 15:28:40 +0000 Subject: Fix not to close the bubble when entering full screen. Listen to the full screen event, then if so, close the bubble. BUG=326081 Review URL: https://codereview.chromium.org/320393005 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@278385 0039d316-1c4b-4281-b951-d872f2087c98 --- AUTHORS | 1 + base/base.gypi | 1 + base/mac/sdk_forward_declarations.h | 5 ++++- base/mac/sdk_forward_declarations.mm | 14 ++++++++++++++ chrome/browser/ui/cocoa/base_bubble_controller.mm | 15 +++++++++++++++ 5 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 base/mac/sdk_forward_declarations.mm diff --git a/AUTHORS b/AUTHORS index 36f3670..267ff5b 100644 --- a/AUTHORS +++ b/AUTHORS @@ -227,6 +227,7 @@ Luke Zarko Maarten Lankhorst Magnus Danielsson Mahesh Kulkarni +Malcolm Wang Manuel Braun Mao Yujie Mao Yujie diff --git a/base/base.gypi b/base/base.gypi index 8c603a7..c033dcb 100644 --- a/base/base.gypi +++ b/base/base.gypi @@ -308,6 +308,7 @@ 'mac/scoped_sending_event.mm', 'mac/scoped_typeref.h', 'mac/sdk_forward_declarations.h', + 'mac/sdk_forward_declarations.mm', 'macros.h', 'md5.cc', 'md5.h', diff --git a/base/mac/sdk_forward_declarations.h b/base/mac/sdk_forward_declarations.h index e53fdbd..3a0878da 100644 --- a/base/mac/sdk_forward_declarations.h +++ b/base/mac/sdk_forward_declarations.h @@ -16,6 +16,8 @@ #import #import +#include "base/base_export.h" + #if !defined(MAC_OS_X_VERSION_10_7) || \ MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_7 @@ -180,8 +182,9 @@ enum CWChannelBand { - (IOReturn)performSDPQuery:(id)target uuids:(NSArray*)uuids; @end -#endif // MAC_OS_X_VERSION_10_7 +BASE_EXPORT extern "C" NSString* const NSWindowWillEnterFullScreenNotification; +#endif // MAC_OS_X_VERSION_10_7 #if !defined(MAC_OS_X_VERSION_10_8) || \ MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_8 diff --git a/base/mac/sdk_forward_declarations.mm b/base/mac/sdk_forward_declarations.mm new file mode 100644 index 0000000..a402a41 --- /dev/null +++ b/base/mac/sdk_forward_declarations.mm @@ -0,0 +1,14 @@ +// Copyright 2014 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "base/mac/sdk_forward_declarations.h" + +// Replicate specific 10.7 SDK declarations for building with prior SDKs. +#if !defined(MAC_OS_X_VERSION_10_7) || \ + MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_7 + +NSString* const NSWindowWillEnterFullScreenNotification = + @"NSWindowWillEnterFullScreenNotification"; + +#endif // MAC_OS_X_VERSION_10_7 diff --git a/chrome/browser/ui/cocoa/base_bubble_controller.mm b/chrome/browser/ui/cocoa/base_bubble_controller.mm index 2628f05..fd19a0d 100644 --- a/chrome/browser/ui/cocoa/base_bubble_controller.mm +++ b/chrome/browser/ui/cocoa/base_bubble_controller.mm @@ -8,6 +8,7 @@ #include "base/mac/bundle_locations.h" #include "base/mac/mac_util.h" #include "base/mac/scoped_nsobject.h" +#include "base/mac/sdk_forward_declarations.h" #include "base/strings/string_util.h" #import "chrome/browser/ui/cocoa/browser_window_controller.h" #import "chrome/browser/ui/cocoa/info_bubble_view.h" @@ -25,6 +26,7 @@ - (void)recordAnchorOffset; - (void)parentWindowDidResize:(NSNotification*)notification; - (void)parentWindowWillClose:(NSNotification*)notification; +- (void)parentWindowWillBecomeFullScreen:(NSNotification*)notification; - (void)closeCleanup; @end @@ -119,6 +121,11 @@ selector:@selector(parentWindowWillClose:) name:NSWindowWillCloseNotification object:parentWindow_]; + // Watch for the full screen event, if so, close the bubble + [center addObserver:self + selector:@selector(parentWindowWillBecomeFullScreen:) + name:NSWindowWillEnterFullScreenNotification + object:parentWindow_]; // Watch for parent window's resizing, to ensure this one is always // anchored correctly. [center addObserver:self @@ -151,6 +158,9 @@ } - (void)parentWindowDidResize:(NSNotification*)notification { + if (!parentWindow_) + return; + DCHECK_EQ(parentWindow_, [notification object]); NSPoint newOrigin = NSMakePoint(NSMinX([parentWindow_ frame]), NSMaxY([parentWindow_ frame])); @@ -164,6 +174,11 @@ [self close]; } +- (void)parentWindowWillBecomeFullScreen:(NSNotification*)notification { + parentWindow_ = nil; + [self close]; +} + - (void)closeCleanup { if (eventTap_) { [NSEvent removeMonitor:eventTap_]; -- cgit v1.1