| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #ifndef CHROME_RENDERER_PLUGINS_PLUGIN_UMA_H_ | 5 #ifndef CHROME_RENDERER_PLUGINS_PLUGIN_UMA_H_ |
| 6 #define CHROME_RENDERER_PLUGINS_PLUGIN_UMA_H_ | 6 #define CHROME_RENDERER_PLUGINS_PLUGIN_UMA_H_ |
| 7 | 7 |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 | 9 |
| 10 #include <memory> | 10 #include <memory> |
| 11 #include <string> | 11 #include <string> |
| 12 | 12 |
| 13 #include "base/macros.h" | 13 #include "base/macros.h" |
| 14 #include "base/memory/singleton.h" | 14 #include "base/memory/singleton.h" |
| 15 #include "url/gurl.h" | 15 #include "url/gurl.h" |
| 16 | 16 |
| 17 // Used to send UMA data about missing plugins to UMA histogram server. Method | 17 // Used to send UMA data about missing plugins to UMA histogram server. Method |
| 18 // ReportPluginMissing should be called whenever plugin that is not available or | 18 // ReportPluginMissing should be called whenever plugin that is not available or |
| 19 // enabled is called. We try to determine plugin's type by requested mime type, | 19 // enabled is called. We try to determine plugin's type by requested mime type, |
| 20 // or, if mime type is unknown, by plugin's src url. | 20 // or, if mime type is unknown, by plugin's src url. |
| 21 class PluginUMAReporter { | 21 class PluginUMAReporter { |
| 22 public: | 22 public: |
| 23 enum ReportType { | 23 enum ReportType { |
| 24 MISSING_PLUGIN, | 24 MISSING_PLUGIN, |
| 25 DISABLED_PLUGIN | 25 DISABLED_PLUGIN, |
| 26 }; | 26 }; |
| 27 | 27 |
| 28 // Make sure the enum list in tools/histogram/histograms.xml is updated with | 28 // Make sure the enum list in tools/histogram/histograms.xml is updated with |
| 29 // any change in this list. | 29 // any change in this list. |
| 30 enum PluginType { | 30 enum PluginType { |
| 31 WINDOWS_MEDIA_PLAYER = 0, | 31 WINDOWS_MEDIA_PLAYER = 0, |
| 32 SILVERLIGHT = 1, | 32 SILVERLIGHT = 1, |
| 33 REALPLAYER = 2, | 33 REALPLAYER = 2, |
| 34 JAVA = 3, | 34 JAVA = 3, |
| 35 QUICKTIME = 4, | 35 QUICKTIME = 4, |
| 36 OTHER = 5, // This is obsolete and replaced by UNSUPPORTED_* types. | 36 OTHER = 5, // This is obsolete and replaced by UNSUPPORTED_* types. |
| 37 UNSUPPORTED_MIMETYPE, | 37 UNSUPPORTED_MIMETYPE, |
| 38 UNSUPPORTED_EXTENSION, | 38 UNSUPPORTED_EXTENSION, |
| 39 // NOTE: Add new unsupported types only immediately above this line. | 39 // NOTE: Add new unsupported types only immediately above this line. |
| 40 BROWSER_PLUGIN = 10, | 40 BROWSER_PLUGIN = 10, |
| 41 SHOCKWAVE_FLASH, | 41 SHOCKWAVE_FLASH, |
| 42 WIDEVINE_CDM, | 42 WIDEVINE_CDM, |
| 43 // NOTE: Add new plugin types only immediately above this line. | 43 // NOTE: Add new plugin types only immediately above this line. |
| 44 PLUGIN_TYPE_MAX | 44 PLUGIN_TYPE_MAX |
| 45 }; | 45 }; |
| 46 | 46 |
| 47 // Must be kept in sync with PDFLoadStatus enum in histograms.xml. |
| 48 // This enum should be treated as append-only. |
| 49 enum PDFLoadStatus { |
| 50 LOADED_FULL_PAGE_PDF_WITH_PDFIUM = 0, |
| 51 LOADED_EMBEDDED_PDF_WITH_PDFIUM = 1, |
| 52 SHOWED_DISABLED_PLUGIN_PLACEHOLDER_FOR_EMBEDDED_PDF = 2, |
| 53 PDF_LOAD_STATUS_COUNT |
| 54 }; |
| 55 |
| 47 // Sends UMA data, i.e. plugin's type. | 56 // Sends UMA data, i.e. plugin's type. |
| 48 class UMASender { | 57 class UMASender { |
| 49 public: | 58 public: |
| 50 virtual ~UMASender() {} | 59 virtual ~UMASender() {} |
| 51 virtual void SendPluginUMA(ReportType report_type, | 60 virtual void SendPluginUMA(ReportType report_type, |
| 52 PluginType plugin_type) = 0; | 61 PluginType plugin_type) = 0; |
| 53 }; | 62 }; |
| 54 | 63 |
| 55 // Returns singleton instance. | 64 // Returns singleton instance. |
| 56 static PluginUMAReporter* GetInstance(); | 65 static PluginUMAReporter* GetInstance(); |
| 57 | 66 |
| 67 static void ReportPDFLoadStatus(PDFLoadStatus status); |
| 68 |
| 58 void ReportPluginMissing(const std::string& plugin_mime_type, | 69 void ReportPluginMissing(const std::string& plugin_mime_type, |
| 59 const GURL& plugin_src); | 70 const GURL& plugin_src); |
| 60 | 71 |
| 61 void ReportPluginDisabled(const std::string& plugin_mime_type, | 72 void ReportPluginDisabled(const std::string& plugin_mime_type, |
| 62 const GURL& plugin_src); | 73 const GURL& plugin_src); |
| 63 | 74 |
| 64 private: | 75 private: |
| 65 friend struct base::DefaultSingletonTraits<PluginUMAReporter>; | 76 friend struct base::DefaultSingletonTraits<PluginUMAReporter>; |
| 66 friend class PluginUMATest; | 77 friend class PluginUMATest; |
| 67 | 78 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 82 PluginType SrcToPluginType(const GURL& src); | 93 PluginType SrcToPluginType(const GURL& src); |
| 83 // Converts plugin's mime type to plugin type. | 94 // Converts plugin's mime type to plugin type. |
| 84 PluginType MimeTypeToPluginType(const std::string& mime_type); | 95 PluginType MimeTypeToPluginType(const std::string& mime_type); |
| 85 | 96 |
| 86 std::unique_ptr<UMASender> report_sender_; | 97 std::unique_ptr<UMASender> report_sender_; |
| 87 | 98 |
| 88 DISALLOW_COPY_AND_ASSIGN(PluginUMAReporter); | 99 DISALLOW_COPY_AND_ASSIGN(PluginUMAReporter); |
| 89 }; | 100 }; |
| 90 | 101 |
| 91 #endif // CHROME_RENDERER_PLUGINS_PLUGIN_UMA_H_ | 102 #endif // CHROME_RENDERER_PLUGINS_PLUGIN_UMA_H_ |
| OLD | NEW |