~saiarcot895/chromium-browser/chromium-browser.precise.dev

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
Index: dev.wily/chrome/browser/browser_resources.grd
===================================================================
--- dev.wily.orig/chrome/browser/browser_resources.grd
+++ dev.wily/chrome/browser/browser_resources.grd
@@ -245,6 +245,7 @@
       </if>
       <if expr="desktop_linux or (is_android and enable_plugins)">
         <include name="IDR_PLUGIN_DB_JSON" file="resources\plugin_metadata\plugins_linux.json" type="BINDATA" />
+        <include name="IDR_PLATFORM_PLUGIN_DB_JSON" file="resources\plugin_metadata\plugins_ubuntu_linux.json" type="BINDATA" />
       </if>
       <if expr="is_android">
         <include name="IDR_POLICY_CSS" file="resources\policy_android.css" type="BINDATA"/>
Index: dev.wily/chrome/browser/plugins/plugin_finder.cc
===================================================================
--- dev.wily.orig/chrome/browser/plugins/plugin_finder.cc
+++ dev.wily/chrome/browser/plugins/plugin_finder.cc
@@ -151,44 +151,10 @@ void RecordBuiltInPluginListError(Plugin
                             static_cast<int>(PluginListError::NUM_VALUES));
 }
 
-}  // namespace
-
-// static
-void PluginFinder::RegisterPrefs(PrefRegistrySimple* registry) {
-  registry->RegisterBooleanPref(prefs::kDisablePluginFinder, false);
-}
-
-// static
-PluginFinder* PluginFinder::GetInstance() {
-  // PluginFinder::GetInstance() is the only method that's allowed to call
-  // Singleton<PluginFinder>::get().
-  return Singleton<PluginFinder>::get();
-}
-
-PluginFinder::PluginFinder() : version_(-1) {
-  DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
-}
-
-void PluginFinder::Init() {
-  DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
-  // Load the built-in plugin list first. If we have a newer version stored
-  // locally or download one, we will replace this one with it.
-  scoped_ptr<base::DictionaryValue> plugin_list(LoadBuiltInPluginList());
-
-  // Gracefully handle the case where we couldn't parse the built-in plugin list
-  // for some reason (https://crbug.com/388560). TODO(bauerb): Change back to a
-  // DCHECK once we have gathered more data about the underlying problem.
-  if (!plugin_list)
-    return;
-
-  ReinitializePlugins(plugin_list.get());
-}
-
-// static
-base::DictionaryValue* PluginFinder::LoadBuiltInPluginList() {
+base::DictionaryValue* LoadPlatformPluginListWithId(int resourceId) {
   base::StringPiece json_resource(
       ResourceBundle::GetSharedInstance().GetRawDataResource(
-          IDR_PLUGIN_DB_JSON));
+          resourceId));
   std::string error_str;
   int error_code = base::JSONReader::JSON_NO_ERROR;
   scoped_ptr<base::Value> value = base::JSONReader::ReadAndReturnError(
@@ -243,6 +209,59 @@ base::DictionaryValue* PluginFinder::Loa
   return static_cast<base::DictionaryValue*>(value.release());
 }
 
