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" |
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
296 if (!GetWidget() || !web_contents()) | 296 if (!GetWidget() || !web_contents()) |
297 return; | 297 return; |
298 | 298 |
299 const gfx::NativeView view_to_attach = is_embedding_fullscreen_widget_ ? | 299 const gfx::NativeView view_to_attach = is_embedding_fullscreen_widget_ ? |
300 web_contents()->GetFullscreenRenderWidgetHostView()->GetNativeView() : | 300 web_contents()->GetFullscreenRenderWidgetHostView()->GetNativeView() : |
301 web_contents()->GetNativeView(); | 301 web_contents()->GetNativeView(); |
302 OnBoundsChanged(bounds()); | 302 OnBoundsChanged(bounds()); |
303 if (holder_->native_view() == view_to_attach) | 303 if (holder_->native_view() == view_to_attach) |
304 return; | 304 return; |
305 | 305 |
| 306 // The WCV needs to be parented before making it visible. |
| 307 holder_->Attach(view_to_attach); |
| 308 |
306 // Fullscreen widgets are not parented by a WebContentsView. Their visibility | 309 // Fullscreen widgets are not parented by a WebContentsView. Their visibility |
307 // is controlled by content i.e. (RenderWidgetHost) | 310 // is controlled by content i.e. (RenderWidgetHost) |
308 if (!is_embedding_fullscreen_widget_) | 311 if (!is_embedding_fullscreen_widget_) |
309 view_to_attach->Show(); | 312 view_to_attach->Show(); |
310 | 313 |
311 holder_->Attach(view_to_attach); | |
312 | |
313 // The view will not be focused automatically when it is attached, so we need | 314 // 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 | 315 // to pass on focus to it if the FocusManager thinks the view is focused. Note |
315 // that not every Widget has a focus manager. | 316 // that not every Widget has a focus manager. |
316 FocusManager* const focus_manager = GetFocusManager(); | 317 FocusManager* const focus_manager = GetFocusManager(); |
317 if (focus_manager && focus_manager->GetFocusedView() == this) | 318 if (focus_manager && focus_manager->GetFocusedView() == this) |
318 OnFocus(); | 319 OnFocus(); |
319 | 320 |
320 #if defined(OS_WIN) | 321 #if defined(OS_WIN) |
321 if (!is_embedding_fullscreen_widget_) { | 322 if (!is_embedding_fullscreen_widget_) { |
322 web_contents()->SetParentNativeViewAccessible( | 323 web_contents()->SetParentNativeViewAccessible( |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
377 if (!contents) { | 378 if (!contents) { |
378 content::WebContents::CreateParams create_params( | 379 content::WebContents::CreateParams create_params( |
379 browser_context, NULL); | 380 browser_context, NULL); |
380 return content::WebContents::Create(create_params); | 381 return content::WebContents::Create(create_params); |
381 } | 382 } |
382 | 383 |
383 return contents; | 384 return contents; |
384 } | 385 } |
385 | 386 |
386 } // namespace views | 387 } // namespace views |
OLD | NEW |