| 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" |
| (...skipping 19 matching lines...) Expand all Loading... |
| 30 public content::WebContentsObserver { | 30 public content::WebContentsObserver { |
| 31 public: | 31 public: |
| 32 KeyboardContentsDelegate(keyboard::KeyboardControllerProxy* proxy) | 32 KeyboardContentsDelegate(keyboard::KeyboardControllerProxy* proxy) |
| 33 : proxy_(proxy) {} | 33 : proxy_(proxy) {} |
| 34 virtual ~KeyboardContentsDelegate() {} | 34 virtual ~KeyboardContentsDelegate() {} |
| 35 | 35 |
| 36 private: | 36 private: |
| 37 // Overridden from content::WebContentsDelegate: | 37 // Overridden from content::WebContentsDelegate: |
| 38 virtual content::WebContents* OpenURLFromTab( | 38 virtual content::WebContents* OpenURLFromTab( |
| 39 content::WebContents* source, | 39 content::WebContents* source, |
| 40 const content::OpenURLParams& params) OVERRIDE { | 40 const content::OpenURLParams& params) override { |
| 41 source->GetController().LoadURL( | 41 source->GetController().LoadURL( |
| 42 params.url, params.referrer, params.transition, params.extra_headers); | 42 params.url, params.referrer, params.transition, params.extra_headers); |
| 43 Observe(source); | 43 Observe(source); |
| 44 return source; | 44 return source; |
| 45 } | 45 } |
| 46 | 46 |
| 47 virtual bool IsPopupOrPanel( | 47 virtual bool IsPopupOrPanel( |
| 48 const content::WebContents* source) const OVERRIDE { | 48 const content::WebContents* source) const override { |
| 49 return true; | 49 return true; |
| 50 } | 50 } |
| 51 | 51 |
| 52 virtual void MoveContents(content::WebContents* source, | 52 virtual void MoveContents(content::WebContents* source, |
| 53 const gfx::Rect& pos) OVERRIDE { | 53 const gfx::Rect& pos) override { |
| 54 aura::Window* keyboard = proxy_->GetKeyboardWindow(); | 54 aura::Window* keyboard = proxy_->GetKeyboardWindow(); |
| 55 // keyboard window must have been added to keyboard container window at this | 55 // keyboard window must have been added to keyboard container window at this |
| 56 // point. Otherwise, wrong keyboard bounds is used and may cause problem as | 56 // point. Otherwise, wrong keyboard bounds is used and may cause problem as |
| 57 // described in crbug.com/367788. | 57 // described in crbug.com/367788. |
| 58 DCHECK(keyboard->parent()); | 58 DCHECK(keyboard->parent()); |
| 59 gfx::Rect bounds = keyboard->bounds(); | 59 gfx::Rect bounds = keyboard->bounds(); |
| 60 int new_height = pos.height(); | 60 int new_height = pos.height(); |
| 61 bounds.set_y(bounds.y() + bounds.height() - new_height); | 61 bounds.set_y(bounds.y() + bounds.height() - new_height); |
| 62 bounds.set_height(new_height); | 62 bounds.set_height(new_height); |
| 63 // Keyboard bounds should only be reset when it actually changes. Otherwise | 63 // Keyboard bounds should only be reset when it actually changes. Otherwise |
| 64 // it interrupts the initial animation of showing the keyboard. Described in | 64 // it interrupts the initial animation of showing the keyboard. Described in |
| 65 // crbug.com/356753. | 65 // crbug.com/356753. |
| 66 if (bounds != keyboard->bounds()) | 66 if (bounds != keyboard->bounds()) |
| 67 keyboard->SetBounds(bounds); | 67 keyboard->SetBounds(bounds); |
| 68 } | 68 } |
| 69 | 69 |
| 70 // Overridden from content::WebContentsDelegate: | 70 // Overridden from content::WebContentsDelegate: |
| 71 virtual void RequestMediaAccessPermission(content::WebContents* web_contents, | 71 virtual void RequestMediaAccessPermission(content::WebContents* web_contents, |
| 72 const content::MediaStreamRequest& request, | 72 const content::MediaStreamRequest& request, |
| 73 const content::MediaResponseCallback& callback) OVERRIDE { | 73 const content::MediaResponseCallback& callback) override { |
| 74 proxy_->RequestAudioInput(web_contents, request, callback); | 74 proxy_->RequestAudioInput(web_contents, request, callback); |
| 75 } | 75 } |
| 76 | 76 |
| 77 // Overridden from content::WebContentsObserver: | 77 // Overridden from content::WebContentsObserver: |
| 78 virtual void WebContentsDestroyed() OVERRIDE { | 78 virtual void WebContentsDestroyed() override { |
| 79 delete this; | 79 delete this; |
| 80 } | 80 } |
| 81 | 81 |
| 82 keyboard::KeyboardControllerProxy* proxy_; | 82 keyboard::KeyboardControllerProxy* proxy_; |
| 83 | 83 |
| 84 DISALLOW_COPY_AND_ASSIGN(KeyboardContentsDelegate); | 84 DISALLOW_COPY_AND_ASSIGN(KeyboardContentsDelegate); |
| 85 }; | 85 }; |
| 86 | 86 |
| 87 } // namespace | 87 } // namespace |
| 88 | 88 |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 203 } | 203 } |
| 204 | 204 |
| 205 shadow_->SetContentBounds(new_bounds); | 205 shadow_->SetContentBounds(new_bounds); |
| 206 } | 206 } |
| 207 | 207 |
| 208 void KeyboardControllerProxy::OnWindowDestroyed(aura::Window* window) { | 208 void KeyboardControllerProxy::OnWindowDestroyed(aura::Window* window) { |
| 209 window->RemoveObserver(this); | 209 window->RemoveObserver(this); |
| 210 } | 210 } |
| 211 | 211 |
| 212 } // namespace keyboard | 212 } // namespace keyboard |
| OLD | NEW |