+}  // namespace
+
+// static
+void PluginFinder::RegisterPrefs(PrefRegistrySimple* registry) {
+  registry->RegisterBooleanPref(prefs::kDisablePluginFinder, false);
+}
+
+void PluginFinder::MergePlatformSpecifiPlugins (base::DictionaryValue * plugin_list) {
+  if (!plugin_list)
+    return;
+  scoped_ptr<base::DictionaryValue> platform_plugin_list =
+    scoped_ptr<base::DictionaryValue>(LoadPlatformPluginList());
+  if (platform_plugin_list) {
+    plugin_list->MergeDictionary(platform_plugin_list.get());
+  }
+}
+
+// static
+PluginFinder* PluginFinder::GetInstance() {
+  // PluginFinder::GetInstance() is the only method that's allowed to call
+  // Singleton<PluginFinder>::get().
+  return Singleton<PluginFinder>::get();
+}
+
+PluginFinder::PluginFinder() : version_(-1) {
+  DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
+}
+
+void PluginFinder::Init() {
+  DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
+  // Load the built-in plugin list first. If we have a newer version stored
+  // locally or download one, we will replace this one with it.
+  scoped_ptr<base::DictionaryValue> plugin_list(LoadBuiltInPluginList());
+
+  // Gracefully handle the case where we couldn't parse the built-in plugin list
+  // for some reason (https://crbug.com/388560). TODO(bauerb): Change back to a
+  // DCHECK once we have gathered more data about the underlying problem.
+  if (!plugin_list)
+    return;
+
+  ReinitializePlugins(plugin_list.get());
+}
+
+// static
+DictionaryValue* PluginFinder::LoadPlatformPluginList() {
+  return LoadPlatformPluginListWithId(IDR_PLATFORM_PLUGIN_DB_JSON);
+}
+
+// static
+base::DictionaryValue* PluginFinder::LoadBuiltInPluginList() {
+  return LoadPlatformPluginListWithId(IDR_PLUGIN_DB_JSON);
+}
+
 PluginFinder::~PluginFinder() {
 #if defined(ENABLE_PLUGIN_INSTALLATION)
   STLDeleteValues(&installers_);
@@ -320,15 +339,20 @@ void PluginFinder::ReinitializePlugins(
   if (version <= version_)
     return;
 
+  // Load the platform specific plugins (if any)
+  scoped_ptr<DictionaryValue> final_plugin_list(plugin_list->DeepCopy());
+  MergePlatformSpecifiPlugins(final_plugin_list.get());
+
   version_ = version;
 
   STLDeleteValues(&identifier_plugin_);
 
-  for (base::DictionaryValue::Iterator plugin_it(*plugin_list);
+  for (base::DictionaryValue::Iterator plugin_it(*final_plugin_list);
       !plugin_it.IsAtEnd(); plugin_it.Advance()) {
     const base::DictionaryValue* plugin = NULL;
     const std::string& identifier = plugin_it.key();
-    if (plugin_list->GetDictionaryWithoutPathExpansion(identifier, &plugin)) {
+    if (final_plugin_list->GetDictionaryWithoutPathExpansion(
+            identifier, &plugin)) {
       DCHECK(!identifier_plugin_[identifier]);
       identifier_plugin_[identifier] = CreatePluginMetadata(identifier, plugin);
 
Index: dev.wily/chrome/browser/plugins/plugin_finder.h
===================================================================
--- dev.wily.orig/chrome/browser/plugins/plugin_finder.h
+++ dev.wily/chrome/browser/plugins/plugin_finder.h
@@ -86,6 +86,15 @@ class PluginFinder {
   // Returns NULL if the plugin list couldn't be parsed.
   static base::DictionaryValue* LoadBuiltInPluginList();
 
+  // Loads platform specific whitelisted plugins from the browser
+  // resources and parses it.
+  // Returns NULL if the plug-in list couldn't be parsed.
+  static base::DictionaryValue* LoadPlatformPluginList();
+
+  // Merges the platform specific plugins to the list of plugins
+  // passed as parameters.
+  static void MergePlatformSpecifiPlugins(base::DictionaryValue * plugin_list);
+
 #if defined(ENABLE_PLUGIN_INSTALLATION)
   std::map<std::string, PluginInstaller*> installers_;
 #endif
Index: dev.wily/chrome/browser/resources/plugin_metadata/plugins_ubuntu_linux.json
===================================================================
--- /dev/null
+++ dev.wily/chrome/browser/resources/plugin_metadata/plugins_ubuntu_linux.json
@@ -0,0 +1,18 @@
+{
+  "libunity_npapi_plugin.so": {
+    "mime_types": [
+      "application/x-unity-webapps-npapi"
+    ],
+    "versions": [
+      {
+        "version": "0",
+        "status": "up_to_date",
+        "reference": "https://launchpad.net/unity-chromium-extension/12.10"
+      }
+    ],
+    "lang": "en-US",
+    "name": "Unity WebApps plugin",
+    "url": "https://launchpad.net/ubuntu/quantal/+source/unity-chromium-extension",
+    "group_name_matcher": "Unity WebApps plugin"
+  }
+}