| Index: chrome/browser/ui/ash/ash_keyboard_controller_proxy.cc
|
| diff --git a/chrome/browser/ui/ash/ash_keyboard_controller_proxy.cc b/chrome/browser/ui/ash/ash_keyboard_controller_proxy.cc
|
| index d999706b58b87e73bf78a5f61c3080e8d785a4ec..06340c4386816e1eb654d56cbe3052d1313d4f31 100644
|
| --- a/chrome/browser/ui/ash/ash_keyboard_controller_proxy.cc
|
| +++ b/chrome/browser/ui/ash/ash_keyboard_controller_proxy.cc
|
| @@ -26,6 +26,7 @@
|
| #include "ui/aura/window_event_dispatcher.h"
|
| #include "ui/compositor/scoped_layer_animation_settings.h"
|
| #include "ui/keyboard/keyboard_controller.h"
|
| +#include "ui/keyboard/keyboard_controller_observer.h"
|
|
|
| namespace virtual_keyboard_private =
|
| extensions::core_api::virtual_keyboard_private;
|
| @@ -71,12 +72,52 @@ TextInputTypeToGeneratedInputTypeEnum(ui::TextInputType type) {
|
|
|
| } // namespace
|
|
|
| +class AshKeyboardControllerProxy::AshKeyboardControllerObserver :
|
| + public keyboard::KeyboardControllerObserver {
|
| + public:
|
| + explicit AshKeyboardControllerObserver(content::BrowserContext* context)
|
| + : context_(context) {
|
| + }
|
| + ~AshKeyboardControllerObserver() override {}
|
| +
|
| + // KeyboardControllerObserver overrides:
|
| + void OnKeyboardBoundsChanging(const gfx::Rect& bounds) override {
|
| + extensions::EventRouter* router =
|
| + extensions::EventRouter::Get(context_);
|
| +
|
| + if (!router->HasEventListener(
|
| + virtual_keyboard_private::OnBoundsChanged::kEventName)) {
|
| + return;
|
| + }
|
| +
|
| + scoped_ptr<base::ListValue> event_args(new base::ListValue());
|
| + scoped_ptr<base::DictionaryValue> new_bounds(new base::DictionaryValue());
|
| + new_bounds->SetInteger("left", bounds.x());
|
| + new_bounds->SetInteger("top", bounds.y());
|
| + new_bounds->SetInteger("width", bounds.width());
|
| + new_bounds->SetInteger("height", bounds.height());
|
| + event_args->Append(new_bounds.release());
|
| +
|
| + scoped_ptr<extensions::Event> event(new extensions::Event(
|
| + virtual_keyboard_private::OnBoundsChanged::kEventName,
|
| + event_args.Pass()));
|
| + event->restrict_to_browser_context = context_;
|
| + router->BroadcastEvent(event.Pass());
|
| + }
|
| +
|
| + private:
|
| + content::BrowserContext* context_;
|
| + DISALLOW_COPY_AND_ASSIGN(AshKeyboardControllerObserver);
|
| +};
|
| +
|
| AshKeyboardControllerProxy::AshKeyboardControllerProxy(
|
| content::BrowserContext* context)
|
| : keyboard::KeyboardControllerProxy(context) {
|
| }
|
|
|
| -AshKeyboardControllerProxy::~AshKeyboardControllerProxy() {}
|
| +AshKeyboardControllerProxy::~AshKeyboardControllerProxy() {
|
| + keyboard_controller()->RemoveObserver(observer_.get());
|
| +}
|
|
|
| void AshKeyboardControllerProxy::OnRequest(
|
| const ExtensionHostMsg_Request_Params& params) {
|
| @@ -123,6 +164,13 @@ extensions::WindowController*
|
| return NULL;
|
| }
|
|
|
| +void AshKeyboardControllerProxy::SetController(
|
| + keyboard::KeyboardController* controller) {
|
| + KeyboardControllerProxy::SetController(controller);
|
| + observer_.reset(new AshKeyboardControllerObserver(browser_context()));
|
| + keyboard_controller()->AddObserver(observer_.get());
|
| +}
|
| +
|
| content::WebContents*
|
| AshKeyboardControllerProxy::GetAssociatedWebContents() const {
|
| return web_contents();
|
|
|