Chromium Code Reviews| 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 views are made visible by content. | |
| 307 if (!is_embedding_fullscreen_widget_) | |
|
sky
2014/09/15 20:40:39
Why is this code any different when there is a ful
ananta
2014/09/15 21:21:09
Updated the comment to clarify why we should not b
| |
| 308 view_to_attach->Show(); | |
| 309 | |
| 304 holder_->Attach(view_to_attach); | 310 holder_->Attach(view_to_attach); |
| 305 | 311 |
| 306 // The view will not be focused automatically when it is attached, so we need | 312 // 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 | 313 // to pass on focus to it if the FocusManager thinks the view is focused. Note |
| 308 // that not every Widget has a focus manager. | 314 // that not every Widget has a focus manager. |
| 309 FocusManager* const focus_manager = GetFocusManager(); | 315 FocusManager* const focus_manager = GetFocusManager(); |
| 310 if (focus_manager && focus_manager->GetFocusedView() == this) | 316 if (focus_manager && focus_manager->GetFocusedView() == this) |
| 311 OnFocus(); | 317 OnFocus(); |
| 312 | 318 |
| 313 #if defined(OS_WIN) | 319 #if defined(OS_WIN) |
| 314 if (!is_embedding_fullscreen_widget_) { | 320 if (!is_embedding_fullscreen_widget_) { |
| 315 web_contents()->SetParentNativeViewAccessible( | 321 web_contents()->SetParentNativeViewAccessible( |
| 316 parent()->GetNativeViewAccessible()); | 322 parent()->GetNativeViewAccessible()); |
| 317 } | 323 } |
| 318 #endif | 324 #endif |
| 319 } | 325 } |
| 320 | 326 |
| 321 void WebView::DetachWebContents() { | 327 void WebView::DetachWebContents() { |
| 322 if (web_contents()) { | 328 if (web_contents()) { |
| 329 // Fullscreen views are shown/hidden by content. | |
| 330 if (!is_embedding_fullscreen_widget_) | |
| 331 web_contents()->GetNativeView()->Hide(); | |
| 332 | |
| 323 holder_->Detach(); | 333 holder_->Detach(); |
| 324 #if defined(OS_WIN) | 334 #if defined(OS_WIN) |
| 325 if (!is_embedding_fullscreen_widget_) | 335 if (!is_embedding_fullscreen_widget_) |
| 326 web_contents()->SetParentNativeViewAccessible(NULL); | 336 web_contents()->SetParentNativeViewAccessible(NULL); |
| 327 #endif | 337 #endif |
| 328 } | 338 } |
| 329 } | 339 } |
| 330 | 340 |
| 331 void WebView::ReattachForFullscreenChange(bool enter_fullscreen) { | 341 void WebView::ReattachForFullscreenChange(bool enter_fullscreen) { |
| 332 DCHECK(embed_fullscreen_widget_mode_enabled_); | 342 DCHECK(embed_fullscreen_widget_mode_enabled_); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 365 if (!contents) { | 375 if (!contents) { |
| 366 content::WebContents::CreateParams create_params( | 376 content::WebContents::CreateParams create_params( |
| 367 browser_context, NULL); | 377 browser_context, NULL); |
| 368 return content::WebContents::Create(create_params); | 378 return content::WebContents::Create(create_params); |
| 369 } | 379 } |
| 370 | 380 |
| 371 return contents; | 381 return contents; |
| 372 } | 382 } |
| 373 | 383 |
| 374 } // namespace views | 384 } // namespace views |
| OLD | NEW |