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