| 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/public/cpp/shell_window_ids.h" | 9 #include "ash/public/cpp/shell_window_ids.h" |
| 10 #include "ash/root_window_controller.h" | 10 #include "ash/root_window_controller.h" |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 91 | 91 |
| 92 std::unique_ptr<base::ListValue> event_args(new base::ListValue()); | 92 std::unique_ptr<base::ListValue> event_args(new base::ListValue()); |
| 93 std::unique_ptr<base::DictionaryValue> new_bounds( | 93 std::unique_ptr<base::DictionaryValue> new_bounds( |
| 94 new base::DictionaryValue()); | 94 new base::DictionaryValue()); |
| 95 new_bounds->SetInteger("left", bounds.x()); | 95 new_bounds->SetInteger("left", bounds.x()); |
| 96 new_bounds->SetInteger("top", bounds.y()); | 96 new_bounds->SetInteger("top", bounds.y()); |
| 97 new_bounds->SetInteger("width", bounds.width()); | 97 new_bounds->SetInteger("width", bounds.width()); |
| 98 new_bounds->SetInteger("height", bounds.height()); | 98 new_bounds->SetInteger("height", bounds.height()); |
| 99 event_args->Append(std::move(new_bounds)); | 99 event_args->Append(std::move(new_bounds)); |
| 100 | 100 |
| 101 std::unique_ptr<extensions::Event> event(new extensions::Event( | 101 auto event = base::MakeUnique<extensions::Event>( |
| 102 extensions::events::VIRTUAL_KEYBOARD_PRIVATE_ON_BOUNDS_CHANGED, | 102 extensions::events::VIRTUAL_KEYBOARD_PRIVATE_ON_BOUNDS_CHANGED, |
| 103 virtual_keyboard_private::OnBoundsChanged::kEventName, | 103 virtual_keyboard_private::OnBoundsChanged::kEventName, |
| 104 std::move(event_args))); | 104 std::move(event_args), context_); |
| 105 event->restrict_to_browser_context = context_; | |
| 106 router->BroadcastEvent(std::move(event)); | 105 router->BroadcastEvent(std::move(event)); |
| 107 } | 106 } |
| 108 | 107 |
| 109 void OnKeyboardClosed() override { | 108 void OnKeyboardClosed() override { |
| 110 extensions::EventRouter* router = extensions::EventRouter::Get(context_); | 109 extensions::EventRouter* router = extensions::EventRouter::Get(context_); |
| 111 | 110 |
| 112 if (!router->HasEventListener( | 111 if (!router->HasEventListener( |
| 113 virtual_keyboard_private::OnKeyboardClosed::kEventName)) { | 112 virtual_keyboard_private::OnKeyboardClosed::kEventName)) { |
| 114 return; | 113 return; |
| 115 } | 114 } |
| 116 | 115 |
| 117 std::unique_ptr<extensions::Event> event(new extensions::Event( | 116 auto event = base::MakeUnique<extensions::Event>( |
| 118 extensions::events::VIRTUAL_KEYBOARD_PRIVATE_ON_KEYBOARD_CLOSED, | 117 extensions::events::VIRTUAL_KEYBOARD_PRIVATE_ON_KEYBOARD_CLOSED, |
| 119 virtual_keyboard_private::OnKeyboardClosed::kEventName, | 118 virtual_keyboard_private::OnKeyboardClosed::kEventName, |
| 120 base::WrapUnique(new base::ListValue()))); | 119 base::MakeUnique<base::ListValue>(), context_); |
| 121 event->restrict_to_browser_context = context_; | |
| 122 router->BroadcastEvent(std::move(event)); | 120 router->BroadcastEvent(std::move(event)); |
| 123 } | 121 } |
| 124 | 122 |
| 125 private: | 123 private: |
| 126 content::BrowserContext* context_; | 124 content::BrowserContext* context_; |
| 127 | 125 |
| 128 DISALLOW_COPY_AND_ASSIGN(AshKeyboardControllerObserver); | 126 DISALLOW_COPY_AND_ASSIGN(AshKeyboardControllerObserver); |
| 129 }; | 127 }; |
| 130 | 128 |
| 131 } // namespace | 129 } // namespace |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 224 } | 222 } |
| 225 | 223 |
| 226 std::unique_ptr<base::ListValue> event_args(new base::ListValue()); | 224 std::unique_ptr<base::ListValue> event_args(new base::ListValue()); |
| 227 std::unique_ptr<base::DictionaryValue> input_context( | 225 std::unique_ptr<base::DictionaryValue> input_context( |
| 228 new base::DictionaryValue()); | 226 new base::DictionaryValue()); |
| 229 input_context->SetString("type", | 227 input_context->SetString("type", |
| 230 virtual_keyboard_private::ToString( | 228 virtual_keyboard_private::ToString( |
| 231 TextInputTypeToGeneratedInputTypeEnum(type))); | 229 TextInputTypeToGeneratedInputTypeEnum(type))); |
| 232 event_args->Append(std::move(input_context)); | 230 event_args->Append(std::move(input_context)); |
| 233 | 231 |
| 234 std::unique_ptr<extensions::Event> event(new extensions::Event( | 232 auto event = base::MakeUnique<extensions::Event>( |
| 235 extensions::events::VIRTUAL_KEYBOARD_PRIVATE_ON_TEXT_INPUT_BOX_FOCUSED, | 233 extensions::events::VIRTUAL_KEYBOARD_PRIVATE_ON_TEXT_INPUT_BOX_FOCUSED, |
| 236 virtual_keyboard_private::OnTextInputBoxFocused::kEventName, | 234 virtual_keyboard_private::OnTextInputBoxFocused::kEventName, |
| 237 std::move(event_args))); | 235 std::move(event_args), browser_context()); |
| 238 event->restrict_to_browser_context = browser_context(); | |
| 239 router->DispatchEventToExtension(kVirtualKeyboardExtensionID, | 236 router->DispatchEventToExtension(kVirtualKeyboardExtensionID, |
| 240 std::move(event)); | 237 std::move(event)); |
| 241 } | 238 } |
| OLD | NEW |