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

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

Issue 2218883002: Record HTMLPluginElement::requestObject result. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: clean ups Created 4 years, 4 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
« no previous file with comments | « no previous file | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 27 matching lines...) Expand all
38 #include "core/html/PluginDocument.h" 38 #include "core/html/PluginDocument.h"
39 #include "core/input/EventHandler.h" 39 #include "core/input/EventHandler.h"
40 #include "core/inspector/ConsoleMessage.h" 40 #include "core/inspector/ConsoleMessage.h"
41 #include "core/layout/LayoutImage.h" 41 #include "core/layout/LayoutImage.h"
42 #include "core/layout/LayoutPart.h" 42 #include "core/layout/LayoutPart.h"
43 #include "core/loader/FrameLoaderClient.h" 43 #include "core/loader/FrameLoaderClient.h"
44 #include "core/loader/MixedContentChecker.h" 44 #include "core/loader/MixedContentChecker.h"
45 #include "core/page/Page.h" 45 #include "core/page/Page.h"
46 #include "core/page/scrolling/ScrollingCoordinator.h" 46 #include "core/page/scrolling/ScrollingCoordinator.h"
47 #include "core/plugins/PluginView.h" 47 #include "core/plugins/PluginView.h"
48 #include "platform/Histogram.h"
48 #include "platform/Logging.h" 49 #include "platform/Logging.h"
49 #include "platform/MIMETypeFromURL.h" 50 #include "platform/MIMETypeFromURL.h"
50 #include "platform/MIMETypeRegistry.h" 51 #include "platform/MIMETypeRegistry.h"
51 #include "platform/Widget.h" 52 #include "platform/Widget.h"
52 #include "platform/network/ResourceRequest.h" 53 #include "platform/network/ResourceRequest.h"
53 #include "platform/plugins/PluginData.h" 54 #include "platform/plugins/PluginData.h"
54 #include "public/platform/WebURLRequest.h" 55 #include "public/platform/WebURLRequest.h"
55 56
56 namespace blink { 57 namespace blink {
57 58
58 using namespace HTMLNames; 59 using namespace HTMLNames;
59 60
61 namespace {
62
63 // Used for histograms, do not change the order.
64 enum PluginRequestObjectResult {
65 PluginRequestObjectResultFailure = 0,
66 PluginRequestObjectResultSuccess = 1,
67 // Keep at the end.
68 PluginRequestObjectResultMax
69 };
70
71 } // anonymous namespace
72
60 HTMLPlugInElement::HTMLPlugInElement(const QualifiedName& tagName, Document& doc , bool createdByParser, PreferPlugInsForImagesOption preferPlugInsForImagesOptio n) 73 HTMLPlugInElement::HTMLPlugInElement(const QualifiedName& tagName, Document& doc , bool createdByParser, PreferPlugInsForImagesOption preferPlugInsForImagesOptio n)
61 : HTMLFrameOwnerElement(tagName, doc) 74 : HTMLFrameOwnerElement(tagName, doc)
62 , m_isDelayingLoadEvent(false) 75 , m_isDelayingLoadEvent(false)
63 // m_needsWidgetUpdate(!createdByParser) allows HTMLObjectElement to delay 76 // m_needsWidgetUpdate(!createdByParser) allows HTMLObjectElement to delay
64 // widget updates until after all children are parsed. For HTMLEmbedElement 77 // widget updates until after all children are parsed. For HTMLEmbedElement
65 // this delay is unnecessary, but it is simpler to make both classes share 78 // this delay is unnecessary, but it is simpler to make both classes share
66 // the same codepath in this class. 79 // the same codepath in this class.
67 , m_needsWidgetUpdate(!createdByParser) 80 , m_needsWidgetUpdate(!createdByParser)
68 , m_shouldPreferPlugInsForImages(preferPlugInsForImagesOption == ShouldPrefe rPlugInsForImages) 81 , m_shouldPreferPlugInsForImages(preferPlugInsForImagesOption == ShouldPrefe rPlugInsForImages)
69 { 82 {
(...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after
437 // that <object> uses depending on <param> values. 450 // that <object> uses depending on <param> values.
438 bool HTMLPlugInElement::wouldLoadAsNetscapePlugin(const String& url, const Strin g& serviceType) 451 bool HTMLPlugInElement::wouldLoadAsNetscapePlugin(const String& url, const Strin g& serviceType)
439 { 452 {
440 ASSERT(document().frame()); 453 ASSERT(document().frame());
441 KURL completedURL; 454 KURL completedURL;
442 if (!url.isEmpty()) 455 if (!url.isEmpty())
443 completedURL = document().completeURL(url); 456 completedURL = document().completeURL(url);
444 return document().frame()->loader().client()->getObjectContentType(completed URL, serviceType, shouldPreferPlugInsForImages()) == ObjectContentNetscapePlugin ; 457 return document().frame()->loader().client()->getObjectContentType(completed URL, serviceType, shouldPreferPlugInsForImages()) == ObjectContentNetscapePlugin ;
445 } 458 }
446 459
447 bool HTMLPlugInElement::requestObject(const String& url, const String& mimeType, const Vector<String>& paramNames, const Vector<String>& paramValues) 460 bool HTMLPlugInElement::requestObject(const String& url, const String& mimeType, const Vector<String>& paramNames, const Vector<String>& paramValues)
pdr. 2016/08/09 17:45:45 I don't think gotos are inherently bad but we rare
mlamouri (slow - plz ping) 2016/08/09 18:20:20 I don't think returning PLuginRequestObjectResult
448 { 461 {
462 bool result = false;
463 KURL completedURL = url.isEmpty() ? KURL() : document().completeURL(url);
464
449 if (url.isEmpty() && mimeType.isEmpty()) 465 if (url.isEmpty() && mimeType.isEmpty())
450 return false; 466 goto reportAndReturn;
451 467
452 if (protocolIsJavaScript(url)) 468 if (protocolIsJavaScript(url))
453 return false; 469 goto reportAndReturn;
454 470
455 KURL completedURL = url.isEmpty() ? KURL() : document().completeURL(url);
456 if (!allowedToLoadObject(completedURL, mimeType)) 471 if (!allowedToLoadObject(completedURL, mimeType))
457 return false; 472 goto reportAndReturn;
458 473
459 bool useFallback; 474 bool useFallback;
460 if (!shouldUsePlugin(completedURL, mimeType, hasFallbackContent(), useFallba ck)) { 475 if (!shouldUsePlugin(completedURL, mimeType, hasFallbackContent(), useFallba ck)) {
461 // If the plugin element already contains a subframe, 476 // If the plugin element already contains a subframe,
462 // loadOrRedirectSubframe will re-use it. Otherwise, it will create a 477 // loadOrRedirectSubframe will re-use it. Otherwise, it will create a
463 // new frame and set it as the LayoutPart's widget, causing what was 478 // new frame and set it as the LayoutPart's widget, causing what was
464 // previously in the widget to be torn down. 479 // previously in the widget to be torn down.
465 return loadOrRedirectSubframe(completedURL, getNameAttribute(), true); 480 result = loadOrRedirectSubframe(completedURL, getNameAttribute(), true);
481 goto reportAndReturn;
466 } 482 }
467 483
468 return loadPlugin(completedURL, mimeType, paramNames, paramValues, useFallba ck, true); 484 result = loadPlugin(completedURL, mimeType, paramNames, paramValues, useFall back, true);
485
486 reportAndReturn:
487 DEFINE_STATIC_LOCAL(EnumerationHistogram, resultHistogram, ("Plugin.RequestO bjectResult", PluginRequestObjectResultMax));
488 resultHistogram.count(result ? PluginRequestObjectResultSuccess : PluginRequ estObjectResultFailure);
489
490 return result;
469 } 491 }
470 492
471 bool HTMLPlugInElement::loadPlugin(const KURL& url, const String& mimeType, cons t Vector<String>& paramNames, const Vector<String>& paramValues, bool useFallbac k, bool requireLayoutObject) 493 bool HTMLPlugInElement::loadPlugin(const KURL& url, const String& mimeType, cons t Vector<String>& paramNames, const Vector<String>& paramValues, bool useFallbac k, bool requireLayoutObject)
472 { 494 {
473 if (!allowedToLoadPlugin(url, mimeType)) 495 if (!allowedToLoadPlugin(url, mimeType))
474 return false; 496 return false;
475 497
476 LocalFrame* frame = document().frame(); 498 LocalFrame* frame = document().frame();
477 if (!frame->loader().allowPlugins(AboutToInstantiatePlugin)) 499 if (!frame->loader().allowPlugins(AboutToInstantiatePlugin))
478 return false; 500 return false;
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
595 617
596 void HTMLPlugInElement::lazyReattachIfNeeded() 618 void HTMLPlugInElement::lazyReattachIfNeeded()
597 { 619 {
598 if (!useFallbackContent() && needsWidgetUpdate() && layoutObject() && !isIma geType()) { 620 if (!useFallbackContent() && needsWidgetUpdate() && layoutObject() && !isIma geType()) {
599 lazyReattachIfAttached(); 621 lazyReattachIfAttached();
600 setPersistedPluginWidget(nullptr); 622 setPersistedPluginWidget(nullptr);
601 } 623 }
602 } 624 }
603 625
604 } // namespace blink 626 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698