Chromium Code Reviews| 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 #include "chrome/renderer/plugins/plugin_uma.h" | 5 #include "chrome/renderer/plugins/plugin_uma.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <cstring> | 8 #include <cstring> |
| 9 | 9 |
| 10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
| 11 #include "base/string_util.h" | 11 #include "base/string_util.h" |
| 12 #include "content/public/common/content_constants.h" | |
| 12 | 13 |
| 13 namespace { | 14 namespace { |
| 14 | 15 |
| 15 // String we will use to convert mime tyoe to plugin type. | 16 // String we will use to convert mime type to plugin type. |
| 16 const char kWindowsMediaPlayerType[] = "application/x-mplayer2"; | 17 const char kWindowsMediaPlayerType[] = "application/x-mplayer2"; |
| 17 const char kSilverlightTypePrefix[] = "application/x-silverlight"; | 18 const char kSilverlightTypePrefix[] = "application/x-silverlight"; |
| 18 const char kRealPlayerTypePrefix[] = "audio/x-pn-realaudio"; | 19 const char kRealPlayerTypePrefix[] = "audio/x-pn-realaudio"; |
| 19 const char kJavaTypeSubstring[] = "application/x-java-applet"; | 20 const char kJavaTypeSubstring[] = "application/x-java-applet"; |
| 20 const char kQuickTimeType[] = "video/quicktime"; | 21 const char kQuickTimeType[] = "video/quicktime"; |
| 22 const char kFlashPluginSwfMimeType[] = "application/x-shockwave-flash"; | |
|
ddorwin
2013/04/05 05:32:17
Are we allowed to include webkit/plugins/plugin_co
Bernhard Bauer
2013/04/05 13:29:10
Yes.
xhwang
2013/04/05 19:00:09
Done.
| |
| 23 const char kFlashPluginSplMimeType[] = "application/futuresplash"; | |
| 24 const char kWidevineCDMType[] = "application/x-ppapi-widevine-cdm"; | |
|
ddorwin
2013/04/05 05:32:17
Should we include widevine_cdm_common.h?
xhwang
2013/04/05 19:00:09
Done.
| |
| 21 | 25 |
| 22 // Arrays containing file extensions connected with specific plugins. | 26 // Arrays containing file extensions connected with specific plugins. |
| 23 // The arrays must be sorted because binary search is used on them. | 27 // The arrays must be sorted because binary search is used on them. |
| 24 const char* kWindowsMediaPlayerExtensions[] = { | 28 const char* kWindowsMediaPlayerExtensions[] = { |
| 25 ".asx" | 29 ".asx" |
| 26 }; | 30 }; |
| 27 | 31 |
| 28 const char* kRealPlayerExtensions[] = { | 32 const char* kRealPlayerExtensions[] = { |
| 29 ".ra", | 33 ".ra", |
| 30 ".ram", | 34 ".ram", |
| 31 ".rm", | 35 ".rm", |
| 32 ".rmm", | 36 ".rmm", |
| 33 ".rmp", | 37 ".rmp", |
| 34 ".rpm" | 38 ".rpm" |
| 35 }; | 39 }; |
| 36 | 40 |
| 37 const char* kQuickTimeExtensions[] = { | 41 const char* kQuickTimeExtensions[] = { |
| 38 ".moov", | 42 ".moov", |
| 39 ".mov", | 43 ".mov", |
| 40 ".qif", | 44 ".qif", |
| 41 ".qt", | 45 ".qt", |
| 42 ".qti", | 46 ".qti", |
| 43 ".qtif" | 47 ".qtif" |
| 44 }; | 48 }; |
| 45 | 49 |
| 50 const char* kShockwaveFlashExtensions[] = { | |
| 51 ".swf", | |
| 52 ".spl" | |
| 53 }; | |
| 54 | |
| 46 } // namespace. | 55 } // namespace. |
| 47 | 56 |
| 48 class UMASenderImpl : public MissingPluginReporter::UMASender { | 57 class UMASenderImpl : public MissingPluginReporter::UMASender { |
| 49 virtual void SendPluginUMA(MissingPluginReporter::PluginType plugin_type) | 58 virtual void SendPluginUMA(MissingPluginReporter::PluginType plugin_type) |
| 50 OVERRIDE; | 59 OVERRIDE; |
| 51 }; | 60 }; |
| 52 | 61 |
| 53 void UMASenderImpl::SendPluginUMA( | 62 void UMASenderImpl::SendPluginUMA( |
| 54 MissingPluginReporter::PluginType plugin_type) { | 63 MissingPluginReporter::PluginType plugin_type) { |
| 55 UMA_HISTOGRAM_ENUMERATION("Plugin.MissingPlugins", | 64 UMA_HISTOGRAM_ENUMERATION("Plugin.MissingPlugins", |
| 56 plugin_type, | 65 plugin_type, |
| 57 MissingPluginReporter::OTHER); | 66 MissingPluginReporter::PLUGIN_TYPE_MAX); |
| 58 } | 67 } |
| 59 | 68 |
| 60 // static. | 69 // static. |
| 61 MissingPluginReporter* MissingPluginReporter::GetInstance() { | 70 MissingPluginReporter* MissingPluginReporter::GetInstance() { |
| 62 return Singleton<MissingPluginReporter>::get(); | 71 return Singleton<MissingPluginReporter>::get(); |
| 63 } | 72 } |
| 64 | 73 |
| 65 void MissingPluginReporter::ReportPluginMissing( | 74 void MissingPluginReporter::ReportPluginMissing( |
| 66 std::string plugin_mime_type, const GURL& plugin_src) { | 75 std::string plugin_mime_type, const GURL& plugin_src) { |
| 67 PluginType plugin_type; | 76 PluginType plugin_type; |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 130 file_extension.c_str())) { | 139 file_extension.c_str())) { |
| 131 return QUICKTIME; | 140 return QUICKTIME; |
| 132 } | 141 } |
| 133 | 142 |
| 134 if (CStringArrayContainsCString(kRealPlayerExtensions, | 143 if (CStringArrayContainsCString(kRealPlayerExtensions, |
| 135 arraysize(kRealPlayerExtensions), | 144 arraysize(kRealPlayerExtensions), |
| 136 file_extension.c_str())) { | 145 file_extension.c_str())) { |
| 137 return REALPLAYER; | 146 return REALPLAYER; |
| 138 } | 147 } |
| 139 | 148 |
| 140 return OTHER; | 149 if (CStringArrayContainsCString(kShockwaveFlashExtensions, |
| 150 arraysize(kShockwaveFlashExtensions), | |
| 151 file_extension.c_str())) { | |
| 152 return SHOCKWAVE_FLASH; | |
| 153 } | |
| 154 | |
| 155 return UNSUPPORTED_EXTENSION; | |
| 141 } | 156 } |
| 142 | 157 |
| 143 MissingPluginReporter::PluginType MissingPluginReporter::MimeTypeToPluginType( | 158 MissingPluginReporter::PluginType MissingPluginReporter::MimeTypeToPluginType( |
| 144 const std::string& mime_type) { | 159 const std::string& mime_type) { |
| 145 if (strcmp(mime_type.c_str(), kWindowsMediaPlayerType) == 0) | 160 if (mime_type == kWindowsMediaPlayerType) |
| 146 return WINDOWS_MEDIA_PLAYER; | 161 return WINDOWS_MEDIA_PLAYER; |
| 147 | 162 |
| 148 size_t prefix_length = strlen(kSilverlightTypePrefix); | 163 size_t prefix_length = strlen(kSilverlightTypePrefix); |
| 149 if (strncmp(mime_type.c_str(), kSilverlightTypePrefix, prefix_length) == 0) | 164 if (strncmp(mime_type.c_str(), kSilverlightTypePrefix, prefix_length) == 0) |
| 150 return SILVERLIGHT; | 165 return SILVERLIGHT; |
| 151 | 166 |
| 152 prefix_length = strlen(kRealPlayerTypePrefix); | 167 prefix_length = strlen(kRealPlayerTypePrefix); |
| 153 if (strncmp(mime_type.c_str(), kRealPlayerTypePrefix, prefix_length) == 0) | 168 if (strncmp(mime_type.c_str(), kRealPlayerTypePrefix, prefix_length) == 0) |
| 154 return REALPLAYER; | 169 return REALPLAYER; |
| 155 | 170 |
| 156 if (strstr(mime_type.c_str(), kJavaTypeSubstring)) | 171 if (strstr(mime_type.c_str(), kJavaTypeSubstring)) |
| 157 return JAVA; | 172 return JAVA; |
| 158 | 173 |
| 159 if (strcmp(mime_type.c_str(), kQuickTimeType) == 0) | 174 if (mime_type == kQuickTimeType) |
| 160 return QUICKTIME; | 175 return QUICKTIME; |
| 161 | 176 |
| 162 return OTHER; | 177 if (mime_type == content::kBrowserPluginMimeType) |
| 178 return BROWSER_PLUGIN; | |
| 179 | |
| 180 if (mime_type == kFlashPluginSwfMimeType || | |
| 181 mime_type == kFlashPluginSplMimeType) { | |
| 182 return SHOCKWAVE_FLASH; | |
| 183 } | |
| 184 | |
| 185 if (mime_type == kWidevineCDMType) | |
| 186 return WIDEVINE_CDM; | |
| 187 | |
| 188 return UNSUPPORTED_MIMETYPE; | |
| 163 } | 189 } |
| 164 | |
| OLD | NEW |