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 "ui/views/controls/webview/webview.h" | 5 #include "ui/views/controls/webview/webview.h" |
6 | 6 |
7 #include "content/public/browser/browser_accessibility_state.h" | 7 #include "content/public/browser/browser_accessibility_state.h" |
8 #include "content/public/browser/browser_context.h" | 8 #include "content/public/browser/browser_context.h" |
9 #include "content/public/browser/navigation_controller.h" | 9 #include "content/public/browser/navigation_controller.h" |
10 #include "content/public/browser/render_view_host.h" | 10 #include "content/public/browser/render_view_host.h" |
11 #include "content/public/browser/render_widget_host_view.h" | 11 #include "content/public/browser/render_widget_host_view.h" |
12 #include "content/public/browser/web_contents.h" | 12 #include "content/public/browser/web_contents.h" |
13 #include "ipc/ipc_message.h" | 13 #include "ipc/ipc_message.h" |
14 #include "ui/accessibility/ax_enums.h" | 14 #include "ui/accessibility/ax_enums.h" |
15 #include "ui/accessibility/ax_view_state.h" | 15 #include "ui/accessibility/ax_view_state.h" |
| 16 #include "ui/aura/window.h" |
16 #include "ui/base/ui_base_switches_util.h" | 17 #include "ui/base/ui_base_switches_util.h" |
17 #include "ui/events/event.h" | 18 #include "ui/events/event.h" |
18 #include "ui/views/accessibility/native_view_accessibility.h" | 19 #include "ui/views/accessibility/native_view_accessibility.h" |
19 #include "ui/views/controls/native/native_view_host.h" | 20 #include "ui/views/controls/native/native_view_host.h" |
20 #include "ui/views/focus/focus_manager.h" | 21 #include "ui/views/focus/focus_manager.h" |
21 #include "ui/views/views_delegate.h" | 22 #include "ui/views/views_delegate.h" |
22 | 23 |
23 namespace views { | 24 namespace views { |
24 | 25 |
25 // static | 26 // static |
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
294 // already attached. | 295 // already attached. |
295 if (!GetWidget() || !web_contents()) | 296 if (!GetWidget() || !web_contents()) |
296 return; | 297 return; |
297 | 298 |
298 const gfx::NativeView view_to_attach = is_embedding_fullscreen_widget_ ? | 299 const gfx::NativeView view_to_attach = is_embedding_fullscreen_widget_ ? |
299 web_contents()->GetFullscreenRenderWidgetHostView()->GetNativeView() : | 300 web_contents()->GetFullscreenRenderWidgetHostView()->GetNativeView() : |
300 web_contents()->GetNativeView(); | 301 web_contents()->GetNativeView(); |
301 OnBoundsChanged(bounds()); | 302 OnBoundsChanged(bounds()); |
302 if (holder_->native_view() == view_to_attach) | 303 if (holder_->native_view() == view_to_attach) |
303 return; | 304 return; |
| 305 |
| 306 // Fullscreen widgets are not parented by a WebContentsView. Their visibility |
| 307 // is controlled by content i.e. (RenderWidgetHost) |
| 308 if (!is_embedding_fullscreen_widget_) |
| 309 view_to_attach->Show(); |
| 310 |
304 holder_->Attach(view_to_attach); | 311 holder_->Attach(view_to_attach); |
305 | 312 |
306 // The view will not be focused automatically when it is attached, so we need | 313 // The view will not be focused automatically when it is attached, so we need |
307 // to pass on focus to it if the FocusManager thinks the view is focused. Note | 314 // to pass on focus to it if the FocusManager thinks the view is focused. Note |
308 // that not every Widget has a focus manager. | 315 // that not every Widget has a focus manager. |
309 FocusManager* const focus_manager = GetFocusManager(); | 316 FocusManager* const focus_manager = GetFocusManager(); |
310 if (focus_manager && focus_manager->GetFocusedView() == this) | 317 if (focus_manager && focus_manager->GetFocusedView() == this) |
311 OnFocus(); | 318 OnFocus(); |
312 | 319 |
313 #if defined(OS_WIN) | 320 #if defined(OS_WIN) |
314 if (!is_embedding_fullscreen_widget_) { | 321 if (!is_embedding_fullscreen_widget_) { |
315 web_contents()->SetParentNativeViewAccessible( | 322 web_contents()->SetParentNativeViewAccessible( |
316 parent()->GetNativeViewAccessible()); | 323 parent()->GetNativeViewAccessible()); |
317 } | 324 } |
318 #endif | 325 #endif |
319 } | 326 } |
320 | 327 |
321 void WebView::DetachWebContents() { | 328 void WebView::DetachWebContents() { |
322 if (web_contents()) { | 329 if (web_contents()) { |
| 330 // Fullscreen widgets are not parented by a WebContentsView. Their |
| 331 // visibility is controlled by content i.e. (RenderWidgetHost). |
| 332 if (!is_embedding_fullscreen_widget_) |
| 333 web_contents()->GetNativeView()->Hide(); |
| 334 |
323 holder_->Detach(); | 335 holder_->Detach(); |
324 #if defined(OS_WIN) | 336 #if defined(OS_WIN) |
325 if (!is_embedding_fullscreen_widget_) | 337 if (!is_embedding_fullscreen_widget_) |
326 web_contents()->SetParentNativeViewAccessible(NULL); | 338 web_contents()->SetParentNativeViewAccessible(NULL); |
327 #endif | 339 #endif |
328 } | 340 } |
329 } | 341 } |
330 | 342 |
331 void WebView::ReattachForFullscreenChange(bool enter_fullscreen) { | 343 void WebView::ReattachForFullscreenChange(bool enter_fullscreen) { |
332 DCHECK(embed_fullscreen_widget_mode_enabled_); | 344 DCHECK(embed_fullscreen_widget_mode_enabled_); |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
365 if (!contents) { | 377 if (!contents) { |
366 content::WebContents::CreateParams create_params( | 378 content::WebContents::CreateParams create_params( |
367 browser_context, NULL); | 379 browser_context, NULL); |
368 return content::WebContents::Create(create_params); | 380 return content::WebContents::Create(create_params); |
369 } | 381 } |
370 | 382 |
371 return contents; | 383 return contents; |
372 } | 384 } |
373 | 385 |
374 } // namespace views | 386 } // namespace views |
OLD | NEW |