diff options
3 files changed, 65 insertions, 5 deletions
diff --git a/chrome/browser/ui/touch/frame/keyboard_container_view.cc b/chrome/browser/ui/touch/frame/keyboard_container_view.cc index 1ca23b4..d5123c1 100644 --- a/chrome/browser/ui/touch/frame/keyboard_container_view.cc +++ b/chrome/browser/ui/touch/frame/keyboard_container_view.cc @@ -5,6 +5,7 @@ #include "chrome/browser/ui/touch/frame/keyboard_container_view.h" #include "chrome/browser/profiles/profile.h" +#include "chrome/browser/ui/browser.h" #include "chrome/browser/ui/views/dom_view.h" #include "chrome/common/url_constants.h" #include "content/browser/site_instance.h" @@ -28,8 +29,12 @@ const char KeyboardContainerView::kViewClassName[] = /////////////////////////////////////////////////////////////////////////////// // KeyboardContainerView, public: -KeyboardContainerView::KeyboardContainerView(Profile* profile) - : dom_view_(new DOMView) { +KeyboardContainerView::KeyboardContainerView(Profile* profile, Browser* browser) + : dom_view_(new DOMView), + ALLOW_THIS_IN_INITIALIZER_LIST( + extension_function_dispatcher_(profile, this)), + ALLOW_THIS_IN_INITIALIZER_LIST(tab_contents_registrar_(this)), + browser_(browser) { GURL keyboard_url(chrome::kChromeUIKeyboardURL); dom_view_->Init(profile, SiteInstance::CreateSiteInstanceForURL(profile, keyboard_url)); @@ -37,6 +42,9 @@ KeyboardContainerView::KeyboardContainerView(Profile* profile) dom_view_->SetVisible(true); AddChildView(dom_view_); + + // We have Inited the dom_view. So we must have a tab contents. + tab_contents_registrar_.Observe(dom_view_->tab_contents()); } KeyboardContainerView::~KeyboardContainerView() { @@ -51,9 +59,36 @@ void KeyboardContainerView::Layout() { dom_view_->SetBounds(0, 0, width(), height()); } +Browser* KeyboardContainerView::GetBrowser() { + return browser_; +} + +gfx::NativeView KeyboardContainerView::GetNativeViewOfHost() { + return dom_view_->native_view(); +} + +TabContents* KeyboardContainerView::GetAssociatedTabContents() const { + return dom_view_->tab_contents(); +} + void KeyboardContainerView::ViewHierarchyChanged(bool is_add, View* parent, View* child) { if (is_add) MakeViewHierarchyUnfocusable(child); } + +bool KeyboardContainerView::OnMessageReceived(const IPC::Message& message) { + bool handled = true; + IPC_BEGIN_MESSAGE_MAP(KeyboardContainerView, message) + IPC_MESSAGE_HANDLER(ExtensionHostMsg_Request, OnRequest) + IPC_MESSAGE_UNHANDLED(handled = false) + IPC_END_MESSAGE_MAP() + return handled; +} + +void KeyboardContainerView::OnRequest( + const ExtensionHostMsg_Request_Params& request) { + extension_function_dispatcher_.Dispatch(request, + dom_view_->tab_contents()->render_view_host()); +} diff --git a/chrome/browser/ui/touch/frame/keyboard_container_view.h b/chrome/browser/ui/touch/frame/keyboard_container_view.h index b2c443a..7fa2b82 100644 --- a/chrome/browser/ui/touch/frame/keyboard_container_view.h +++ b/chrome/browser/ui/touch/frame/keyboard_container_view.h @@ -6,8 +6,17 @@ #define CHROME_BROWSER_UI_TOUCH_FRAME_KEYBOARD_CONTAINER_VIEW_H_ #pragma once +#include "chrome/browser/extensions/extension_function_dispatcher.h" +#include "chrome/common/extensions/extension_messages.h" +#include "content/browser/tab_contents/tab_contents.h" +#include "content/browser/tab_contents/tab_contents_observer.h" #include "views/view.h" +namespace IPC { +class Message; +} + +class Browser; class DOMView; class Profile; @@ -15,24 +24,39 @@ class Profile; // // This class is also responsible for managing focus of all views related to // the keyboard to prevent them from interfering with the ClientView. -class KeyboardContainerView : public views::View { +class KeyboardContainerView : public views::View, + public TabContentsObserver, + public ExtensionFunctionDispatcher::Delegate { public: // Internal class name. static const char kViewClassName[]; - explicit KeyboardContainerView(Profile* profile); + KeyboardContainerView(Profile* profile, Browser* browser); virtual ~KeyboardContainerView(); // Overridden from views::View virtual std::string GetClassName() const OVERRIDE; virtual void Layout(); + // ExtensionFunctionDispatcher::Delegate implementation + virtual Browser* GetBrowser(); + virtual gfx::NativeView GetNativeViewOfHost(); + virtual TabContents* GetAssociatedTabContents() const; + protected: // Overridden from views::View virtual void ViewHierarchyChanged(bool is_add, View* parent, View* child); + // Overridden from TabContentsObserver + virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; + private: + void OnRequest(const ExtensionHostMsg_Request_Params& params); + DOMView* dom_view_; + ExtensionFunctionDispatcher extension_function_dispatcher_; + TabContentsObserver::Registrar tab_contents_registrar_; + Browser* browser_; DISALLOW_COPY_AND_ASSIGN(KeyboardContainerView); }; diff --git a/chrome/browser/ui/touch/frame/touch_browser_frame_view.cc b/chrome/browser/ui/touch/frame/touch_browser_frame_view.cc index f685e37..5457b1a 100644 --- a/chrome/browser/ui/touch/frame/touch_browser_frame_view.cc +++ b/chrome/browser/ui/touch/frame/touch_browser_frame_view.cc @@ -143,7 +143,8 @@ void TouchBrowserFrameView::InitVirtualKeyboard() { Profile* keyboard_profile = browser_view()->browser()->profile(); DCHECK(keyboard_profile) << "Profile required for virtual keyboard."; - keyboard_ = new KeyboardContainerView(keyboard_profile); + keyboard_ = new KeyboardContainerView(keyboard_profile, + browser_view()->browser()); keyboard_->SetVisible(false); AddChildView(keyboard_); } |