Index: chrome/browser/ui/cocoa/base_bubble_controller.mm |
diff --git a/chrome/browser/ui/cocoa/base_bubble_controller.mm b/chrome/browser/ui/cocoa/base_bubble_controller.mm |
index 08b3912d2a8c7e4e3d37d3152d85d6866af0a269..9ac37495e0399eac382529cbc875ddc566d36689 100644 |
--- a/chrome/browser/ui/cocoa/base_bubble_controller.mm |
+++ b/chrome/browser/ui/cocoa/base_bubble_controller.mm |
@@ -10,16 +10,18 @@ |
#include "base/mac/mac_util.h" |
#include "base/memory/scoped_nsobject.h" |
#include "base/string_util.h" |
+#import "chrome/browser/ui/cocoa/browser_window_controller.h" |
#import "chrome/browser/ui/cocoa/info_bubble_view.h" |
-#include "content/public/browser/notification_observer.h" |
-#include "content/public/browser/notification_registrar.h" |
-#include "content/public/browser/notification_service.h" |
-#include "content/public/browser/notification_types.h" |
+#import "chrome/browser/ui/cocoa/tabs/tab_strip_model_observer_bridge.h" |
#include "grit/generated_resources.h" |
#include "ui/base/l10n/l10n_util.h" |
@interface BaseBubbleController (Private) |
- (void)updateOriginFromAnchor; |
+- (void)activateTabWithContents:(TabContentsWrapper*)newContents |
+ previousContents:(TabContentsWrapper*)oldContents |
+ atIndex:(NSInteger)index |
+ userGesture:(bool)wasUserGesture; |
@end |
#if !defined(MAC_OS_X_VERSION_10_6) || \ |
@@ -44,31 +46,6 @@ typedef unsigned long long NSEventMask; |
@end |
#endif // MAC_OS_X_VERSION_10_6 |
-namespace BaseBubbleControllerInternal { |
- |
-// This bridge listens for notifications so that the bubble closes when a user |
-// switches tabs (including by opening a new one). |
-class Bridge : public content::NotificationObserver { |
- public: |
- explicit Bridge(BaseBubbleController* controller) : controller_(controller) { |
- registrar_.Add(this, content::NOTIFICATION_WEB_CONTENTS_HIDDEN, |
- content::NotificationService::AllSources()); |
- } |
- |
- // content::NotificationObserver: |
- virtual void Observe(int type, |
- const content::NotificationSource& source, |
- const content::NotificationDetails& details) { |
- [controller_ close]; |
- } |
- |
- private: |
- BaseBubbleController* controller_; // Weak, owns this. |
- content::NotificationRegistrar registrar_; |
-}; |
- |
-} // namespace BaseBubbleControllerInternal |
- |
@implementation BaseBubbleController |
@synthesize parentWindow = parentWindow_; |
@@ -142,7 +119,14 @@ class Bridge : public content::NotificationObserver { |
DCHECK(bubble_); |
DCHECK_EQ(self, [[self window] delegate]); |
- baseBridge_.reset(new BaseBubbleControllerInternal::Bridge(self)); |
+ BrowserWindowController* bwc = |
+ [BrowserWindowController browserWindowControllerForWindow:parentWindow_]; |
+ if (bwc) { |
+ TabStripController* tabStripController = [bwc tabStripController]; |
+ TabStripModel* tabStripModel = [tabStripController tabStripModel]; |
+ tabStripObserverBridge_.reset(new TabStripModelObserverBridge(tabStripModel, |
+ self)); |
+ } |
[bubble_ setArrowLocation:info_bubble::kTopRight]; |
} |
@@ -205,6 +189,8 @@ class Bridge : public content::NotificationObserver { |
resignationObserver_ = nil; |
} |
+ tabStripObserverBridge_.reset(); |
+ |
[[[self window] parentWindow] removeChildWindow:[self window]]; |
[super close]; |
} |
@@ -305,4 +291,12 @@ class Bridge : public content::NotificationObserver { |
[window setFrameOrigin:origin]; |
} |
+- (void)activateTabWithContents:(TabContentsWrapper*)newContents |
+ previousContents:(TabContentsWrapper*)oldContents |
+ atIndex:(NSInteger)index |
+ userGesture:(bool)wasUserGesture { |
+ // The user switched tabs; close. |
+ [self close]; |
+} |
+ |
@end // BaseBubbleController |