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
3 // found in the LICENSE file.
5 #ifndef CHROME_RENDERER_PLUGINS_PLUGIN_UMA_H_
6 #define CHROME_RENDERER_PLUGINS_PLUGIN_UMA_H_
10 #include "base/memory/scoped_ptr.h"
11 #include "base/memory/singleton.h"
14 // Used to send UMA data about missing plugins to UMA histogram server. Method
15 // ReportPluginMissing should be called whenever plugin that is not available or
16 // enabled is called. We try to determine plugin's type by requested mime type,
17 // or, if mime type is unknown, by plugin's src url.
18 class PluginUMAReporter
{
25 // Make sure the enum list in tools/histogram/histograms.xml is updated with
26 // any change in this list.
28 WINDOWS_MEDIA_PLAYER
= 0,
33 OTHER
= 5, // This is obsolete and replaced by UNSUPPORTED_* types.
35 UNSUPPORTED_EXTENSION
,
36 // NOTE: Add new unsupported types only immediately above this line.
40 // NOTE: Add new plugin types only immediately above this line.
44 // Sends UMA data, i.e. plugin's type.
47 virtual ~UMASender() {}
48 virtual void SendPluginUMA(ReportType report_type
,
49 PluginType plugin_type
) = 0;
52 // Returns singleton instance.
53 static PluginUMAReporter
* GetInstance();
55 void ReportPluginMissing(const std::string
& plugin_mime_type
,
56 const GURL
& plugin_src
);
58 void ReportPluginDisabled(const std::string
& plugin_mime_type
,
59 const GURL
& plugin_src
);
62 friend struct DefaultSingletonTraits
<PluginUMAReporter
>;
63 friend class PluginUMATest
;
68 static bool CompareCStrings(const char* first
, const char* second
);
69 bool CStringArrayContainsCString(const char* const* array
,
72 // Extracts file extension from url.
73 void ExtractFileExtension(const GURL
& src
, std::string
* extension
);
75 PluginType
GetPluginType(const std::string
& plugin_mime_type
,
76 const GURL
& plugin_src
);
78 // Converts plugin's src to plugin type.
79 PluginType
SrcToPluginType(const GURL
& src
);
80 // Converts plugin's mime type to plugin type.
81 PluginType
MimeTypeToPluginType(const std::string
& mime_type
);
83 scoped_ptr
<UMASender
> report_sender_
;
85 DISALLOW_COPY_AND_ASSIGN(PluginUMAReporter
);
88 #endif // CHROME_RENDERER_PLUGINS_PLUGIN_UMA_H_