| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 #include "chrome/browser/chromeos/accessibility/spoken_feedback_event_rewriter.h
" | 5 #include "chrome/browser/chromeos/accessibility/spoken_feedback_event_rewriter.h
" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "ash/shell.h" | 10 #include "ash/shell.h" |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 108 } | 108 } |
| 109 | 109 |
| 110 SpokenFeedbackEventRewriter::SpokenFeedbackEventRewriter() { | 110 SpokenFeedbackEventRewriter::SpokenFeedbackEventRewriter() { |
| 111 delegate_.reset(new SpokenFeedbackEventRewriterDelegate()); | 111 delegate_.reset(new SpokenFeedbackEventRewriterDelegate()); |
| 112 } | 112 } |
| 113 | 113 |
| 114 SpokenFeedbackEventRewriter::~SpokenFeedbackEventRewriter() { | 114 SpokenFeedbackEventRewriter::~SpokenFeedbackEventRewriter() { |
| 115 } | 115 } |
| 116 | 116 |
| 117 void SpokenFeedbackEventRewriter::SetDelegateForTest( | 117 void SpokenFeedbackEventRewriter::SetDelegateForTest( |
| 118 scoped_ptr<SpokenFeedbackEventRewriterDelegate> delegate) { | 118 std::unique_ptr<SpokenFeedbackEventRewriterDelegate> delegate) { |
| 119 delegate_ = std::move(delegate); | 119 delegate_ = std::move(delegate); |
| 120 } | 120 } |
| 121 | 121 |
| 122 ui::EventRewriteStatus SpokenFeedbackEventRewriter::RewriteEvent( | 122 ui::EventRewriteStatus SpokenFeedbackEventRewriter::RewriteEvent( |
| 123 const ui::Event& event, | 123 const ui::Event& event, |
| 124 scoped_ptr<ui::Event>* new_event) { | 124 std::unique_ptr<ui::Event>* new_event) { |
| 125 if (!delegate_->IsSpokenFeedbackEnabled()) | 125 if (!delegate_->IsSpokenFeedbackEnabled()) |
| 126 return ui::EVENT_REWRITE_CONTINUE; | 126 return ui::EVENT_REWRITE_CONTINUE; |
| 127 | 127 |
| 128 if ((event.type() != ui::ET_KEY_PRESSED && | 128 if ((event.type() != ui::ET_KEY_PRESSED && |
| 129 event.type() != ui::ET_KEY_RELEASED)) | 129 event.type() != ui::ET_KEY_RELEASED)) |
| 130 return ui::EVENT_REWRITE_CONTINUE; | 130 return ui::EVENT_REWRITE_CONTINUE; |
| 131 | 131 |
| 132 std::string extension_id = | 132 std::string extension_id = |
| 133 chromeos::AccessibilityManager::Get()->keyboard_listener_extension_id(); | 133 chromeos::AccessibilityManager::Get()->keyboard_listener_extension_id(); |
| 134 if (extension_id.empty()) | 134 if (extension_id.empty()) |
| 135 return ui::EVENT_REWRITE_CONTINUE; | 135 return ui::EVENT_REWRITE_CONTINUE; |
| 136 | 136 |
| 137 bool capture = | 137 bool capture = |
| 138 chromeos::AccessibilityManager::Get()->keyboard_listener_capture(); | 138 chromeos::AccessibilityManager::Get()->keyboard_listener_capture(); |
| 139 const ui::KeyEvent key_event = static_cast<const ui::KeyEvent&>(event); | 139 const ui::KeyEvent key_event = static_cast<const ui::KeyEvent&>(event); |
| 140 if (delegate_->DispatchKeyEventToChromeVox(key_event, capture)) | 140 if (delegate_->DispatchKeyEventToChromeVox(key_event, capture)) |
| 141 return ui::EVENT_REWRITE_DISCARD; | 141 return ui::EVENT_REWRITE_DISCARD; |
| 142 return ui::EVENT_REWRITE_CONTINUE; | 142 return ui::EVENT_REWRITE_CONTINUE; |
| 143 } | 143 } |
| 144 | 144 |
| 145 ui::EventRewriteStatus SpokenFeedbackEventRewriter::NextDispatchEvent( | 145 ui::EventRewriteStatus SpokenFeedbackEventRewriter::NextDispatchEvent( |
| 146 const ui::Event& last_event, | 146 const ui::Event& last_event, |
| 147 scoped_ptr<ui::Event>* new_event) { | 147 std::unique_ptr<ui::Event>* new_event) { |
| 148 return ui::EVENT_REWRITE_CONTINUE; | 148 return ui::EVENT_REWRITE_CONTINUE; |
| 149 } | 149 } |
| OLD | NEW |