Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "ui/keyboard/keyboard_controller_proxy.h" | 5 #include "ui/keyboard/keyboard_controller_proxy.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/values.h" | 8 #include "base/values.h" |
| 9 #include "content/public/browser/site_instance.h" | 9 #include "content/public/browser/site_instance.h" |
| 10 #include "content/public/browser/web_contents.h" | 10 #include "content/public/browser/web_contents.h" |
| 11 #include "content/public/browser/web_contents.h" | 11 #include "content/public/browser/web_contents.h" |
| 12 #include "content/public/browser/web_contents_delegate.h" | 12 #include "content/public/browser/web_contents_delegate.h" |
| 13 #include "content/public/browser/web_contents_observer.h" | 13 #include "content/public/browser/web_contents_observer.h" |
| 14 #include "content/public/browser/web_ui.h" | 14 #include "content/public/browser/web_ui.h" |
| 15 #include "content/public/common/bindings_policy.h" | 15 #include "content/public/common/bindings_policy.h" |
| 16 #include "ui/aura/layout_manager.h" | 16 #include "ui/aura/layout_manager.h" |
| 17 #include "ui/aura/window.h" | 17 #include "ui/aura/window.h" |
| 18 #include "ui/keyboard/keyboard_constants.h" | 18 #include "ui/keyboard/keyboard_constants.h" |
| 19 #include "ui/keyboard/keyboard_switches.h" | 19 #include "ui/keyboard/keyboard_switches.h" |
| 20 #include "ui/keyboard/keyboard_util.h" | 20 #include "ui/keyboard/keyboard_util.h" |
| 21 #include "ui/wm/core/shadow.h" | |
| 21 | 22 |
| 22 namespace { | 23 namespace { |
| 23 | 24 |
| 24 // The WebContentsDelegate for the keyboard. | 25 // The WebContentsDelegate for the keyboard. |
| 25 // The delegate deletes itself when the keyboard is destroyed. | 26 // The delegate deletes itself when the keyboard is destroyed. |
| 26 class KeyboardContentsDelegate : public content::WebContentsDelegate, | 27 class KeyboardContentsDelegate : public content::WebContentsDelegate, |
| 27 public content::WebContentsObserver { | 28 public content::WebContentsObserver { |
| 28 public: | 29 public: |
| 29 KeyboardContentsDelegate(keyboard::KeyboardControllerProxy* proxy) | 30 KeyboardContentsDelegate(keyboard::KeyboardControllerProxy* proxy) |
| 30 : proxy_(proxy) {} | 31 : proxy_(proxy) {} |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 112 aura::Window* KeyboardControllerProxy::GetKeyboardWindow() { | 113 aura::Window* KeyboardControllerProxy::GetKeyboardWindow() { |
| 113 if (!keyboard_contents_) { | 114 if (!keyboard_contents_) { |
| 114 content::BrowserContext* context = GetBrowserContext(); | 115 content::BrowserContext* context = GetBrowserContext(); |
| 115 keyboard_contents_.reset(content::WebContents::Create( | 116 keyboard_contents_.reset(content::WebContents::Create( |
| 116 content::WebContents::CreateParams(context, | 117 content::WebContents::CreateParams(context, |
| 117 content::SiteInstance::CreateForURL(context, | 118 content::SiteInstance::CreateForURL(context, |
| 118 GetVirtualKeyboardUrl())))); | 119 GetVirtualKeyboardUrl())))); |
| 119 keyboard_contents_->SetDelegate(new KeyboardContentsDelegate(this)); | 120 keyboard_contents_->SetDelegate(new KeyboardContentsDelegate(this)); |
| 120 SetupWebContents(keyboard_contents_.get()); | 121 SetupWebContents(keyboard_contents_.get()); |
| 121 LoadContents(GetVirtualKeyboardUrl()); | 122 LoadContents(GetVirtualKeyboardUrl()); |
| 123 keyboard_contents_->GetNativeView()->AddObserver(this); | |
| 122 } | 124 } |
| 123 | 125 |
| 124 return keyboard_contents_->GetNativeView(); | 126 return keyboard_contents_->GetNativeView(); |
| 125 } | 127 } |
| 126 | 128 |
| 127 bool KeyboardControllerProxy::HasKeyboardWindow() const { | 129 bool KeyboardControllerProxy::HasKeyboardWindow() const { |
| 128 return keyboard_contents_; | 130 return keyboard_contents_; |
| 129 } | 131 } |
| 130 | 132 |
| 131 void KeyboardControllerProxy::ShowKeyboardContainer(aura::Window* container) { | 133 void KeyboardControllerProxy::ShowKeyboardContainer(aura::Window* container) { |
| (...skipping 24 matching lines...) Expand all Loading... | |
| 156 void KeyboardControllerProxy::ReloadKeyboardIfNeeded() { | 158 void KeyboardControllerProxy::ReloadKeyboardIfNeeded() { |
| 157 DCHECK(keyboard_contents_); | 159 DCHECK(keyboard_contents_); |
| 158 if (keyboard_contents_->GetURL() != GetVirtualKeyboardUrl()) { | 160 if (keyboard_contents_->GetURL() != GetVirtualKeyboardUrl()) { |
| 159 LoadContents(GetVirtualKeyboardUrl()); | 161 LoadContents(GetVirtualKeyboardUrl()); |
| 160 } | 162 } |
| 161 } | 163 } |
| 162 | 164 |
| 163 void KeyboardControllerProxy::SetupWebContents(content::WebContents* contents) { | 165 void KeyboardControllerProxy::SetupWebContents(content::WebContents* contents) { |
| 164 } | 166 } |
| 165 | 167 |
| 168 void KeyboardControllerProxy::OnWindowBoundsChanged( | |
| 169 aura::Window* window, | |
| 170 const gfx::Rect& old_bounds, | |
| 171 const gfx::Rect& new_bounds) { | |
| 172 if (!shadow_) { | |
| 173 shadow_.reset(new wm::Shadow()); | |
| 174 shadow_->Init(wm::Shadow::STYLE_ACTIVE); | |
| 175 shadow_->layer()->SetVisible(true); | |
| 176 DCHECK(keyboard_contents_->GetNativeView()->parent()); | |
| 177 keyboard_contents_->GetNativeView()->parent()->layer()->Add( | |
| 178 shadow_->layer()); | |
|
kevers
2014/05/12 16:15:02
Has the impact of the size change been tested with
bshe
2014/05/12 16:24:43
I tried a11y keyboard and the shadow seems work fi
kevers
2014/05/12 17:10:18
My main concern was whether the top shadow overlap
| |
| 179 } | |
| 180 | |
| 181 shadow_->SetContentBounds(new_bounds); | |
| 182 } | |
| 183 | |
| 184 void KeyboardControllerProxy::OnWindowDestroyed(aura::Window* window) { | |
| 185 window->RemoveObserver(this); | |
| 186 } | |
| 187 | |
| 166 } // namespace keyboard | 188 } // namespace keyboard |
| OLD | NEW |