| 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 #ifndef UI_BASE_COCOA_TRACKING_AREA_H_ | 5 #ifndef UI_BASE_COCOA_TRACKING_AREA_H_ |
| 6 #define UI_BASE_COCOA_TRACKING_AREA_H_ | 6 #define UI_BASE_COCOA_TRACKING_AREA_H_ |
| 7 | 7 |
| 8 #import <AppKit/AppKit.h> | 8 #import <AppKit/AppKit.h> |
| 9 | 9 |
| 10 #include "base/mac/scoped_nsobject.h" | 10 #include "base/mac/scoped_nsobject.h" |
| 11 #include "ui/base/ui_export.h" | 11 #include "ui/base/ui_base_export.h" |
| 12 | 12 |
| 13 @class CrTrackingAreaOwnerProxy; | 13 @class CrTrackingAreaOwnerProxy; |
| 14 | 14 |
| 15 // The CrTrackingArea can be used in place of an NSTrackingArea to shut off | 15 // The CrTrackingArea can be used in place of an NSTrackingArea to shut off |
| 16 // messaging to the |owner| at a specific point in time. | 16 // messaging to the |owner| at a specific point in time. |
| 17 UI_EXPORT | 17 UI_BASE_EXPORT |
| 18 @interface CrTrackingArea : NSTrackingArea { | 18 @interface CrTrackingArea : NSTrackingArea { |
| 19 @private | 19 @private |
| 20 base::scoped_nsobject<CrTrackingAreaOwnerProxy> ownerProxy_; | 20 base::scoped_nsobject<CrTrackingAreaOwnerProxy> ownerProxy_; |
| 21 } | 21 } |
| 22 | 22 |
| 23 // Designated initializer. Forwards all arguments to the superclass, but wraps | 23 // Designated initializer. Forwards all arguments to the superclass, but wraps |
| 24 // |owner| in a proxy object. | 24 // |owner| in a proxy object. |
| 25 - (id)initWithRect:(NSRect)rect | 25 - (id)initWithRect:(NSRect)rect |
| 26 options:(NSTrackingAreaOptions)options | 26 options:(NSTrackingAreaOptions)options |
| 27 owner:(id)owner | 27 owner:(id)owner |
| 28 userInfo:(NSDictionary*)userInfo; | 28 userInfo:(NSDictionary*)userInfo; |
| 29 | 29 |
| 30 // Prevents any future messages from being delivered to the |owner|. | 30 // Prevents any future messages from being delivered to the |owner|. |
| 31 - (void)clearOwner; | 31 - (void)clearOwner; |
| 32 | 32 |
| 33 // Watches |window| for its NSWindowWillCloseNotification and calls | 33 // Watches |window| for its NSWindowWillCloseNotification and calls |
| 34 // |-clearOwner| when the notification is observed. | 34 // |-clearOwner| when the notification is observed. |
| 35 - (void)clearOwnerWhenWindowWillClose:(NSWindow*)window; | 35 - (void)clearOwnerWhenWindowWillClose:(NSWindow*)window; |
| 36 | 36 |
| 37 @end | 37 @end |
| 38 | 38 |
| 39 // Scoper ////////////////////////////////////////////////////////////////////// | 39 // Scoper ////////////////////////////////////////////////////////////////////// |
| 40 | 40 |
| 41 namespace ui { | 41 namespace ui { |
| 42 | 42 |
| 43 // Use an instance of this class to call |-clearOwner| on the |tracking_area_| | 43 // Use an instance of this class to call |-clearOwner| on the |tracking_area_| |
| 44 // when this goes out of scope. | 44 // when this goes out of scope. |
| 45 class UI_EXPORT ScopedCrTrackingArea { | 45 class UI_BASE_EXPORT ScopedCrTrackingArea { |
| 46 public: | 46 public: |
| 47 // Takes ownership of |tracking_area| without retaining it. | 47 // Takes ownership of |tracking_area| without retaining it. |
| 48 explicit ScopedCrTrackingArea(CrTrackingArea* tracking_area = nil); | 48 explicit ScopedCrTrackingArea(CrTrackingArea* tracking_area = nil); |
| 49 ~ScopedCrTrackingArea(); | 49 ~ScopedCrTrackingArea(); |
| 50 | 50 |
| 51 // This will call |scoped_nsobject<>::reset()| to take ownership of the new | 51 // This will call |scoped_nsobject<>::reset()| to take ownership of the new |
| 52 // tracking area. Note that -clearOwner is NOT called on the existing | 52 // tracking area. Note that -clearOwner is NOT called on the existing |
| 53 // tracking area. | 53 // tracking area. |
| 54 void reset(CrTrackingArea* tracking_area = nil); | 54 void reset(CrTrackingArea* tracking_area = nil); |
| 55 | 55 |
| 56 CrTrackingArea* get() const; | 56 CrTrackingArea* get() const; |
| 57 | 57 |
| 58 private: | 58 private: |
| 59 base::scoped_nsobject<CrTrackingArea> tracking_area_; | 59 base::scoped_nsobject<CrTrackingArea> tracking_area_; |
| 60 DISALLOW_COPY_AND_ASSIGN(ScopedCrTrackingArea); | 60 DISALLOW_COPY_AND_ASSIGN(ScopedCrTrackingArea); |
| 61 }; | 61 }; |
| 62 | 62 |
| 63 } // namespace ui | 63 } // namespace ui |
| 64 | 64 |
| 65 #endif // UI_BASE_COCOA_TRACKING_AREA_H_ | 65 #endif // UI_BASE_COCOA_TRACKING_AREA_H_ |
| OLD | NEW |