OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "content/browser/renderer_host/render_widget_host_view_aura.h" | 5 #include "content/browser/renderer_host/render_widget_host_view_aura.h" |
6 | 6 |
7 #include "base/auto_reset.h" | 7 #include "base/auto_reset.h" |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/callback_helpers.h" | 10 #include "base/callback_helpers.h" |
(...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
380 event->type() != ui::ET_TOUCH_PRESSED) { | 380 event->type() != ui::ET_TOUCH_PRESSED) { |
381 return; | 381 return; |
382 } | 382 } |
383 | 383 |
384 aura::Window* target = static_cast<aura::Window*>(event->target()); | 384 aura::Window* target = static_cast<aura::Window*>(event->target()); |
385 if (target != window_ && | 385 if (target != window_ && |
386 (!popup_parent_host_view_ || | 386 (!popup_parent_host_view_ || |
387 target != popup_parent_host_view_->window_)) { | 387 target != popup_parent_host_view_->window_)) { |
388 // Note: popup_parent_host_view_ may be NULL when there are multiple | 388 // Note: popup_parent_host_view_ may be NULL when there are multiple |
389 // popup children per view. See: RenderWidgetHostViewAura::InitAsPopup(). | 389 // popup children per view. See: RenderWidgetHostViewAura::InitAsPopup(). |
390 Shutdown(); | 390 in_shutdown_ = true; |
| 391 host_->Shutdown(); |
391 } | 392 } |
392 } | 393 } |
393 | 394 |
394 // We have to implement the WindowObserver interface on a separate object | 395 // We have to implement the WindowObserver interface on a separate object |
395 // because clang doesn't like implementing multiple interfaces that have | 396 // because clang doesn't like implementing multiple interfaces that have |
396 // methods with the same name. This object is owned by the | 397 // methods with the same name. This object is owned by the |
397 // RenderWidgetHostViewAura. | 398 // RenderWidgetHostViewAura. |
398 class RenderWidgetHostViewAura::WindowObserver : public aura::WindowObserver { | 399 class RenderWidgetHostViewAura::WindowObserver : public aura::WindowObserver { |
399 public: | 400 public: |
400 explicit WindowObserver(RenderWidgetHostViewAura* view) | 401 explicit WindowObserver(RenderWidgetHostViewAura* view) |
(...skipping 1410 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1811 aura::WindowTracker tracker; | 1812 aura::WindowTracker tracker; |
1812 aura::Window* window = window_; | 1813 aura::Window* window = window_; |
1813 tracker.Add(window); | 1814 tracker.Add(window); |
1814 host->Focus(); | 1815 host->Focus(); |
1815 if (!tracker.Contains(window)) { | 1816 if (!tracker.Contains(window)) { |
1816 event->SetHandled(); | 1817 event->SetHandled(); |
1817 return; | 1818 return; |
1818 } | 1819 } |
1819 } | 1820 } |
1820 } | 1821 } |
1821 Shutdown(); | 1822 if (!in_shutdown_) { |
| 1823 in_shutdown_ = true; |
| 1824 host_->Shutdown(); |
| 1825 } |
1822 } else { | 1826 } else { |
1823 if (event->key_code() == ui::VKEY_RETURN) { | 1827 if (event->key_code() == ui::VKEY_RETURN) { |
1824 // Do not forward return key release events if no press event was handled. | 1828 // Do not forward return key release events if no press event was handled. |
1825 if (event->type() == ui::ET_KEY_RELEASED && !accept_return_character_) | 1829 if (event->type() == ui::ET_KEY_RELEASED && !accept_return_character_) |
1826 return; | 1830 return; |
1827 // Accept return key character events between press and release events. | 1831 // Accept return key character events between press and release events. |
1828 accept_return_character_ = event->type() == ui::ET_KEY_PRESSED; | 1832 accept_return_character_ = event->type() == ui::ET_KEY_PRESSED; |
1829 } | 1833 } |
1830 | 1834 |
1831 // We don't have to communicate with an input method here. | 1835 // We don't have to communicate with an input method here. |
(...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2201 // On Windows, if we are switching to a non Aura Window on a different | 2205 // On Windows, if we are switching to a non Aura Window on a different |
2202 // screen we should not close the fullscreen window. | 2206 // screen we should not close the fullscreen window. |
2203 if (!gained_focus) { | 2207 if (!gained_focus) { |
2204 POINT point = {0}; | 2208 POINT point = {0}; |
2205 ::GetCursorPos(&point); | 2209 ::GetCursorPos(&point); |
2206 if (screen->GetDisplayNearestWindow(window_).id() != | 2210 if (screen->GetDisplayNearestWindow(window_).id() != |
2207 screen->GetDisplayNearestPoint(gfx::Point(point)).id()) | 2211 screen->GetDisplayNearestPoint(gfx::Point(point)).id()) |
2208 return; | 2212 return; |
2209 } | 2213 } |
2210 #endif | 2214 #endif |
2211 Shutdown(); | 2215 in_shutdown_ = true; |
2212 return; | 2216 host_->Shutdown(); |
2213 } | 2217 } |
2214 | |
2215 // Close the child popup window if we lose focus (e.g. due to a JS alert or | |
2216 // system modal dialog). This is particularly important if | |
2217 // |popup_child_host_view_| has mouse capture. | |
2218 if (popup_child_host_view_) | |
2219 popup_child_host_view_->Shutdown(); | |
2220 } | 2218 } |
2221 } | 2219 } |
2222 | 2220 |
2223 //////////////////////////////////////////////////////////////////////////////// | 2221 //////////////////////////////////////////////////////////////////////////////// |
2224 // RenderWidgetHostViewAura, aura::WindowTreeHostObserver implementation: | 2222 // RenderWidgetHostViewAura, aura::WindowTreeHostObserver implementation: |
2225 | 2223 |
2226 void RenderWidgetHostViewAura::OnHostMoved(const aura::WindowTreeHost* host, | 2224 void RenderWidgetHostViewAura::OnHostMoved(const aura::WindowTreeHost* host, |
2227 const gfx::Point& new_origin) { | 2225 const gfx::Point& new_origin) { |
2228 TRACE_EVENT1("ui", "RenderWidgetHostViewAura::OnHostMoved", | 2226 TRACE_EVENT1("ui", "RenderWidgetHostViewAura::OnHostMoved", |
2229 "new_origin", new_origin.ToString()); | 2227 "new_origin", new_origin.ToString()); |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2300 } | 2298 } |
2301 } | 2299 } |
2302 | 2300 |
2303 ui::InputMethod* RenderWidgetHostViewAura::GetInputMethod() const { | 2301 ui::InputMethod* RenderWidgetHostViewAura::GetInputMethod() const { |
2304 aura::Window* root_window = window_->GetRootWindow(); | 2302 aura::Window* root_window = window_->GetRootWindow(); |
2305 if (!root_window) | 2303 if (!root_window) |
2306 return NULL; | 2304 return NULL; |
2307 return root_window->GetProperty(aura::client::kRootWindowInputMethodKey); | 2305 return root_window->GetProperty(aura::client::kRootWindowInputMethodKey); |
2308 } | 2306 } |
2309 | 2307 |
2310 void RenderWidgetHostViewAura::Shutdown() { | |
2311 if (!in_shutdown_) { | |
2312 in_shutdown_ = true; | |
2313 host_->Shutdown(); | |
2314 } | |
2315 } | |
2316 | |
2317 bool RenderWidgetHostViewAura::NeedsInputGrab() { | 2308 bool RenderWidgetHostViewAura::NeedsInputGrab() { |
2318 return popup_type_ == blink::WebPopupTypeSelect; | 2309 return popup_type_ == blink::WebPopupTypeSelect; |
2319 } | 2310 } |
2320 | 2311 |
2321 bool RenderWidgetHostViewAura::NeedsMouseCapture() { | 2312 bool RenderWidgetHostViewAura::NeedsMouseCapture() { |
2322 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) | 2313 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) |
2323 return NeedsInputGrab(); | 2314 return NeedsInputGrab(); |
2324 #endif | 2315 #endif |
2325 return false; | 2316 return false; |
2326 } | 2317 } |
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2615 | 2606 |
2616 //////////////////////////////////////////////////////////////////////////////// | 2607 //////////////////////////////////////////////////////////////////////////////// |
2617 // RenderWidgetHostViewBase, public: | 2608 // RenderWidgetHostViewBase, public: |
2618 | 2609 |
2619 // static | 2610 // static |
2620 void RenderWidgetHostViewBase::GetDefaultScreenInfo(WebScreenInfo* results) { | 2611 void RenderWidgetHostViewBase::GetDefaultScreenInfo(WebScreenInfo* results) { |
2621 GetScreenInfoForWindow(results, NULL); | 2612 GetScreenInfoForWindow(results, NULL); |
2622 } | 2613 } |
2623 | 2614 |
2624 } // namespace content | 2615 } // namespace content |
OLD | NEW |