| 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/public/browser/notification_observer.h" | 12 #include "content/public/browser/notification_observer.h" |
| 13 #include "content/public/browser/notification_registrar.h" | 13 #include "content/public/browser/notification_registrar.h" |
| 14 #include "content/common/notification_service.h" | 14 #include "content/public/browser/notification_service.h" |
| 15 #include "content/public/browser/notification_types.h" | 15 #include "content/public/browser/notification_types.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 content::NotificationObserver { | 27 class Bridge : public content::NotificationObserver { |
| 28 public: | 28 public: |
| 29 explicit Bridge(BaseBubbleController* controller) : controller_(controller) { | 29 explicit Bridge(BaseBubbleController* controller) : controller_(controller) { |
| 30 registrar_.Add(this, content::NOTIFICATION_TAB_CONTENTS_HIDDEN, | 30 registrar_.Add(this, content::NOTIFICATION_TAB_CONTENTS_HIDDEN, |
| 31 NotificationService::AllSources()); | 31 content::NotificationService::AllSources()); |
| 32 } | 32 } |
| 33 | 33 |
| 34 // content::NotificationObserver: | 34 // content::NotificationObserver: |
| 35 virtual void Observe(int type, | 35 virtual void Observe(int type, |
| 36 const content::NotificationSource& source, | 36 const content::NotificationSource& source, |
| 37 const content::NotificationDetails& details) { | 37 const content::NotificationDetails& details) { |
| 38 [controller_ close]; | 38 [controller_ close]; |
| 39 } | 39 } |
| 40 | 40 |
| 41 private: | 41 private: |
| (...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 201 if ([bubble_ arrowLocation] == info_bubble::kTopRight) { | 201 if ([bubble_ arrowLocation] == info_bubble::kTopRight) { |
| 202 origin.x -= NSWidth([window frame]) - offsets.width; | 202 origin.x -= NSWidth([window frame]) - offsets.width; |
| 203 } else { | 203 } else { |
| 204 origin.x -= offsets.width; | 204 origin.x -= offsets.width; |
| 205 } | 205 } |
| 206 origin.y -= NSHeight([window frame]); | 206 origin.y -= NSHeight([window frame]); |
| 207 [window setFrameOrigin:origin]; | 207 [window setFrameOrigin:origin]; |
| 208 } | 208 } |
| 209 | 209 |
| 210 @end // BaseBubbleController | 210 @end // BaseBubbleController |
| OLD | NEW |