Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(278)

Side by Side Diff: third_party/WebKit/Source/core/html/HTMLPlugInElement.cpp

Issue 2719333002: second stage
Patch Set: Need to get around resource loading without web/ Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /** 1 /**
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) 3 * (C) 1999 Antti Koivisto (koivisto@kde.org)
4 * (C) 2000 Stefan Schimanski (1Stein@gmx.de) 4 * (C) 2000 Stefan Schimanski (1Stein@gmx.de)
5 * Copyright (C) 2004, 2005, 2006 Apple Computer, Inc. 5 * Copyright (C) 2004, 2005, 2006 Apple Computer, Inc.
6 * 6 *
7 * This library is free software; you can redistribute it and/or 7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Library General Public 8 * modify it under the terms of the GNU Library General Public
9 * License as published by the Free Software Foundation; either 9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version. 10 * version 2 of the License, or (at your option) any later version.
(...skipping 11 matching lines...) Expand all
22 22
23 #include "core/html/HTMLPlugInElement.h" 23 #include "core/html/HTMLPlugInElement.h"
24 24
25 #include "bindings/core/v8/ScriptController.h" 25 #include "bindings/core/v8/ScriptController.h"
26 #include "core/CSSPropertyNames.h" 26 #include "core/CSSPropertyNames.h"
27 #include "core/HTMLNames.h" 27 #include "core/HTMLNames.h"
28 #include "core/dom/Document.h" 28 #include "core/dom/Document.h"
29 #include "core/dom/Node.h" 29 #include "core/dom/Node.h"
30 #include "core/dom/shadow/ShadowRoot.h" 30 #include "core/dom/shadow/ShadowRoot.h"
31 #include "core/events/Event.h" 31 #include "core/events/Event.h"
32 #include "core/frame/Frame.h"
32 #include "core/frame/FrameView.h" 33 #include "core/frame/FrameView.h"
33 #include "core/frame/LocalFrame.h" 34 #include "core/frame/LocalFrame.h"
34 #include "core/frame/Settings.h" 35 #include "core/frame/Settings.h"
35 #include "core/frame/csp/ContentSecurityPolicy.h" 36 #include "core/frame/csp/ContentSecurityPolicy.h"
36 #include "core/html/HTMLContentElement.h" 37 #include "core/html/HTMLContentElement.h"
37 #include "core/html/HTMLImageLoader.h" 38 #include "core/html/HTMLImageLoader.h"
38 #include "core/html/PluginDocument.h" 39 #include "core/html/PluginDocument.h"
39 #include "core/input/EventHandler.h" 40 #include "core/input/EventHandler.h"
40 #include "core/inspector/ConsoleMessage.h" 41 #include "core/inspector/ConsoleMessage.h"
41 #include "core/layout/LayoutImage.h" 42 #include "core/layout/LayoutImage.h"
42 #include "core/layout/LayoutPart.h" 43 #include "core/layout/LayoutPart.h"
43 #include "core/layout/api/LayoutEmbeddedItem.h" 44 #include "core/layout/api/LayoutEmbeddedItem.h"
44 #include "core/loader/FrameLoaderClient.h" 45 #include "core/loader/FrameLoaderClient.h"
45 #include "core/loader/MixedContentChecker.h" 46 #include "core/loader/MixedContentChecker.h"
46 #include "core/page/Page.h" 47 #include "core/page/Page.h"
47 #include "core/page/scrolling/ScrollingCoordinator.h" 48 #include "core/page/scrolling/ScrollingCoordinator.h"
49 #include "core/plugins/PluginClient.h"
48 #include "core/plugins/PluginView.h" 50 #include "core/plugins/PluginView.h"
49 #include "platform/Histogram.h" 51 #include "platform/Histogram.h"
50 #include "platform/Widget.h" 52 #include "platform/Widget.h"
51 #include "platform/network/ResourceRequest.h" 53 #include "platform/network/ResourceRequest.h"
52 #include "platform/network/mime/MIMETypeFromURL.h" 54 #include "platform/network/mime/MIMETypeFromURL.h"
53 #include "platform/network/mime/MIMETypeRegistry.h" 55 #include "platform/network/mime/MIMETypeRegistry.h"
54 #include "platform/plugins/PluginData.h" 56 #include "platform/plugins/PluginData.h"
55 #include "public/platform/WebURLRequest.h" 57 #include "public/platform/WebURLRequest.h"
56 58
57 namespace blink { 59 namespace blink {
(...skipping 28 matching lines...) Expand all
86 ShouldPreferPlugInsForImages) {} 88 ShouldPreferPlugInsForImages) {}
87 89
88 HTMLPlugInElement::~HTMLPlugInElement() { 90 HTMLPlugInElement::~HTMLPlugInElement() {
89 DCHECK(!m_pluginWrapper); // cleared in detachLayoutTree() 91 DCHECK(!m_pluginWrapper); // cleared in detachLayoutTree()
90 DCHECK(!m_isDelayingLoadEvent); 92 DCHECK(!m_isDelayingLoadEvent);
91 } 93 }
92 94
93 DEFINE_TRACE(HTMLPlugInElement) { 95 DEFINE_TRACE(HTMLPlugInElement) {
94 visitor->trace(m_imageLoader); 96 visitor->trace(m_imageLoader);
95 visitor->trace(m_persistedPluginWidget); 97 visitor->trace(m_persistedPluginWidget);
98 visitor->trace(m_pluginClient);
96 HTMLFrameOwnerElement::trace(visitor); 99 HTMLFrameOwnerElement::trace(visitor);
97 } 100 }
98 101
99 void HTMLPlugInElement::setPersistedPluginWidget(Widget* widget) { 102 void HTMLPlugInElement::setPersistedPluginWidget(Widget* widget) {
100 if (m_persistedPluginWidget == widget) 103 if (m_persistedPluginWidget == widget)
101 return; 104 return;
102 if (m_persistedPluginWidget) { 105 if (m_persistedPluginWidget) {
103 if (m_persistedPluginWidget->isPluginView()) { 106 if (m_persistedPluginWidget->isPluginView()) {
104 m_persistedPluginWidget->hide(); 107 m_persistedPluginWidget->hide();
105 disposeWidgetSoon(m_persistedPluginWidget.release()); 108 disposeWidgetSoon(m_persistedPluginWidget.release());
(...skipping 23 matching lines...) Expand all
129 bool useFallback; 132 bool useFallback;
130 if (!shouldUsePlugin(completedURL, mimeType, hasFallbackContent(), 133 if (!shouldUsePlugin(completedURL, mimeType, hasFallbackContent(),
131 useFallback)) { 134 useFallback)) {
132 // If the plugin element already contains a subframe, 135 // If the plugin element already contains a subframe,
133 // loadOrRedirectSubframe will re-use it. Otherwise, it will create a 136 // loadOrRedirectSubframe will re-use it. Otherwise, it will create a
134 // new frame and set it as the LayoutPart's widget, causing what was 137 // new frame and set it as the LayoutPart's widget, causing what was
135 // previously in the widget to be torn down. 138 // previously in the widget to be torn down.
136 return loadOrRedirectSubframe(completedURL, getNameAttribute(), true); 139 return loadOrRedirectSubframe(completedURL, getNameAttribute(), true);
137 } 140 }
138 141
142 if (loadFrame(completedURL))
143 return true;
144
139 return loadPlugin(completedURL, mimeType, paramNames, paramValues, 145 return loadPlugin(completedURL, mimeType, paramNames, paramValues,
140 useFallback, true); 146 useFallback, true);
141 } 147 }
142 148
143 bool HTMLPlugInElement::canProcessDrag() const { 149 bool HTMLPlugInElement::canProcessDrag() const {
144 return pluginWidget() && pluginWidget()->isPluginView() && 150 return pluginWidget() && pluginWidget()->isPluginView() &&
145 toPluginView(pluginWidget())->canProcessDrag(); 151 toPluginView(pluginWidget())->canProcessDrag();
146 } 152 }
147 153
148 bool HTMLPlugInElement::canStartSelection() const { 154 bool HTMLPlugInElement::canStartSelection() const {
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
315 321
316 SharedPersistent<v8::Object>* HTMLPlugInElement::pluginWrapper() { 322 SharedPersistent<v8::Object>* HTMLPlugInElement::pluginWrapper() {
317 LocalFrame* frame = document().frame(); 323 LocalFrame* frame = document().frame();
318 if (!frame) 324 if (!frame)
319 return nullptr; 325 return nullptr;
320 326
321 // If the host dynamically turns off JavaScript (or Java) we will still 327 // If the host dynamically turns off JavaScript (or Java) we will still
322 // return the cached allocated Bindings::Instance. Not supporting this 328 // return the cached allocated Bindings::Instance. Not supporting this
323 // edge-case is OK. 329 // edge-case is OK.
324 if (!m_pluginWrapper) { 330 if (!m_pluginWrapper) {
331 if (m_pluginClient) {
332 m_pluginWrapper = frame->script().createPluginWrapper(m_pluginClient);
333 return m_pluginWrapper.get();
334 }
335
325 Widget* plugin; 336 Widget* plugin;
326 337
327 if (m_persistedPluginWidget) 338 if (m_persistedPluginWidget)
328 plugin = m_persistedPluginWidget.get(); 339 plugin = m_persistedPluginWidget.get();
329 else 340 else
330 plugin = pluginWidget(); 341 plugin = pluginWidget();
331 342
332 if (plugin) 343 if (plugin && plugin->isPluginView()) {
333 m_pluginWrapper = frame->script().createPluginWrapper(plugin); 344 m_pluginWrapper = frame->script().createPluginWrapper(plugin);
345 }
334 } 346 }
335 return m_pluginWrapper.get(); 347 return m_pluginWrapper.get();
336 } 348 }
337 349
338 Widget* HTMLPlugInElement::pluginWidget() const { 350 Widget* HTMLPlugInElement::pluginWidget() const {
339 if (LayoutPart* layoutPart = layoutPartForJSBindings()) 351 if (LayoutPart* layoutPart = layoutPartForJSBindings())
340 return layoutPart->widget(); 352 return layoutPart->widget();
341 return nullptr; 353 return nullptr;
342 } 354 }
343 355
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
491 503
492 DEFINE_STATIC_LOCAL( 504 DEFINE_STATIC_LOCAL(
493 EnumerationHistogram, resultHistogram, 505 EnumerationHistogram, resultHistogram,
494 ("Plugin.RequestObjectResult", PluginRequestObjectResultMax)); 506 ("Plugin.RequestObjectResult", PluginRequestObjectResultMax));
495 resultHistogram.count(result ? PluginRequestObjectResultSuccess 507 resultHistogram.count(result ? PluginRequestObjectResultSuccess
496 : PluginRequestObjectResultFailure); 508 : PluginRequestObjectResultFailure);
497 509
498 return result; 510 return result;
499 } 511 }
500 512
513 bool HTMLPlugInElement::loadFrame(const KURL& url) {
514 LocalFrame* frame = document().frame();
515 if (!frame)
516 return false;
517 m_pluginClient = frame->loader().client()->createPluginClient(
518 this, url, mimeTypeFromURL(url));
519 return m_pluginClient;
520 }
521
501 bool HTMLPlugInElement::loadPlugin(const KURL& url, 522 bool HTMLPlugInElement::loadPlugin(const KURL& url,
502 const String& mimeType, 523 const String& mimeType,
503 const Vector<String>& paramNames, 524 const Vector<String>& paramNames,
504 const Vector<String>& paramValues, 525 const Vector<String>& paramValues,
505 bool useFallback, 526 bool useFallback,
506 bool requireLayoutObject) { 527 bool requireLayoutObject) {
507 if (!allowedToLoadPlugin(url, mimeType)) 528 if (!allowedToLoadPlugin(url, mimeType))
508 return false; 529 return false;
509 530
510 LocalFrame* frame = document().frame(); 531 LocalFrame* frame = document().frame();
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
646 667
647 void HTMLPlugInElement::lazyReattachIfNeeded() { 668 void HTMLPlugInElement::lazyReattachIfNeeded() {
648 if (!useFallbackContent() && needsWidgetUpdate() && layoutObject() && 669 if (!useFallbackContent() && needsWidgetUpdate() && layoutObject() &&
649 !isImageType()) { 670 !isImageType()) {
650 lazyReattachIfAttached(); 671 lazyReattachIfAttached();
651 setPersistedPluginWidget(nullptr); 672 setPersistedPluginWidget(nullptr);
652 } 673 }
653 } 674 }
654 675
655 } // namespace blink 676 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/html/HTMLPlugInElement.h ('k') | third_party/WebKit/Source/core/loader/EmptyClients.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698