Commit aac37049 authored by bshe@chromium.org's avatar bshe@chromium.org

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
parent f6cd1998
......@@ -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
......@@ -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);
};
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment