FireBreath  1.4.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Pages
PluginInfo.cpp
1 /**********************************************************\
2 Original Author: Georg Fritzsche
3 
4 Created: Oct 23, 2010
5 License: Dual license model; choose one of two:
6  New BSD License
7  http://www.opensource.org/licenses/bsd-license.php
8  - or -
9  GNU Lesser General Public License, version 2.1
10  http://www.gnu.org/licenses/lgpl-2.1.html
11 
12 Copyright 2010 Georg Fritzsche, Firebreath development team
13 \**********************************************************/
14 
15 #include "global/config.h"
16 #include <map>
17 #include <string>
18 #include <vector>
19 #include <boost/algorithm/string.hpp>
20 
21 #include "PluginInfo.h"
22 #include "precompiled_headers.h" // On windows, everything above this line in PCH
23 
24 namespace {
25  bool nameParsed = false;
26  std::map<std::string, std::string> descMap;
27 
28  void initPluginMetadata()
29  {
30  if (nameParsed)
31  return;
32  std::vector<std::string> versions;
33  boost::algorithm::split(versions, FBSTRING_X11MIMEType, boost::is_any_of(";"));
34  for (std::vector<std::string>::const_iterator it = versions.begin();
35  it != versions.end(); ++it)
36  {
37  std::vector<std::string> parts;
38  boost::algorithm::split(parts, *it, boost::is_any_of(":"));
39  if (parts.size() > 2) {
40  descMap[parts[0]] = parts[2];
41  }
42  }
43  nameParsed = true;
44  }
45 };
46 
47 std::string FB::getPluginName(const std::string& mimetype)
48 {
49  return FBSTRING_PluginName; // NPAPI only really allows one name per mimetype
50 }
51 
52 std::string FB::getPluginDescription(const std::string& mimetype)
53 {
54  initPluginMetadata();
55 
56  try {
57  return descMap[mimetype];
58  } catch (...) {
59  return "Unknown Description";
60  }
61 }
62 
63 bool FB::pluginGuiEnabled() {
64 #if FB_GUI_DISABLED
65  return false;
66 #else
67  return true;
68 #endif
69 }
70