OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/ui/ash/chrome_keyboard_ui.h" | 5 #include "chrome/browser/ui/ash/chrome_keyboard_ui.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "ash/root_window_controller.h" | 9 #include "ash/root_window_controller.h" |
10 #include "ash/shell.h" | 10 #include "ash/shell.h" |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 | 81 |
82 // KeyboardControllerObserver overrides: | 82 // KeyboardControllerObserver overrides: |
83 void OnKeyboardBoundsChanging(const gfx::Rect& bounds) override { | 83 void OnKeyboardBoundsChanging(const gfx::Rect& bounds) override { |
84 extensions::EventRouter* router = extensions::EventRouter::Get(context_); | 84 extensions::EventRouter* router = extensions::EventRouter::Get(context_); |
85 | 85 |
86 if (!router->HasEventListener( | 86 if (!router->HasEventListener( |
87 virtual_keyboard_private::OnBoundsChanged::kEventName)) { | 87 virtual_keyboard_private::OnBoundsChanged::kEventName)) { |
88 return; | 88 return; |
89 } | 89 } |
90 | 90 |
91 scoped_ptr<base::ListValue> event_args(new base::ListValue()); | 91 std::unique_ptr<base::ListValue> event_args(new base::ListValue()); |
92 scoped_ptr<base::DictionaryValue> new_bounds(new base::DictionaryValue()); | 92 std::unique_ptr<base::DictionaryValue> new_bounds( |
| 93 new base::DictionaryValue()); |
93 new_bounds->SetInteger("left", bounds.x()); | 94 new_bounds->SetInteger("left", bounds.x()); |
94 new_bounds->SetInteger("top", bounds.y()); | 95 new_bounds->SetInteger("top", bounds.y()); |
95 new_bounds->SetInteger("width", bounds.width()); | 96 new_bounds->SetInteger("width", bounds.width()); |
96 new_bounds->SetInteger("height", bounds.height()); | 97 new_bounds->SetInteger("height", bounds.height()); |
97 event_args->Append(new_bounds.release()); | 98 event_args->Append(new_bounds.release()); |
98 | 99 |
99 scoped_ptr<extensions::Event> event(new extensions::Event( | 100 std::unique_ptr<extensions::Event> event(new extensions::Event( |
100 extensions::events::VIRTUAL_KEYBOARD_PRIVATE_ON_BOUNDS_CHANGED, | 101 extensions::events::VIRTUAL_KEYBOARD_PRIVATE_ON_BOUNDS_CHANGED, |
101 virtual_keyboard_private::OnBoundsChanged::kEventName, | 102 virtual_keyboard_private::OnBoundsChanged::kEventName, |
102 std::move(event_args))); | 103 std::move(event_args))); |
103 event->restrict_to_browser_context = context_; | 104 event->restrict_to_browser_context = context_; |
104 router->BroadcastEvent(std::move(event)); | 105 router->BroadcastEvent(std::move(event)); |
105 } | 106 } |
106 | 107 |
107 private: | 108 private: |
108 content::BrowserContext* context_; | 109 content::BrowserContext* context_; |
109 | 110 |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
203 // TODO(bshe): Need to check the affected window's profile once multi-profile | 204 // TODO(bshe): Need to check the affected window's profile once multi-profile |
204 // is supported. | 205 // is supported. |
205 extensions::EventRouter* router = | 206 extensions::EventRouter* router = |
206 extensions::EventRouter::Get(browser_context()); | 207 extensions::EventRouter::Get(browser_context()); |
207 | 208 |
208 if (!router->HasEventListener( | 209 if (!router->HasEventListener( |
209 virtual_keyboard_private::OnTextInputBoxFocused::kEventName)) { | 210 virtual_keyboard_private::OnTextInputBoxFocused::kEventName)) { |
210 return; | 211 return; |
211 } | 212 } |
212 | 213 |
213 scoped_ptr<base::ListValue> event_args(new base::ListValue()); | 214 std::unique_ptr<base::ListValue> event_args(new base::ListValue()); |
214 scoped_ptr<base::DictionaryValue> input_context(new base::DictionaryValue()); | 215 std::unique_ptr<base::DictionaryValue> input_context( |
| 216 new base::DictionaryValue()); |
215 input_context->SetString("type", | 217 input_context->SetString("type", |
216 virtual_keyboard_private::ToString( | 218 virtual_keyboard_private::ToString( |
217 TextInputTypeToGeneratedInputTypeEnum(type))); | 219 TextInputTypeToGeneratedInputTypeEnum(type))); |
218 event_args->Append(input_context.release()); | 220 event_args->Append(input_context.release()); |
219 | 221 |
220 scoped_ptr<extensions::Event> event(new extensions::Event( | 222 std::unique_ptr<extensions::Event> event(new extensions::Event( |
221 extensions::events::VIRTUAL_KEYBOARD_PRIVATE_ON_TEXT_INPUT_BOX_FOCUSED, | 223 extensions::events::VIRTUAL_KEYBOARD_PRIVATE_ON_TEXT_INPUT_BOX_FOCUSED, |
222 virtual_keyboard_private::OnTextInputBoxFocused::kEventName, | 224 virtual_keyboard_private::OnTextInputBoxFocused::kEventName, |
223 std::move(event_args))); | 225 std::move(event_args))); |
224 event->restrict_to_browser_context = browser_context(); | 226 event->restrict_to_browser_context = browser_context(); |
225 router->DispatchEventToExtension(kVirtualKeyboardExtensionID, | 227 router->DispatchEventToExtension(kVirtualKeyboardExtensionID, |
226 std::move(event)); | 228 std::move(event)); |
227 } | 229 } |
OLD | NEW |