Home | History | Annotate | Download | only in keyboard
      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 #ifndef UI_KEYBOARD_KEYBOARD_CONTROLLER_PROXY_H_
      6 #define UI_KEYBOARD_KEYBOARD_CONTROLLER_PROXY_H_
      7 
      8 #include "base/memory/scoped_ptr.h"
      9 #include "content/public/common/media_stream_request.h"
     10 #include "ui/keyboard/keyboard_export.h"
     11 
     12 namespace aura {
     13 class Window;
     14 }
     15 namespace content {
     16 class BrowserContext;
     17 class SiteInstance;
     18 class WebContents;
     19 }
     20 namespace gfx {
     21 class Rect;
     22 }
     23 namespace ui {
     24 class InputMethod;
     25 }
     26 
     27 namespace keyboard {
     28 
     29 // A proxy used by the KeyboardController to get access to the virtual
     30 // keyboard window.
     31 class KEYBOARD_EXPORT KeyboardControllerProxy {
     32  public:
     33   KeyboardControllerProxy();
     34   virtual ~KeyboardControllerProxy();
     35 
     36   // Gets the virtual keyboard window.  Ownership of the returned Window remains
     37   // with the proxy.
     38   virtual aura::Window* GetKeyboardWindow();
     39 
     40   // Gets the InputMethod that will provide notifications about changes in the
     41   // text input context.
     42   virtual ui::InputMethod* GetInputMethod() = 0;
     43 
     44   // Requests the audio input from microphone for speech input.
     45   virtual void RequestAudioInput(content::WebContents* web_contents,
     46       const content::MediaStreamRequest& request,
     47       const content::MediaResponseCallback& callback) = 0;
     48 
     49   // Shows the container window of the keyboard. The default implementation
     50   // simply shows the container. An overridden implementation can set up
     51   // necessary animation, or delay the visibility change as it desires.
     52   virtual void ShowKeyboardContainer(aura::Window* container);
     53 
     54   // Hides the container window of the keyboard. The default implementation
     55   // simply hides the container. An overridden implementation can set up
     56   // necesasry animation, or delay the visibility change as it desires.
     57   virtual void HideKeyboardContainer(aura::Window* container);
     58 
     59  protected:
     60   // Gets the BrowserContext to use for creating the WebContents hosting the
     61   // keyboard.
     62   virtual content::BrowserContext* GetBrowserContext() = 0;
     63 
     64   // The implementation can choose to setup the WebContents before the virtual
     65   // keyboard page is loaded (e.g. install a WebContentsObserver).
     66   // SetupWebContents() is called right after creating the WebContents, before
     67   // loading the keyboard page.
     68   virtual void SetupWebContents(content::WebContents* contents);
     69 
     70  private:
     71   scoped_ptr<content::WebContents> keyboard_contents_;
     72 
     73   DISALLOW_COPY_AND_ASSIGN(KeyboardControllerProxy);
     74 };
     75 
     76 }  // namespace keyboard
     77 
     78 #endif  // UI_KEYBOARD_KEYBOARD_CONTROLLER_PROXY_H_
     79