| 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 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 247 web_contents()->SetParentNativeViewAccessible( | 247 web_contents()->SetParentNativeViewAccessible( |
| 248 parent()->GetNativeViewAccessible()); | 248 parent()->GetNativeViewAccessible()); |
| 249 } | 249 } |
| 250 #endif | 250 #endif |
| 251 } | 251 } |
| 252 | 252 |
| 253 void WebView::DetachWebContents() { | 253 void WebView::DetachWebContents() { |
| 254 if (web_contents()) { | 254 if (web_contents()) { |
| 255 wcv_holder_->Detach(); | 255 wcv_holder_->Detach(); |
| 256 #if defined(OS_WIN) | 256 #if defined(OS_WIN) |
| 257 if (!is_embedding_fullscreen_widget_) { | 257 if (!is_embedding_fullscreen_widget_) |
| 258 #if !defined(USE_AURA) | |
| 259 // TODO(beng): This should either not be necessary, or be done implicitly | |
| 260 // by NativeViewHostWin on Detach(). As it stands, this is needed so that | |
| 261 // the of the detached contents knows to tell the renderer it's been | |
| 262 // hidden. | |
| 263 // | |
| 264 // Moving this out of here would also mean we wouldn't be potentially | |
| 265 // calling member functions on a half-destroyed WebContents. | |
| 266 ShowWindow(web_contents()->GetView()->GetNativeView(), SW_HIDE); | |
| 267 #else | |
| 268 web_contents()->SetParentNativeViewAccessible(NULL); | 258 web_contents()->SetParentNativeViewAccessible(NULL); |
| 269 #endif | 259 #endif |
| 270 } | |
| 271 #endif | |
| 272 } | 260 } |
| 273 } | 261 } |
| 274 | 262 |
| 275 void WebView::ReattachForFullscreenChange(bool enter_fullscreen) { | 263 void WebView::ReattachForFullscreenChange(bool enter_fullscreen) { |
| 276 DetachWebContents(); | 264 DetachWebContents(); |
| 277 is_embedding_fullscreen_widget_ = enter_fullscreen && | 265 is_embedding_fullscreen_widget_ = enter_fullscreen && |
| 278 web_contents() && web_contents()->GetFullscreenRenderWidgetHostView(); | 266 web_contents() && web_contents()->GetFullscreenRenderWidgetHostView(); |
| 279 AttachWebContents(); | 267 AttachWebContents(); |
| 280 } | 268 } |
| 281 | 269 |
| 282 content::WebContents* WebView::CreateWebContents( | 270 content::WebContents* WebView::CreateWebContents( |
| 283 content::BrowserContext* browser_context) { | 271 content::BrowserContext* browser_context) { |
| 284 content::WebContents* contents = NULL; | 272 content::WebContents* contents = NULL; |
| 285 if (ViewsDelegate::views_delegate) { | 273 if (ViewsDelegate::views_delegate) { |
| 286 contents = ViewsDelegate::views_delegate->CreateWebContents( | 274 contents = ViewsDelegate::views_delegate->CreateWebContents( |
| 287 browser_context, NULL); | 275 browser_context, NULL); |
| 288 } | 276 } |
| 289 | 277 |
| 290 if (!contents) { | 278 if (!contents) { |
| 291 content::WebContents::CreateParams create_params( | 279 content::WebContents::CreateParams create_params( |
| 292 browser_context, NULL); | 280 browser_context, NULL); |
| 293 return content::WebContents::Create(create_params); | 281 return content::WebContents::Create(create_params); |
| 294 } | 282 } |
| 295 | 283 |
| 296 return contents; | 284 return contents; |
| 297 } | 285 } |
| 298 | 286 |
| 299 } // namespace views | 287 } // namespace views |
| OLD | NEW |