Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(79)

Side by Side Diff: ui/base/cocoa/tracking_area.h

Issue 12763002: Move CrTrackingArea from chrome/browser/ui/cocoa to ui/base/cocoa. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: test in namespace Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chrome/chrome_tests_unit.gypi ('k') | ui/base/cocoa/tracking_area.mm » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 CHROME_BROWSER_UI_COCOA_TRACKING_AREA_H_ 5 #ifndef UI_BASE_COCOA_TRACKING_AREA_H_
6 #define CHROME_BROWSER_UI_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/memory/scoped_nsobject.h" 10 #include "base/memory/scoped_nsobject.h"
11 #include "ui/base/ui_export.h"
11 12
12 @class CrTrackingAreaOwnerProxy; 13 @class CrTrackingAreaOwnerProxy;
13 14
14 // 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
15 // messaging to the |owner| at a specific point in time. 16 // messaging to the |owner| at a specific point in time.
16 @interface CrTrackingArea : NSTrackingArea { 17 @interface CrTrackingArea : NSTrackingArea {
17 @private 18 @private
18 scoped_nsobject<CrTrackingAreaOwnerProxy> ownerProxy_; 19 scoped_nsobject<CrTrackingAreaOwnerProxy> ownerProxy_;
19 } 20 }
20 21
21 // Designated initializer. Forwards all arguments to the superclass, but wraps 22 // Designated initializer. Forwards all arguments to the superclass, but wraps
22 // |owner| in a proxy object. 23 // |owner| in a proxy object.
23 - (id)initWithRect:(NSRect)rect 24 - (id)initWithRect:(NSRect)rect
24 options:(NSTrackingAreaOptions)options 25 options:(NSTrackingAreaOptions)options
25 owner:(id)owner 26 owner:(id)owner
26 userInfo:(NSDictionary*)userInfo; 27 userInfo:(NSDictionary*)userInfo;
27 28
28 // Prevents any future messages from being delivered to the |owner|. 29 // Prevents any future messages from being delivered to the |owner|.
29 - (void)clearOwner; 30 - (void)clearOwner;
30 31
31 // Watches |window| for its NSWindowWillCloseNotification and calls 32 // Watches |window| for its NSWindowWillCloseNotification and calls
32 // |-clearOwner| when the notification is observed. 33 // |-clearOwner| when the notification is observed.
33 - (void)clearOwnerWhenWindowWillClose:(NSWindow*)window; 34 - (void)clearOwnerWhenWindowWillClose:(NSWindow*)window;
34 35
35 @end 36 @end
36 37
37 // Scoper ////////////////////////////////////////////////////////////////////// 38 // Scoper //////////////////////////////////////////////////////////////////////
38 39
40 namespace ui {
41
39 // Use an instance of this class to call |-clearOwner| on the |tracking_area_| 42 // Use an instance of this class to call |-clearOwner| on the |tracking_area_|
40 // when this goes out of scope. 43 // when this goes out of scope.
41 class ScopedCrTrackingArea { 44 class UI_EXPORT ScopedCrTrackingArea {
42 public: 45 public:
43 // Takes ownership of |tracking_area| without retaining it. 46 // Takes ownership of |tracking_area| without retaining it.
44 explicit ScopedCrTrackingArea(CrTrackingArea* tracking_area = nil); 47 explicit ScopedCrTrackingArea(CrTrackingArea* tracking_area = nil);
45 ~ScopedCrTrackingArea(); 48 ~ScopedCrTrackingArea();
46 49
47 // This will call |scoped_nsobject<>::reset()| to take ownership of the new 50 // This will call |scoped_nsobject<>::reset()| to take ownership of the new
48 // tracking area. Note that -clearOwner is NOT called on the existing 51 // tracking area. Note that -clearOwner is NOT called on the existing
49 // tracking area. 52 // tracking area.
50 void reset(CrTrackingArea* tracking_area = nil); 53 void reset(CrTrackingArea* tracking_area = nil);
51 54
52 CrTrackingArea* get() const; 55 CrTrackingArea* get() const;
53 56
54 private: 57 private:
55 scoped_nsobject<CrTrackingArea> tracking_area_; 58 scoped_nsobject<CrTrackingArea> tracking_area_;
56 DISALLOW_COPY_AND_ASSIGN(ScopedCrTrackingArea); 59 DISALLOW_COPY_AND_ASSIGN(ScopedCrTrackingArea);
57 }; 60 };
58 61
59 #endif // CHROME_BROWSER_UI_COCOA_TRACKING_AREA_H_ 62 } // namespace ui
63
64 #endif // UI_BASE_COCOA_TRACKING_AREA_H_
OLDNEW
« no previous file with comments | « chrome/chrome_tests_unit.gypi ('k') | ui/base/cocoa/tracking_area.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698