| 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/content/keyboard_ui_content.h" | 5 #include "ui/keyboard/content/keyboard_ui_content.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/macros.h" | 8 #include "base/macros.h" |
| 9 #include "base/values.h" | 9 #include "base/values.h" |
| 10 #include "content/public/browser/render_widget_host.h" | 10 #include "content/public/browser/render_widget_host.h" |
| (...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 233 | 233 |
| 234 void KeyboardUIContent::ReloadKeyboardIfNeeded() { | 234 void KeyboardUIContent::ReloadKeyboardIfNeeded() { |
| 235 DCHECK(keyboard_contents_); | 235 DCHECK(keyboard_contents_); |
| 236 if (keyboard_contents_->GetURL() != GetVirtualKeyboardUrl()) { | 236 if (keyboard_contents_->GetURL() != GetVirtualKeyboardUrl()) { |
| 237 if (keyboard_contents_->GetURL().GetOrigin() != | 237 if (keyboard_contents_->GetURL().GetOrigin() != |
| 238 GetVirtualKeyboardUrl().GetOrigin()) { | 238 GetVirtualKeyboardUrl().GetOrigin()) { |
| 239 // Sets keyboard window rectangle to 0 and close current page before | 239 // Sets keyboard window rectangle to 0 and close current page before |
| 240 // navigate to a keyboard in a different extension. This keeps the UX the | 240 // navigate to a keyboard in a different extension. This keeps the UX the |
| 241 // same as Android. Note we need to explicitly close current page as it | 241 // same as Android. Note we need to explicitly close current page as it |
| 242 // might try to resize keyboard window in javascript on a resize event. | 242 // might try to resize keyboard window in javascript on a resize event. |
| 243 TRACE_EVENT0("vk", "ReloadKeyboardIfNeeded"); |
| 243 GetKeyboardWindow()->SetBounds(gfx::Rect()); | 244 GetKeyboardWindow()->SetBounds(gfx::Rect()); |
| 244 keyboard_contents_->ClosePage(); | 245 keyboard_contents_->ClosePage(); |
| 245 keyboard_controller()->SetKeyboardMode(FULL_WIDTH); | 246 keyboard_controller()->SetKeyboardMode(FULL_WIDTH); |
| 246 } | 247 } |
| 247 LoadContents(GetVirtualKeyboardUrl()); | 248 LoadContents(GetVirtualKeyboardUrl()); |
| 248 } | 249 } |
| 249 } | 250 } |
| 250 | 251 |
| 251 void KeyboardUIContent::InitInsets(const gfx::Rect& new_bounds) { | 252 void KeyboardUIContent::InitInsets(const gfx::Rect& new_bounds) { |
| 252 // Adjust the height of the viewport for visible windows on the primary | 253 // Adjust the height of the viewport for visible windows on the primary |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 318 | 319 |
| 319 const aura::Window* KeyboardUIContent::GetKeyboardRootWindow() const { | 320 const aura::Window* KeyboardUIContent::GetKeyboardRootWindow() const { |
| 320 if (!keyboard_contents_) { | 321 if (!keyboard_contents_) { |
| 321 return nullptr; | 322 return nullptr; |
| 322 } | 323 } |
| 323 return keyboard_contents_->GetNativeView()->GetRootWindow(); | 324 return keyboard_contents_->GetNativeView()->GetRootWindow(); |
| 324 } | 325 } |
| 325 | 326 |
| 326 void KeyboardUIContent::LoadContents(const GURL& url) { | 327 void KeyboardUIContent::LoadContents(const GURL& url) { |
| 327 if (keyboard_contents_) { | 328 if (keyboard_contents_) { |
| 329 TRACE_EVENT0("vk", "LoadContents"); |
| 328 content::OpenURLParams params(url, content::Referrer(), | 330 content::OpenURLParams params(url, content::Referrer(), |
| 329 WindowOpenDisposition::SINGLETON_TAB, | 331 WindowOpenDisposition::SINGLETON_TAB, |
| 330 ui::PAGE_TRANSITION_AUTO_TOPLEVEL, false); | 332 ui::PAGE_TRANSITION_AUTO_TOPLEVEL, false); |
| 331 keyboard_contents_->OpenURL(params); | 333 keyboard_contents_->OpenURL(params); |
| 332 } | 334 } |
| 333 } | 335 } |
| 334 | 336 |
| 335 const GURL& KeyboardUIContent::GetVirtualKeyboardUrl() { | 337 const GURL& KeyboardUIContent::GetVirtualKeyboardUrl() { |
| 336 if (keyboard::IsInputViewEnabled()) { | 338 if (keyboard::IsInputViewEnabled()) { |
| 337 const GURL& override_url = GetOverrideContentUrl(); | 339 const GURL& override_url = GetOverrideContentUrl(); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 349 keyboard_controller()->keyboard_visible()); | 351 keyboard_controller()->keyboard_visible()); |
| 350 } | 352 } |
| 351 | 353 |
| 352 void KeyboardUIContent::AddBoundsChangedObserver(aura::Window* window) { | 354 void KeyboardUIContent::AddBoundsChangedObserver(aura::Window* window) { |
| 353 aura::Window* target_window = window ? window->GetToplevelWindow() : nullptr; | 355 aura::Window* target_window = window ? window->GetToplevelWindow() : nullptr; |
| 354 if (target_window) | 356 if (target_window) |
| 355 window_bounds_observer_->AddObservedWindow(target_window); | 357 window_bounds_observer_->AddObservedWindow(target_window); |
| 356 } | 358 } |
| 357 | 359 |
| 358 } // namespace keyboard | 360 } // namespace keyboard |
| OLD | NEW |