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