OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "chrome/browser/ui/ash/ash_keyboard_controller_proxy.h" |
| 6 |
| 7 #include "chrome/browser/extensions/extension_function_dispatcher.h" |
| 8 #include "chrome/browser/profiles/profile.h" |
| 9 #include "chrome/browser/profiles/profile_manager.h" |
| 10 #include "chrome/common/extensions/extension_messages.h" |
| 11 #include "content/public/browser/site_instance.h" |
| 12 #include "content/public/browser/web_contents.h" |
| 13 #include "content/public/browser/web_contents_view.h" |
| 14 #include "ipc/ipc_message_macros.h" |
| 15 #include "ui/aura/window.h" |
| 16 #include "ui/keyboard/keyboard_controller.h" |
| 17 |
| 18 AshKeyboardControllerProxy::AshKeyboardControllerProxy() {} |
| 19 |
| 20 AshKeyboardControllerProxy::~AshKeyboardControllerProxy() {} |
| 21 |
| 22 aura::Window* AshKeyboardControllerProxy::GetKeyboardWindow() { |
| 23 if (!web_contents_) { |
| 24 Profile* profile = ProfileManager::GetDefaultProfile(); |
| 25 |
| 26 extension_function_dispatcher_.reset( |
| 27 new ExtensionFunctionDispatcher(profile, this)); |
| 28 |
| 29 GURL keyboard_url("chrome://keyboard/"); |
| 30 web_contents_.reset(content::WebContents::Create( |
| 31 content::WebContents::CreateParams( |
| 32 profile, |
| 33 content::SiteInstance::CreateForURL(profile, keyboard_url)))); |
| 34 |
| 35 content::WebContentsObserver::Observe(web_contents_.get()); |
| 36 |
| 37 web_contents_->GetController().LoadURL( |
| 38 keyboard_url, |
| 39 content::Referrer(), |
| 40 content::PAGE_TRANSITION_AUTO_TOPLEVEL, |
| 41 std::string()); |
| 42 } |
| 43 return web_contents_->GetView()->GetNativeView(); |
| 44 } |
| 45 |
| 46 extensions::WindowController* |
| 47 AshKeyboardControllerProxy::GetExtensionWindowController() const { |
| 48 // The keyboard doesn't have a window controller. |
| 49 return NULL; |
| 50 } |
| 51 |
| 52 content::WebContents* |
| 53 AshKeyboardControllerProxy::GetAssociatedWebContents() const { |
| 54 return web_contents_.get(); |
| 55 } |
| 56 |
| 57 void AshKeyboardControllerProxy::OnRequest( |
| 58 const ExtensionHostMsg_Request_Params& params) { |
| 59 extension_function_dispatcher_->Dispatch( |
| 60 params, web_contents_->GetRenderViewHost()); |
| 61 } |
| 62 |
| 63 bool AshKeyboardControllerProxy::OnMessageReceived( |
| 64 const IPC::Message& message) { |
| 65 bool handled = true; |
| 66 IPC_BEGIN_MESSAGE_MAP(AshKeyboardControllerProxy, message) |
| 67 IPC_MESSAGE_HANDLER(ExtensionHostMsg_Request, OnRequest) |
| 68 IPC_MESSAGE_UNHANDLED(handled = false) |
| 69 IPC_END_MESSAGE_MAP() |
| 70 return handled; |
| 71 } |
OLD | NEW |