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

Unified Diff: ui/base/accelerators/accelerator.h

Issue 2751323002: Converts ui::Accelerator::type to an enum (Closed)
Patch Set: remove dcheck Created 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/ui/ash/chrome_screenshot_grabber_unittest.cc ('k') | ui/base/accelerators/accelerator.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/base/accelerators/accelerator.h
diff --git a/ui/base/accelerators/accelerator.h b/ui/base/accelerators/accelerator.h
index 7941f3385955e045bb87c16c84bc764f2f06b5a8..4363198a52fc0211e4d346fba1674526b8468f9b 100644
--- a/ui/base/accelerators/accelerator.h
+++ b/ui/base/accelerators/accelerator.h
@@ -35,9 +35,14 @@ class PlatformAccelerator;
// repeat flag in its comparison.
class UI_BASE_EXPORT Accelerator {
public:
+ enum class KeyState {
msw 2017/03/16 16:57:22 very optional nit: If this weren't an enum class,
sky 2017/03/16 17:06:40 If I went down that route I would use a more verbo
+ PRESSED,
+ RELEASED,
+ };
+
Accelerator();
// NOTE: this constructor strips out non key related flags.
- Accelerator(ui::KeyboardCode keycode, int modifiers);
+ Accelerator(KeyboardCode key_code, int modifiers);
explicit Accelerator(const KeyEvent& key_event);
Accelerator(const Accelerator& accelerator);
~Accelerator();
@@ -56,12 +61,11 @@ class UI_BASE_EXPORT Accelerator {
bool operator !=(const Accelerator& rhs) const;
- ui::KeyboardCode key_code() const { return key_code_; }
+ KeyboardCode key_code() const { return key_code_; }
- // Sets the event type if the accelerator should be processed on an event
- // other than ui::ET_KEY_PRESSED.
- void set_type(ui::EventType type) { type_ = type; }
- ui::EventType type() const { return type_; }
+ // Sets the key state that triggers the accelerator. Default is PRESSED.
+ void set_key_state(KeyState state) { key_state_ = state; }
+ KeyState key_state() const { return key_state_; }
int modifiers() const { return modifiers_; }
@@ -87,8 +91,7 @@ class UI_BASE_EXPORT Accelerator {
// The keycode (VK_...).
KeyboardCode key_code_;
- // The event type (usually ui::ET_KEY_PRESSED).
- EventType type_;
+ KeyState key_state_;
// The state of the Shift/Ctrl/Alt keys. This corresponds to Event::flags().
int modifiers_;
@@ -120,9 +123,8 @@ class AcceleratorProvider {
public:
// Gets the accelerator for the specified command id. Returns true if the
// command id has a valid accelerator, false otherwise.
- virtual bool GetAcceleratorForCommandId(
- int command_id,
- ui::Accelerator* accelerator) const = 0;
+ virtual bool GetAcceleratorForCommandId(int command_id,
+ Accelerator* accelerator) const = 0;
protected:
virtual ~AcceleratorProvider() {}
« no previous file with comments | « chrome/browser/ui/ash/chrome_screenshot_grabber_unittest.cc ('k') | ui/base/accelerators/accelerator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698