diff options
author | bshe@chromium.org <bshe@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-05-12 23:45:51 +0000 |
---|---|---|
committer | bshe@chromium.org <bshe@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-05-12 23:45:51 +0000 |
commit | aac3704922b4d2e658a56369e5fdfed63faf46ae (patch) | |
tree | 0dca98d797db8c20033397601ae2aa7ca0b0a75e | |
parent | f6cd19984d42e91bf283365f5a6e1418436d01bc (diff) | |
download | chromium_src-aac3704922b4d2e658a56369e5fdfed63faf46ae.zip chromium_src-aac3704922b4d2e658a56369e5fdfed63faf46ae.tar.gz chromium_src-aac3704922b4d2e658a56369e5fdfed63faf46ae.tar.bz2 |
Add default shadow to keyboard window
BUG=370412
TEST=
1. open virtual keyboard in google.com
2. virtual keyboard window should have the default shadow
Review URL: https://codereview.chromium.org/280273002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@269915 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | ui/keyboard/keyboard_controller_proxy.cc | 22 | ||||
-rw-r--r-- | ui/keyboard/keyboard_controller_proxy.h | 13 |
2 files changed, 34 insertions, 1 deletions
diff --git a/ui/keyboard/keyboard_controller_proxy.cc b/ui/keyboard/keyboard_controller_proxy.cc index 2ade09d..9ed1197 100644 --- a/ui/keyboard/keyboard_controller_proxy.cc +++ b/ui/keyboard/keyboard_controller_proxy.cc @@ -18,6 +18,7 @@ #include "ui/keyboard/keyboard_constants.h" #include "ui/keyboard/keyboard_switches.h" #include "ui/keyboard/keyboard_util.h" +#include "ui/wm/core/shadow.h" namespace { @@ -119,6 +120,7 @@ aura::Window* KeyboardControllerProxy::GetKeyboardWindow() { keyboard_contents_->SetDelegate(new KeyboardContentsDelegate(this)); SetupWebContents(keyboard_contents_.get()); LoadContents(GetVirtualKeyboardUrl()); + keyboard_contents_->GetNativeView()->AddObserver(this); } return keyboard_contents_->GetNativeView(); @@ -163,4 +165,24 @@ void KeyboardControllerProxy::ReloadKeyboardIfNeeded() { void KeyboardControllerProxy::SetupWebContents(content::WebContents* contents) { } +void KeyboardControllerProxy::OnWindowBoundsChanged( + aura::Window* window, + const gfx::Rect& old_bounds, + const gfx::Rect& new_bounds) { + if (!shadow_) { + shadow_.reset(new wm::Shadow()); + shadow_->Init(wm::Shadow::STYLE_ACTIVE); + shadow_->layer()->SetVisible(true); + DCHECK(keyboard_contents_->GetNativeView()->parent()); + keyboard_contents_->GetNativeView()->parent()->layer()->Add( + shadow_->layer()); + } + + shadow_->SetContentBounds(new_bounds); +} + +void KeyboardControllerProxy::OnWindowDestroyed(aura::Window* window) { + window->RemoveObserver(this); +} + } // namespace keyboard diff --git a/ui/keyboard/keyboard_controller_proxy.h b/ui/keyboard/keyboard_controller_proxy.h index 0884cd9..d7886e2 100644 --- a/ui/keyboard/keyboard_controller_proxy.h +++ b/ui/keyboard/keyboard_controller_proxy.h @@ -7,6 +7,7 @@ #include "base/memory/scoped_ptr.h" #include "content/public/common/media_stream_request.h" +#include "ui/aura/window_observer.h" #include "ui/base/ime/text_input_type.h" #include "ui/keyboard/keyboard_export.h" @@ -24,12 +25,15 @@ class Rect; namespace ui { class InputMethod; } +namespace wm { +class Shadow; +} namespace keyboard { // A proxy used by the KeyboardController to get access to the virtual // keyboard window. -class KEYBOARD_EXPORT KeyboardControllerProxy { +class KEYBOARD_EXPORT KeyboardControllerProxy : public aura::WindowObserver { public: class TestApi { public: @@ -108,6 +112,12 @@ class KEYBOARD_EXPORT KeyboardControllerProxy { // loading the keyboard page. virtual void SetupWebContents(content::WebContents* contents); + // aura::WindowObserver overrides: + virtual void OnWindowBoundsChanged(aura::Window* window, + const gfx::Rect& old_bounds, + const gfx::Rect& new_bounds) OVERRIDE; + virtual void OnWindowDestroyed(aura::Window* window) OVERRIDE; + private: friend class TestApi; @@ -120,6 +130,7 @@ class KEYBOARD_EXPORT KeyboardControllerProxy { const GURL default_url_; scoped_ptr<content::WebContents> keyboard_contents_; + scoped_ptr<wm::Shadow> shadow_; DISALLOW_COPY_AND_ASSIGN(KeyboardControllerProxy); }; |