| 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 633 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 644 #endif | 644 #endif |
| 645 return static_cast<gfx::NativeViewId>(NULL); | 645 return static_cast<gfx::NativeViewId>(NULL); |
| 646 } | 646 } |
| 647 | 647 |
| 648 gfx::NativeViewAccessible RenderWidgetHostViewAura::GetNativeViewAccessible() { | 648 gfx::NativeViewAccessible RenderWidgetHostViewAura::GetNativeViewAccessible() { |
| 649 #if defined(OS_WIN) | 649 #if defined(OS_WIN) |
| 650 aura::WindowTreeHost* host = window_->GetHost(); | 650 aura::WindowTreeHost* host = window_->GetHost(); |
| 651 if (!host) | 651 if (!host) |
| 652 return static_cast<gfx::NativeViewAccessible>(NULL); | 652 return static_cast<gfx::NativeViewAccessible>(NULL); |
| 653 HWND hwnd = host->GetAcceleratedWidget(); | 653 HWND hwnd = host->GetAcceleratedWidget(); |
| 654 BrowserAccessibilityManager* manager = | 654 |
| 655 host_->GetOrCreateRootBrowserAccessibilityManager(); | 655 CreateBrowserAccessibilityManagerIfNeeded(); |
| 656 BrowserAccessibilityManager* manager = GetBrowserAccessibilityManager(); |
| 656 if (manager) | 657 if (manager) |
| 657 return manager->GetRoot()->ToBrowserAccessibilityWin(); | 658 return manager->GetRoot()->ToBrowserAccessibilityWin(); |
| 658 #endif | 659 #endif |
| 659 | 660 |
| 660 NOTIMPLEMENTED(); | 661 NOTIMPLEMENTED(); |
| 661 return static_cast<gfx::NativeViewAccessible>(NULL); | 662 return static_cast<gfx::NativeViewAccessible>(NULL); |
| 662 } | 663 } |
| 663 | 664 |
| 664 ui::TextInputClient* RenderWidgetHostViewAura::GetTextInputClient() { | 665 ui::TextInputClient* RenderWidgetHostViewAura::GetTextInputClient() { |
| 665 return this; | 666 return this; |
| (...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1035 RecordAction( | 1036 RecordAction( |
| 1036 base::UserMetricsAction("BadMessageTerminate_SharedMemoryAura")); | 1037 base::UserMetricsAction("BadMessageTerminate_SharedMemoryAura")); |
| 1037 host_->GetProcess()->ReceivedBadMessage(); | 1038 host_->GetProcess()->ReceivedBadMessage(); |
| 1038 return; | 1039 return; |
| 1039 } | 1040 } |
| 1040 } | 1041 } |
| 1041 | 1042 |
| 1042 #if defined(OS_WIN) | 1043 #if defined(OS_WIN) |
| 1043 void RenderWidgetHostViewAura::SetParentNativeViewAccessible( | 1044 void RenderWidgetHostViewAura::SetParentNativeViewAccessible( |
| 1044 gfx::NativeViewAccessible accessible_parent) { | 1045 gfx::NativeViewAccessible accessible_parent) { |
| 1045 BrowserAccessibilityManager* manager = | 1046 if (GetBrowserAccessibilityManager()) { |
| 1046 host_->GetRootBrowserAccessibilityManager(); | 1047 GetBrowserAccessibilityManager()->ToBrowserAccessibilityManagerWin() |
| 1047 if (manager) { | |
| 1048 manager->ToBrowserAccessibilityManagerWin() | |
| 1049 ->set_parent_iaccessible(accessible_parent); | 1048 ->set_parent_iaccessible(accessible_parent); |
| 1050 } | 1049 } |
| 1051 } | 1050 } |
| 1052 | 1051 |
| 1053 gfx::NativeViewId RenderWidgetHostViewAura::GetParentForWindowlessPlugin() | 1052 gfx::NativeViewId RenderWidgetHostViewAura::GetParentForWindowlessPlugin() |
| 1054 const { | 1053 const { |
| 1055 if (legacy_render_widget_host_HWND_) { | 1054 if (legacy_render_widget_host_HWND_) { |
| 1056 return reinterpret_cast<gfx::NativeViewId>( | 1055 return reinterpret_cast<gfx::NativeViewId>( |
| 1057 legacy_render_widget_host_HWND_->hwnd()); | 1056 legacy_render_widget_host_HWND_->hwnd()); |
| 1058 } | 1057 } |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1185 } | 1184 } |
| 1186 | 1185 |
| 1187 if (overscroll_controller_) | 1186 if (overscroll_controller_) |
| 1188 consumed |= overscroll_controller_->WillHandleEvent(input_event); | 1187 consumed |= overscroll_controller_->WillHandleEvent(input_event); |
| 1189 | 1188 |
| 1190 return consumed && !WebTouchEvent::isTouchEventType(input_event.type) | 1189 return consumed && !WebTouchEvent::isTouchEventType(input_event.type) |
| 1191 ? INPUT_EVENT_ACK_STATE_CONSUMED | 1190 ? INPUT_EVENT_ACK_STATE_CONSUMED |
| 1192 : INPUT_EVENT_ACK_STATE_NOT_CONSUMED; | 1191 : INPUT_EVENT_ACK_STATE_NOT_CONSUMED; |
| 1193 } | 1192 } |
| 1194 | 1193 |
| 1195 BrowserAccessibilityManager* | 1194 void RenderWidgetHostViewAura::CreateBrowserAccessibilityManagerIfNeeded() { |
| 1196 RenderWidgetHostViewAura::CreateBrowserAccessibilityManager( | |
| 1197 BrowserAccessibilityDelegate* delegate) { | |
| 1198 BrowserAccessibilityManager* manager = NULL; | |
| 1199 #if defined(OS_WIN) | 1195 #if defined(OS_WIN) |
| 1200 gfx::NativeViewAccessible accessible_parent = | 1196 if (!GetBrowserAccessibilityManager()) { |
| 1201 host_->GetParentNativeViewAccessible(); | 1197 gfx::NativeViewAccessible accessible_parent = |
| 1202 manager = new BrowserAccessibilityManagerWin( | 1198 host_->GetParentNativeViewAccessible(); |
| 1203 legacy_render_widget_host_HWND_, accessible_parent, | 1199 SetBrowserAccessibilityManager(new BrowserAccessibilityManagerWin( |
| 1204 BrowserAccessibilityManagerWin::GetEmptyDocument(), delegate); | 1200 legacy_render_widget_host_HWND_, accessible_parent, |
| 1201 BrowserAccessibilityManagerWin::GetEmptyDocument(), host_)); |
| 1202 } |
| 1205 #else | 1203 #else |
| 1206 manager = BrowserAccessibilityManager::Create( | 1204 if (!GetBrowserAccessibilityManager()) { |
| 1207 BrowserAccessibilityManager::GetEmptyDocument(), delegate); | 1205 SetBrowserAccessibilityManager( |
| 1206 BrowserAccessibilityManager::Create( |
| 1207 BrowserAccessibilityManager::GetEmptyDocument(), host_)); |
| 1208 } |
| 1208 #endif | 1209 #endif |
| 1209 return manager; | |
| 1210 } | 1210 } |
| 1211 | 1211 |
| 1212 gfx::GLSurfaceHandle RenderWidgetHostViewAura::GetCompositingSurface() { | 1212 gfx::GLSurfaceHandle RenderWidgetHostViewAura::GetCompositingSurface() { |
| 1213 return ImageTransportFactory::GetInstance()->GetSharedSurfaceHandle(); | 1213 return ImageTransportFactory::GetInstance()->GetSharedSurfaceHandle(); |
| 1214 } | 1214 } |
| 1215 | 1215 |
| 1216 bool RenderWidgetHostViewAura::LockMouse() { | 1216 bool RenderWidgetHostViewAura::LockMouse() { |
| 1217 aura::Window* root_window = window_->GetRootWindow(); | 1217 aura::Window* root_window = window_->GetRootWindow(); |
| 1218 if (!root_window) | 1218 if (!root_window) |
| 1219 return false; | 1219 return false; |
| (...skipping 821 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2041 host_->SetInputMethodActive(input_method->IsActive()); | 2041 host_->SetInputMethodActive(input_method->IsActive()); |
| 2042 | 2042 |
| 2043 // Often the application can set focus to the view in response to a key | 2043 // Often the application can set focus to the view in response to a key |
| 2044 // down. However the following char event shouldn't be sent to the web | 2044 // down. However the following char event shouldn't be sent to the web |
| 2045 // page. | 2045 // page. |
| 2046 host_->SuppressNextCharEvents(); | 2046 host_->SuppressNextCharEvents(); |
| 2047 } else { | 2047 } else { |
| 2048 host_->SetInputMethodActive(false); | 2048 host_->SetInputMethodActive(false); |
| 2049 } | 2049 } |
| 2050 | 2050 |
| 2051 BrowserAccessibilityManager* manager = | 2051 BrowserAccessibilityManager* manager = GetBrowserAccessibilityManager(); |
| 2052 host_->GetRootBrowserAccessibilityManager(); | |
| 2053 if (manager) | 2052 if (manager) |
| 2054 manager->OnWindowFocused(); | 2053 manager->OnWindowFocused(); |
| 2055 } else if (window_ == lost_focus) { | 2054 } else if (window_ == lost_focus) { |
| 2056 host_->SetActive(false); | 2055 host_->SetActive(false); |
| 2057 host_->Blur(); | 2056 host_->Blur(); |
| 2058 | 2057 |
| 2059 DetachFromInputMethod(); | 2058 DetachFromInputMethod(); |
| 2060 host_->SetInputMethodActive(false); | 2059 host_->SetInputMethodActive(false); |
| 2061 | 2060 |
| 2062 if (touch_editing_client_) | 2061 if (touch_editing_client_) |
| 2063 touch_editing_client_->EndTouchEditing(false); | 2062 touch_editing_client_->EndTouchEditing(false); |
| 2064 | 2063 |
| 2065 if (overscroll_controller_) | 2064 if (overscroll_controller_) |
| 2066 overscroll_controller_->Cancel(); | 2065 overscroll_controller_->Cancel(); |
| 2067 | 2066 |
| 2068 BrowserAccessibilityManager* manager = | 2067 BrowserAccessibilityManager* manager = GetBrowserAccessibilityManager(); |
| 2069 host_->GetRootBrowserAccessibilityManager(); | |
| 2070 if (manager) | 2068 if (manager) |
| 2071 manager->OnWindowBlurred(); | 2069 manager->OnWindowBlurred(); |
| 2072 | 2070 |
| 2073 // If we lose the focus while fullscreen, close the window; Pepper Flash | 2071 // If we lose the focus while fullscreen, close the window; Pepper Flash |
| 2074 // won't do it for us (unlike NPAPI Flash). However, we do not close the | 2072 // won't do it for us (unlike NPAPI Flash). However, we do not close the |
| 2075 // window if we lose the focus to a window on another display. | 2073 // window if we lose the focus to a window on another display. |
| 2076 gfx::Screen* screen = gfx::Screen::GetScreenFor(window_); | 2074 gfx::Screen* screen = gfx::Screen::GetScreenFor(window_); |
| 2077 bool focusing_other_display = | 2075 bool focusing_other_display = |
| 2078 gained_focus && screen->GetNumDisplays() > 1 && | 2076 gained_focus && screen->GetNumDisplays() > 1 && |
| 2079 (screen->GetDisplayNearestWindow(window_).id() != | 2077 (screen->GetDisplayNearestWindow(window_).id() != |
| (...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2305 window_->GetBoundsInRootWindow()); | 2303 window_->GetBoundsInRootWindow()); |
| 2306 // There are cases where the parent window is created, made visible and | 2304 // There are cases where the parent window is created, made visible and |
| 2307 // the associated RenderWidget is also visible before the | 2305 // the associated RenderWidget is also visible before the |
| 2308 // LegacyRenderWidgetHostHWND instace is created. Ensure that it is shown | 2306 // LegacyRenderWidgetHostHWND instace is created. Ensure that it is shown |
| 2309 // here. | 2307 // here. |
| 2310 if (!host_->is_hidden()) | 2308 if (!host_->is_hidden()) |
| 2311 legacy_render_widget_host_HWND_->Show(); | 2309 legacy_render_widget_host_HWND_->Show(); |
| 2312 | 2310 |
| 2313 BrowserAccessibilityManagerWin* manager = | 2311 BrowserAccessibilityManagerWin* manager = |
| 2314 static_cast<BrowserAccessibilityManagerWin*>( | 2312 static_cast<BrowserAccessibilityManagerWin*>( |
| 2315 host_->GetRootBrowserAccessibilityManager()); | 2313 GetBrowserAccessibilityManager()); |
| 2316 if (manager) | 2314 if (manager) |
| 2317 manager->SetAccessibleHWND(legacy_render_widget_host_HWND_); | 2315 manager->SetAccessibleHWND(legacy_render_widget_host_HWND_); |
| 2318 } | 2316 } |
| 2319 } | 2317 } |
| 2320 | 2318 |
| 2321 if (mouse_locked_) | 2319 if (mouse_locked_) |
| 2322 UpdateMouseLockRegion(); | 2320 UpdateMouseLockRegion(); |
| 2323 #endif | 2321 #endif |
| 2324 } | 2322 } |
| 2325 | 2323 |
| (...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2486 | 2484 |
| 2487 //////////////////////////////////////////////////////////////////////////////// | 2485 //////////////////////////////////////////////////////////////////////////////// |
| 2488 // RenderWidgetHostViewBase, public: | 2486 // RenderWidgetHostViewBase, public: |
| 2489 | 2487 |
| 2490 // static | 2488 // static |
| 2491 void RenderWidgetHostViewBase::GetDefaultScreenInfo(WebScreenInfo* results) { | 2489 void RenderWidgetHostViewBase::GetDefaultScreenInfo(WebScreenInfo* results) { |
| 2492 GetScreenInfoForWindow(results, NULL); | 2490 GetScreenInfoForWindow(results, NULL); |
| 2493 } | 2491 } |
| 2494 | 2492 |
| 2495 } // namespace content | 2493 } // namespace content |
| OLD | NEW |