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