OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #import "chrome/browser/ui/cocoa/base_bubble_controller.h" | 5 #import "chrome/browser/ui/cocoa/base_bubble_controller.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/mac/mac_util.h" | 8 #include "base/mac/mac_util.h" |
9 #include "base/memory/scoped_nsobject.h" | 9 #include "base/memory/scoped_nsobject.h" |
10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
11 #import "chrome/browser/ui/cocoa/info_bubble_view.h" | 11 #import "chrome/browser/ui/cocoa/info_bubble_view.h" |
| 12 #include "content/common/content_notification_types.h" |
12 #include "content/common/notification_observer.h" | 13 #include "content/common/notification_observer.h" |
13 #include "content/common/notification_registrar.h" | 14 #include "content/common/notification_registrar.h" |
14 #include "content/common/notification_service.h" | 15 #include "content/common/notification_service.h" |
15 #include "content/common/notification_type.h" | |
16 #include "grit/generated_resources.h" | 16 #include "grit/generated_resources.h" |
17 #include "ui/base/l10n/l10n_util.h" | 17 #include "ui/base/l10n/l10n_util.h" |
18 | 18 |
19 @interface BaseBubbleController (Private) | 19 @interface BaseBubbleController (Private) |
20 - (void)updateOriginFromAnchor; | 20 - (void)updateOriginFromAnchor; |
21 @end | 21 @end |
22 | 22 |
23 namespace BaseBubbleControllerInternal { | 23 namespace BaseBubbleControllerInternal { |
24 | 24 |
25 // This bridge listens for notifications so that the bubble closes when a user | 25 // This bridge listens for notifications so that the bubble closes when a user |
26 // switches tabs (including by opening a new one). | 26 // switches tabs (including by opening a new one). |
27 class Bridge : public NotificationObserver { | 27 class Bridge : public NotificationObserver { |
28 public: | 28 public: |
29 explicit Bridge(BaseBubbleController* controller) : controller_(controller) { | 29 explicit Bridge(BaseBubbleController* controller) : controller_(controller) { |
30 registrar_.Add(this, NotificationType::TAB_CONTENTS_HIDDEN, | 30 registrar_.Add(this, content::NOTIFICATION_TAB_CONTENTS_HIDDEN, |
31 NotificationService::AllSources()); | 31 NotificationService::AllSources()); |
32 } | 32 } |
33 | 33 |
34 // NotificationObserver: | 34 // NotificationObserver: |
35 virtual void Observe(NotificationType type, | 35 virtual void Observe(int type, |
36 const NotificationSource& source, | 36 const NotificationSource& source, |
37 const NotificationDetails& details) { | 37 const NotificationDetails& details) { |
38 [controller_ close]; | 38 [controller_ close]; |
39 } | 39 } |
40 | 40 |
41 private: | 41 private: |
42 BaseBubbleController* controller_; // Weak, owns this. | 42 BaseBubbleController* controller_; // Weak, owns this. |
43 NotificationRegistrar registrar_; | 43 NotificationRegistrar registrar_; |
44 }; | 44 }; |
45 | 45 |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
191 if ([bubble_ arrowLocation] == info_bubble::kTopRight) { | 191 if ([bubble_ arrowLocation] == info_bubble::kTopRight) { |
192 origin.x -= NSWidth([window frame]) - offsets.width; | 192 origin.x -= NSWidth([window frame]) - offsets.width; |
193 } else { | 193 } else { |
194 origin.x -= offsets.width; | 194 origin.x -= offsets.width; |
195 } | 195 } |
196 origin.y -= NSHeight([window frame]); | 196 origin.y -= NSHeight([window frame]); |
197 [window setFrameOrigin:origin]; | 197 [window setFrameOrigin:origin]; |
198 } | 198 } |
199 | 199 |
200 @end // BaseBubbleController | 200 @end // BaseBubbleController |
OLD | NEW |