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

Side by Side Diff: ui/base/accelerators/accelerator.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
« no previous file with comments | « ui/aura/window_unittest.cc ('k') | ui/base/accelerators/platform_accelerator.h » ('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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 // This class describe a keyboard accelerator (or keyboard shortcut). 5 // This class describe a keyboard accelerator (or keyboard shortcut).
6 // Keyboard accelerators are registered with the FocusManager. 6 // Keyboard accelerators are registered with the FocusManager.
7 // It has a copy constructor and assignment operator so that it can be copied. 7 // It has a copy constructor and assignment operator so that it can be copied.
8 // It also defines the < operator so that it can be used as a key in a std::map. 8 // It also defines the < operator so that it can be used as a key in a std::map.
9 // 9 //
10 10
11 #ifndef UI_BASE_ACCELERATORS_ACCELERATOR_H_ 11 #ifndef UI_BASE_ACCELERATORS_ACCELERATOR_H_
12 #define UI_BASE_ACCELERATORS_ACCELERATOR_H_ 12 #define UI_BASE_ACCELERATORS_ACCELERATOR_H_
13 13
14 #include <memory>
14 #include <utility> 15 #include <utility>
15 16
16 #include "base/memory/scoped_ptr.h"
17 #include "base/strings/string16.h" 17 #include "base/strings/string16.h"
18 #include "ui/base/accelerators/platform_accelerator.h" 18 #include "ui/base/accelerators/platform_accelerator.h"
19 #include "ui/base/ui_base_export.h" 19 #include "ui/base/ui_base_export.h"
20 #include "ui/events/event_constants.h" 20 #include "ui/events/event_constants.h"
21 #include "ui/events/keycodes/keyboard_codes.h" 21 #include "ui/events/keycodes/keyboard_codes.h"
22 22
23 namespace ui { 23 namespace ui {
24 24
25 class KeyEvent; 25 class KeyEvent;
26 class PlatformAccelerator; 26 class PlatformAccelerator;
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 60
61 bool IsShiftDown() const; 61 bool IsShiftDown() const;
62 bool IsCtrlDown() const; 62 bool IsCtrlDown() const;
63 bool IsAltDown() const; 63 bool IsAltDown() const;
64 bool IsCmdDown() const; 64 bool IsCmdDown() const;
65 bool IsRepeat() const; 65 bool IsRepeat() const;
66 66
67 // Returns a string with the localized shortcut if any. 67 // Returns a string with the localized shortcut if any.
68 base::string16 GetShortcutText() const; 68 base::string16 GetShortcutText() const;
69 69
70 void set_platform_accelerator(scoped_ptr<PlatformAccelerator> p) { 70 void set_platform_accelerator(std::unique_ptr<PlatformAccelerator> p) {
71 platform_accelerator_ = std::move(p); 71 platform_accelerator_ = std::move(p);
72 } 72 }
73 73
74 // This class keeps ownership of the returned object. 74 // This class keeps ownership of the returned object.
75 const PlatformAccelerator* platform_accelerator() const { 75 const PlatformAccelerator* platform_accelerator() const {
76 return platform_accelerator_.get(); 76 return platform_accelerator_.get();
77 } 77 }
78 78
79 void set_is_repeat(bool is_repeat) { is_repeat_ = is_repeat; } 79 void set_is_repeat(bool is_repeat) { is_repeat_ = is_repeat; }
80 80
81 protected: 81 protected:
82 // The keycode (VK_...). 82 // The keycode (VK_...).
83 KeyboardCode key_code_; 83 KeyboardCode key_code_;
84 84
85 // The event type (usually ui::ET_KEY_PRESSED). 85 // The event type (usually ui::ET_KEY_PRESSED).
86 EventType type_; 86 EventType type_;
87 87
88 // The state of the Shift/Ctrl/Alt keys. 88 // The state of the Shift/Ctrl/Alt keys.
89 int modifiers_; 89 int modifiers_;
90 90
91 // True if the accelerator is created for an auto repeated key event. 91 // True if the accelerator is created for an auto repeated key event.
92 bool is_repeat_; 92 bool is_repeat_;
93 93
94 // Stores platform specific data. May be NULL. 94 // Stores platform specific data. May be NULL.
95 scoped_ptr<PlatformAccelerator> platform_accelerator_; 95 std::unique_ptr<PlatformAccelerator> platform_accelerator_;
96 }; 96 };
97 97
98 // An interface that classes that want to register for keyboard accelerators 98 // An interface that classes that want to register for keyboard accelerators
99 // should implement. 99 // should implement.
100 class UI_BASE_EXPORT AcceleratorTarget { 100 class UI_BASE_EXPORT AcceleratorTarget {
101 public: 101 public:
102 // Should return true if the accelerator was processed. 102 // Should return true if the accelerator was processed.
103 virtual bool AcceleratorPressed(const Accelerator& accelerator) = 0; 103 virtual bool AcceleratorPressed(const Accelerator& accelerator) = 0;
104 104
105 // Should return true if the target can handle the accelerator events. The 105 // Should return true if the target can handle the accelerator events. The
(...skipping 15 matching lines...) Expand all
121 virtual bool GetAcceleratorForCommandId(int command_id, 121 virtual bool GetAcceleratorForCommandId(int command_id,
122 ui::Accelerator* accelerator) = 0; 122 ui::Accelerator* accelerator) = 0;
123 123
124 protected: 124 protected:
125 virtual ~AcceleratorProvider() {} 125 virtual ~AcceleratorProvider() {}
126 }; 126 };
127 127
128 } // namespace ui 128 } // namespace ui
129 129
130 #endif // UI_BASE_ACCELERATORS_ACCELERATOR_H_ 130 #endif // UI_BASE_ACCELERATORS_ACCELERATOR_H_
OLDNEW
« no previous file with comments | « ui/aura/window_unittest.cc ('k') | ui/base/accelerators/platform_accelerator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698