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

Side by Side Diff: chrome/renderer/plugins/plugin_uma.cc

Issue 13601002: Report UMA for Shockwave Flash and Widevine CDM. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase and updated unittest. Created 7 years, 8 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 | Annotate | Revision Log
« no previous file with comments | « chrome/renderer/plugins/plugin_uma.h ('k') | chrome/renderer/plugins/plugin_uma_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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"
13 #include "third_party/widevine/cdm/widevine_cdm_common.h"
14 #include "webkit/plugins/plugin_constants.h"
12 15
13 namespace { 16 namespace {
14 17
15 // String we will use to convert mime type to plugin type. 18 // String we will use to convert mime type to plugin type.
16 const char kWindowsMediaPlayerType[] = "application/x-mplayer2"; 19 const char kWindowsMediaPlayerType[] = "application/x-mplayer2";
17 const char kSilverlightTypePrefix[] = "application/x-silverlight"; 20 const char kSilverlightTypePrefix[] = "application/x-silverlight";
18 const char kRealPlayerTypePrefix[] = "audio/x-pn-realaudio"; 21 const char kRealPlayerTypePrefix[] = "audio/x-pn-realaudio";
19 const char kJavaTypeSubstring[] = "application/x-java-applet"; 22 const char kJavaTypeSubstring[] = "application/x-java-applet";
20 const char kQuickTimeType[] = "video/quicktime"; 23 const char kQuickTimeType[] = "video/quicktime";
21 24
22 // Arrays containing file extensions connected with specific plugins. 25 // Arrays containing file extensions connected with specific plugins.
23 // The arrays must be sorted because binary search is used on them. 26 // Note: THE ARRAYS MUST BE SORTED BECAUSE BINARY SEARCH IS USED ON THEM!
24 const char* kWindowsMediaPlayerExtensions[] = { 27 const char* kWindowsMediaPlayerExtensions[] = {
25 ".asx" 28 ".asx"
26 }; 29 };
27 30
28 const char* kRealPlayerExtensions[] = { 31 const char* kRealPlayerExtensions[] = {
29 ".ra", 32 ".ra",
30 ".ram", 33 ".ram",
31 ".rm", 34 ".rm",
32 ".rmm", 35 ".rmm",
33 ".rmp", 36 ".rmp",
34 ".rpm" 37 ".rpm"
35 }; 38 };
36 39
37 const char* kQuickTimeExtensions[] = { 40 const char* kQuickTimeExtensions[] = {
38 ".moov", 41 ".moov",
39 ".mov", 42 ".mov",
40 ".qif", 43 ".qif",
41 ".qt", 44 ".qt",
42 ".qti", 45 ".qti",
43 ".qtif" 46 ".qtif"
44 }; 47 };
45 48
49 const char* kShockwaveFlashExtensions[] = {
50 ".spl",
51 ".swf"
52 };
53
46 } // namespace. 54 } // namespace.
47 55
48 class UMASenderImpl : public PluginUMAReporter::UMASender { 56 class UMASenderImpl : public PluginUMAReporter::UMASender {
49 virtual void SendPluginUMA( 57 virtual void SendPluginUMA(
50 PluginUMAReporter::ReportType report_type, 58 PluginUMAReporter::ReportType report_type,
51 PluginUMAReporter::PluginType plugin_type) OVERRIDE; 59 PluginUMAReporter::PluginType plugin_type) OVERRIDE;
52 }; 60 };
53 61
54 void UMASenderImpl::SendPluginUMA(PluginUMAReporter::ReportType report_type, 62 void UMASenderImpl::SendPluginUMA(PluginUMAReporter::ReportType report_type,
55 PluginUMAReporter::PluginType plugin_type) { 63 PluginUMAReporter::PluginType plugin_type) {
56 // UMA_HISTOGRAM_ENUMERATION requires constant histogram name. Use string 64 // UMA_HISTOGRAM_ENUMERATION requires constant histogram name. Use string
57 // constants explicitly instead of trying to use variables for names. 65 // constants explicitly instead of trying to use variables for names.
58 switch (report_type) { 66 switch (report_type) {
59 case PluginUMAReporter::MISSING_PLUGIN: 67 case PluginUMAReporter::MISSING_PLUGIN:
60 UMA_HISTOGRAM_ENUMERATION("Plugin.MissingPlugins", 68 UMA_HISTOGRAM_ENUMERATION("Plugin.MissingPlugins",
61 plugin_type, 69 plugin_type,
62 PluginUMAReporter::OTHER); 70 PluginUMAReporter::PLUGIN_TYPE_MAX);
63 break; 71 break;
64 case PluginUMAReporter::DISABLED_PLUGIN: 72 case PluginUMAReporter::DISABLED_PLUGIN:
65 UMA_HISTOGRAM_ENUMERATION("Plugin.DisabledPlugins", 73 UMA_HISTOGRAM_ENUMERATION("Plugin.DisabledPlugins",
66 plugin_type, 74 plugin_type,
67 PluginUMAReporter::OTHER); 75 PluginUMAReporter::PLUGIN_TYPE_MAX);
68 break; 76 break;
69 default: 77 default:
70 NOTREACHED(); 78 NOTREACHED();
71 } 79 }
72 } 80 }
73 81
74 // static. 82 // static.
75 PluginUMAReporter* PluginUMAReporter::GetInstance() { 83 PluginUMAReporter* PluginUMAReporter::GetInstance() {
76 return Singleton<PluginUMAReporter>::get(); 84 return Singleton<PluginUMAReporter>::get();
77 } 85 }
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 file_extension.c_str())) { 154 file_extension.c_str())) {
147 return QUICKTIME; 155 return QUICKTIME;
148 } 156 }
149 157
150 if (CStringArrayContainsCString(kRealPlayerExtensions, 158 if (CStringArrayContainsCString(kRealPlayerExtensions,
151 arraysize(kRealPlayerExtensions), 159 arraysize(kRealPlayerExtensions),
152 file_extension.c_str())) { 160 file_extension.c_str())) {
153 return REALPLAYER; 161 return REALPLAYER;
154 } 162 }
155 163
156 return OTHER; 164 if (CStringArrayContainsCString(kShockwaveFlashExtensions,
165 arraysize(kShockwaveFlashExtensions),
166 file_extension.c_str())) {
167 return SHOCKWAVE_FLASH;
168 }
169
170 return UNSUPPORTED_EXTENSION;
157 } 171 }
158 172
159 PluginUMAReporter::PluginType PluginUMAReporter::MimeTypeToPluginType( 173 PluginUMAReporter::PluginType PluginUMAReporter::MimeTypeToPluginType(
160 const std::string& mime_type) { 174 const std::string& mime_type) {
161 if (strcmp(mime_type.c_str(), kWindowsMediaPlayerType) == 0) 175 if (mime_type == kWindowsMediaPlayerType)
162 return WINDOWS_MEDIA_PLAYER; 176 return WINDOWS_MEDIA_PLAYER;
163 177
164 size_t prefix_length = strlen(kSilverlightTypePrefix); 178 size_t prefix_length = strlen(kSilverlightTypePrefix);
165 if (strncmp(mime_type.c_str(), kSilverlightTypePrefix, prefix_length) == 0) 179 if (strncmp(mime_type.c_str(), kSilverlightTypePrefix, prefix_length) == 0)
166 return SILVERLIGHT; 180 return SILVERLIGHT;
167 181
168 prefix_length = strlen(kRealPlayerTypePrefix); 182 prefix_length = strlen(kRealPlayerTypePrefix);
169 if (strncmp(mime_type.c_str(), kRealPlayerTypePrefix, prefix_length) == 0) 183 if (strncmp(mime_type.c_str(), kRealPlayerTypePrefix, prefix_length) == 0)
170 return REALPLAYER; 184 return REALPLAYER;
171 185
172 if (strstr(mime_type.c_str(), kJavaTypeSubstring)) 186 if (strstr(mime_type.c_str(), kJavaTypeSubstring))
173 return JAVA; 187 return JAVA;
174 188
175 if (strcmp(mime_type.c_str(), kQuickTimeType) == 0) 189 if (mime_type == kQuickTimeType)
176 return QUICKTIME; 190 return QUICKTIME;
177 191
178 return OTHER; 192 if (mime_type == content::kBrowserPluginMimeType)
193 return BROWSER_PLUGIN;
194
195 if (mime_type == kFlashPluginSwfMimeType ||
196 mime_type == kFlashPluginSplMimeType) {
197 return SHOCKWAVE_FLASH;
198 }
199
200 if (mime_type == kWidevineCdmPluginMimeType)
201 return WIDEVINE_CDM;
202
203 return UNSUPPORTED_MIMETYPE;
179 } 204 }
OLDNEW
« no previous file with comments | « chrome/renderer/plugins/plugin_uma.h ('k') | chrome/renderer/plugins/plugin_uma_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698