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

Side by Side Diff: ui/views/cocoa/cocoa_mouse_capture.h

Issue 1868363002: Replace scoped_ptr with std::unique_ptr in //ui (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@scopedptrcc
Patch Set: scopedptrui: rebase-make_scoped_ptr Created 4 years, 8 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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_VIEWS_COCOA_COCOA_MOUSE_CAPTURE_H_ 5 #ifndef UI_VIEWS_COCOA_COCOA_MOUSE_CAPTURE_H_
6 #define UI_VIEWS_COCOA_COCOA_MOUSE_CAPTURE_H_ 6 #define UI_VIEWS_COCOA_COCOA_MOUSE_CAPTURE_H_
7 7
8 #include <memory>
9
8 #include "base/macros.h" 10 #include "base/macros.h"
9 #include "base/memory/scoped_ptr.h"
10 #include "ui/views/views_export.h" 11 #include "ui/views/views_export.h"
11 12
12 namespace views { 13 namespace views {
13 14
14 class CocoaMouseCaptureDelegate; 15 class CocoaMouseCaptureDelegate;
15 16
16 // Basic mouse capture to simulate ::SetCapture() from Windows. This is used to 17 // Basic mouse capture to simulate ::SetCapture() from Windows. This is used to
17 // support menu widgets (e.g. on Combo boxes). Clicking anywhere other than the 18 // support menu widgets (e.g. on Combo boxes). Clicking anywhere other than the
18 // menu should dismiss the menu and "swallow" the mouse event. All events are 19 // menu should dismiss the menu and "swallow" the mouse event. All events are
19 // forwarded, but only events to the same application are "swallowed", which is 20 // forwarded, but only events to the same application are "swallowed", which is
20 // consistent with how native NSMenus behave. 21 // consistent with how native NSMenus behave.
21 class VIEWS_EXPORT CocoaMouseCapture { 22 class VIEWS_EXPORT CocoaMouseCapture {
22 public: 23 public:
23 explicit CocoaMouseCapture(CocoaMouseCaptureDelegate* delegate); 24 explicit CocoaMouseCapture(CocoaMouseCaptureDelegate* delegate);
24 ~CocoaMouseCapture(); 25 ~CocoaMouseCapture();
25 26
26 // True if the event tap is active (i.e. not stolen by a later instance). 27 // True if the event tap is active (i.e. not stolen by a later instance).
27 bool IsActive() const { return !!active_handle_; } 28 bool IsActive() const { return !!active_handle_; }
28 29
29 private: 30 private:
30 class ActiveEventTap; 31 class ActiveEventTap;
31 32
32 // Deactivates the event tap if still active. 33 // Deactivates the event tap if still active.
33 void OnOtherClientGotCapture(); 34 void OnOtherClientGotCapture();
34 35
35 CocoaMouseCaptureDelegate* delegate_; // Weak. Owns this. 36 CocoaMouseCaptureDelegate* delegate_; // Weak. Owns this.
36 37
37 // The active event tap for this capture. Owned by this, but can be cleared 38 // The active event tap for this capture. Owned by this, but can be cleared
38 // out early if another instance of CocoaMouseCapture is created. 39 // out early if another instance of CocoaMouseCapture is created.
39 scoped_ptr<ActiveEventTap> active_handle_; 40 std::unique_ptr<ActiveEventTap> active_handle_;
40 41
41 DISALLOW_COPY_AND_ASSIGN(CocoaMouseCapture); 42 DISALLOW_COPY_AND_ASSIGN(CocoaMouseCapture);
42 }; 43 };
43 44
44 } // namespace views 45 } // namespace views
45 46
46 #endif // UI_VIEWS_COCOA_COCOA_MOUSE_CAPTURE_H_ 47 #endif // UI_VIEWS_COCOA_COCOA_MOUSE_CAPTURE_H_
OLDNEW
« no previous file with comments | « ui/views/cocoa/bridged_native_widget_unittest.mm ('k') | ui/views/cocoa/cocoa_mouse_capture_unittest.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698