Upstream version 7.36.149.0
[platform/framework/web/crosswalk.git] / src / ui / keyboard / keyboard_controller.h
index 86cd12d..7bd8e2f 100644 (file)
 #include "ui/aura/window_observer.h"
 #include "ui/base/ime/input_method_observer.h"
 #include "ui/base/ime/text_input_type.h"
+#include "ui/gfx/rect.h"
 #include "ui/keyboard/keyboard_export.h"
 #include "url/gurl.h"
 
 namespace aura {
 class Window;
 }
-namespace gfx {
-class Rect;
-}
 namespace ui {
 class InputMethod;
 class TextInputClient;
@@ -58,7 +56,8 @@ class KEYBOARD_EXPORT KeyboardController : public ui::InputMethodObserver,
     return container_.get() != NULL;
   }
 
-  // Reloads the content of the keyboard.
+  // Reloads the content of the keyboard. No-op if the keyboard content is not
+  // loaded yet.
   void Reload();
 
   // Hides virtual keyboard and notifies observer bounds change.
@@ -78,8 +77,26 @@ class KEYBOARD_EXPORT KeyboardController : public ui::InputMethodObserver,
 
   void set_lock_keyboard(bool lock) { lock_keyboard_ = lock; }
 
-  // Force the keyboard to show up if not showing and lock the keyboard.
-  void ShowAndLockKeyboard();
+  // Force the keyboard to show up if not showing and lock the keyboard if
+  // |lock| is true.
+  void ShowKeyboard(bool lock);
+
+  // Sets the active keyboard controller. KeyboardController takes ownership of
+  // the instance. Calling ResetIntance with a new instance destroys the
+  // previous one. May be called with NULL to clear the instance.
+  static void ResetInstance(KeyboardController* controller);
+
+  // Retrieve the active keyboard controller.
+  static KeyboardController* GetInstance();
+
+  // Returns true if keyboard is currently visible.
+  bool keyboard_visible() { return keyboard_visible_; }
+
+  // Returns the current keyboard bounds. When the keyboard is not shown,
+  // an empty rectangle will get returned.
+  const gfx::Rect& current_keyboard_bounds() {
+    return current_keyboard_bounds_;
+  }
 
  private:
   // For access to Observer methods for simulation.
@@ -103,7 +120,10 @@ class KEYBOARD_EXPORT KeyboardController : public ui::InputMethodObserver,
   virtual void OnShowImeIfNeeded() OVERRIDE;
 
   // Show virtual keyboard immediately with animation.
-  void ShowKeyboard();
+  void ShowKeyboardInternal();
+
+  // Clears any insets on web content windows.
+  void ResetWindowInsets();
 
   // Returns true if keyboard is scheduled to hide.
   bool WillHideKeyboard() const;
@@ -128,6 +148,11 @@ class KEYBOARD_EXPORT KeyboardController : public ui::InputMethodObserver,
 
   base::WeakPtrFactory<KeyboardController> weak_factory_;
 
+  // The currently used keyboard position.
+  gfx::Rect current_keyboard_bounds_;
+
+  static KeyboardController* instance_;
+
   DISALLOW_COPY_AND_ASSIGN(KeyboardController);
 };