| OLD | NEW |
| (Empty) |
| 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. | |
| 4 | |
| 5 #ifndef CHROME_RENDERER_PLUGIN_UMA_H_ | |
| 6 #define CHROME_RENDERER_PLUGIN_UMA_H_ | |
| 7 | |
| 8 #include <string> | |
| 9 | |
| 10 #include "base/memory/scoped_ptr.h" | |
| 11 #include "base/memory/singleton.h" | |
| 12 #include "googleurl/src/gurl.h" | |
| 13 | |
| 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 MissingPluginReporter { | |
| 19 public: | |
| 20 // This must be sync'd with histogram values. | |
| 21 enum PluginType { | |
| 22 WINDOWS_MEDIA_PLAYER = 0, | |
| 23 SILVERLIGHT = 1, | |
| 24 REALPLAYER = 2, | |
| 25 JAVA = 3, | |
| 26 QUICKTIME = 4, | |
| 27 OTHER = 5 | |
| 28 }; | |
| 29 | |
| 30 // Sends UMA data, i.e. plugin's type. | |
| 31 class UMASender { | |
| 32 public: | |
| 33 virtual ~UMASender() {} | |
| 34 virtual void SendPluginUMA(PluginType plugin_type) = 0; | |
| 35 }; | |
| 36 | |
| 37 // Returns singleton instance. | |
| 38 static MissingPluginReporter* GetInstance(); | |
| 39 | |
| 40 void ReportPluginMissing(std::string plugin_mime_type, | |
| 41 const GURL& plugin_src); | |
| 42 | |
| 43 // Used in testing. | |
| 44 void SetUMASender(UMASender* sender); | |
| 45 | |
| 46 private: | |
| 47 friend struct DefaultSingletonTraits<MissingPluginReporter>; | |
| 48 | |
| 49 MissingPluginReporter(); | |
| 50 ~MissingPluginReporter(); | |
| 51 | |
| 52 static bool CompareCStrings(const char* first, const char* second); | |
| 53 bool CStringArrayContainsCString(const char** array, | |
| 54 size_t array_size, | |
| 55 const char* str); | |
| 56 // Extracts file extension from url. | |
| 57 void ExtractFileExtension(const GURL& src, std::string* extension); | |
| 58 | |
| 59 // Converts plugin's src to plugin type. | |
| 60 PluginType SrcToPluginType(const GURL& src); | |
| 61 // Converts plugin's mime type to plugin type. | |
| 62 PluginType MimeTypeToPluginType(const std::string& mime_type); | |
| 63 | |
| 64 scoped_ptr<UMASender> report_sender_; | |
| 65 | |
| 66 DISALLOW_COPY_AND_ASSIGN(MissingPluginReporter); | |
| 67 }; | |
| 68 | |
| 69 #endif // CHROME_RENDERER_PLUGIN_UMA_H_ | |
| 70 | |
| OLD | NEW |