Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "components/plugins/renderer/webview_plugin.h" | 5 #include "components/plugins/renderer/webview_plugin.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include "base/auto_reset.h" | 9 #include "base/auto_reset.h" |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 343 web_view_->MainFrame()->MainWorldScriptContext(); | 343 web_view_->MainFrame()->MainWorldScriptContext(); |
| 344 DCHECK(!context.IsEmpty()); | 344 DCHECK(!context.IsEmpty()); |
| 345 | 345 |
| 346 v8::Context::Scope context_scope(context); | 346 v8::Context::Scope context_scope(context); |
| 347 v8::Local<v8::Object> global = context->Global(); | 347 v8::Local<v8::Object> global = context->Global(); |
| 348 | 348 |
| 349 global->Set(gin::StringToV8(isolate, "plugin"), | 349 global->Set(gin::StringToV8(isolate, "plugin"), |
| 350 plugin_->delegate_->GetV8Handle(isolate)); | 350 plugin_->delegate_->GetV8Handle(isolate)); |
| 351 } | 351 } |
| 352 | 352 |
| 353 void WebViewPlugin::WebViewHelper::FrameDetached(blink::WebLocalFrame* frame, | |
| 354 DetachType type) { | |
| 355 if (type == DetachType::kRemove && frame->Parent()) | |
|
dcheng
2017/05/11 21:17:11
Actually I think this one doesn't need the RemoveC
sashab
2017/05/15 02:18:01
Removed, thanks.
| |
| 356 frame->Parent()->RemoveChild(frame); | |
| 357 | |
| 358 if (frame->FrameWidget()) | |
| 359 frame->FrameWidget()->Close(); | |
| 360 | |
| 361 frame->Close(); | |
| 362 } | |
| 363 | |
| 353 void WebViewPlugin::OnZoomLevelChanged() { | 364 void WebViewPlugin::OnZoomLevelChanged() { |
| 354 if (container_) { | 365 if (container_) { |
| 355 web_view()->SetZoomLevel( | 366 web_view()->SetZoomLevel( |
| 356 blink::WebView::ZoomFactorToZoomLevel(container_->PageZoomFactor())); | 367 blink::WebView::ZoomFactorToZoomLevel(container_->PageZoomFactor())); |
| 357 } | 368 } |
| 358 } | 369 } |
| 359 | 370 |
| 360 void WebViewPlugin::UpdatePluginForNewGeometry( | 371 void WebViewPlugin::UpdatePluginForNewGeometry( |
| 361 const blink::WebRect& window_rect, | 372 const blink::WebRect& window_rect, |
| 362 const blink::WebRect& unobscured_rect) { | 373 const blink::WebRect& unobscured_rect) { |
| 363 DCHECK(container_); | 374 DCHECK(container_); |
| 364 if (!delegate_) | 375 if (!delegate_) |
| 365 return; | 376 return; |
| 366 | 377 |
| 367 // The delegate may instantiate a new plugin. | 378 // The delegate may instantiate a new plugin. |
| 368 delegate_->OnUnobscuredRectUpdate(gfx::Rect(unobscured_rect)); | 379 delegate_->OnUnobscuredRectUpdate(gfx::Rect(unobscured_rect)); |
| 369 // The delegate may have dirtied style and layout of the WebView. | 380 // The delegate may have dirtied style and layout of the WebView. |
| 370 // See for example the resizePoster function in plugin_poster.html. | 381 // See for example the resizePoster function in plugin_poster.html. |
| 371 // Run the lifecycle now so that it is clean. | 382 // Run the lifecycle now so that it is clean. |
| 372 web_view()->UpdateAllLifecyclePhases(); | 383 web_view()->UpdateAllLifecyclePhases(); |
| 373 } | 384 } |
| OLD | NEW |