OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/browser/ui/webui/plugins_ui.h" | 5 #include "chrome/browser/ui/webui/plugins_ui.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 #include "grit/theme_resources.h" | 45 #include "grit/theme_resources.h" |
46 #include "ui/base/l10n/l10n_util.h" | 46 #include "ui/base/l10n/l10n_util.h" |
47 #include "ui/base/resource/resource_bundle.h" | 47 #include "ui/base/resource/resource_bundle.h" |
48 | 48 |
49 #if defined(OS_CHROMEOS) | 49 #if defined(OS_CHROMEOS) |
50 #include "chrome/browser/ui/webui/chromeos/ui_account_tweaks.h" | 50 #include "chrome/browser/ui/webui/chromeos/ui_account_tweaks.h" |
51 #endif | 51 #endif |
52 | 52 |
53 using content::PluginService; | 53 using content::PluginService; |
54 using content::WebContents; | 54 using content::WebContents; |
| 55 using content::WebPluginInfo; |
55 using content::WebUIMessageHandler; | 56 using content::WebUIMessageHandler; |
56 using webkit::WebPluginInfo; | |
57 | 57 |
58 namespace { | 58 namespace { |
59 | 59 |
60 // Callback function to process result of EnablePlugin method. | 60 // Callback function to process result of EnablePlugin method. |
61 void AssertPluginEnabled(bool did_enable) { | 61 void AssertPluginEnabled(bool did_enable) { |
62 DCHECK(did_enable); | 62 DCHECK(did_enable); |
63 } | 63 } |
64 | 64 |
65 content::WebUIDataSource* CreatePluginsUIHTMLSource() { | 65 content::WebUIDataSource* CreatePluginsUIHTMLSource() { |
66 content::WebUIDataSource* source = | 66 content::WebUIDataSource* source = |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
160 | 160 |
161 // content::NotificationObserver method overrides | 161 // content::NotificationObserver method overrides |
162 virtual void Observe(int type, | 162 virtual void Observe(int type, |
163 const content::NotificationSource& source, | 163 const content::NotificationSource& source, |
164 const content::NotificationDetails& details) OVERRIDE; | 164 const content::NotificationDetails& details) OVERRIDE; |
165 | 165 |
166 private: | 166 private: |
167 void LoadPlugins(); | 167 void LoadPlugins(); |
168 | 168 |
169 // Called on the UI thread when the plugin information is ready. | 169 // Called on the UI thread when the plugin information is ready. |
170 void PluginsLoaded(const std::vector<webkit::WebPluginInfo>& plugins); | 170 void PluginsLoaded(const std::vector<WebPluginInfo>& plugins); |
171 | 171 |
172 content::NotificationRegistrar registrar_; | 172 content::NotificationRegistrar registrar_; |
173 | 173 |
174 base::WeakPtrFactory<PluginsDOMHandler> weak_ptr_factory_; | 174 base::WeakPtrFactory<PluginsDOMHandler> weak_ptr_factory_; |
175 | 175 |
176 // Holds grouped plug-ins. The key is the group identifier and | 176 // Holds grouped plug-ins. The key is the group identifier and |
177 // the value is the list of plug-ins belonging to the group. | 177 // the value is the list of plug-ins belonging to the group. |
178 typedef base::hash_map<std::string, std::vector<const WebPluginInfo*> > | 178 typedef base::hash_map<std::string, std::vector<const WebPluginInfo*> > |
179 PluginGroups; | 179 PluginGroups; |
180 | 180 |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
322 void PluginsDOMHandler::LoadPlugins() { | 322 void PluginsDOMHandler::LoadPlugins() { |
323 if (weak_ptr_factory_.HasWeakPtrs()) | 323 if (weak_ptr_factory_.HasWeakPtrs()) |
324 return; | 324 return; |
325 | 325 |
326 PluginService::GetInstance()->GetPlugins( | 326 PluginService::GetInstance()->GetPlugins( |
327 base::Bind(&PluginsDOMHandler::PluginsLoaded, | 327 base::Bind(&PluginsDOMHandler::PluginsLoaded, |
328 weak_ptr_factory_.GetWeakPtr())); | 328 weak_ptr_factory_.GetWeakPtr())); |
329 } | 329 } |
330 | 330 |
331 void PluginsDOMHandler::PluginsLoaded( | 331 void PluginsDOMHandler::PluginsLoaded( |
332 const std::vector<webkit::WebPluginInfo>& plugins) { | 332 const std::vector<WebPluginInfo>& plugins) { |
333 Profile* profile = Profile::FromWebUI(web_ui()); | 333 Profile* profile = Profile::FromWebUI(web_ui()); |
334 PluginPrefs* plugin_prefs = PluginPrefs::GetForProfile(profile).get(); | 334 PluginPrefs* plugin_prefs = PluginPrefs::GetForProfile(profile).get(); |
335 | 335 |
336 ContentSettingsPattern wildcard = ContentSettingsPattern::Wildcard(); | 336 ContentSettingsPattern wildcard = ContentSettingsPattern::Wildcard(); |
337 | 337 |
338 PluginFinder* plugin_finder = PluginFinder::GetInstance(); | 338 PluginFinder* plugin_finder = PluginFinder::GetInstance(); |
339 // Group plug-ins by identifier. This is done to be able to display | 339 // Group plug-ins by identifier. This is done to be able to display |
340 // the plug-ins in UI in a grouped fashion. | 340 // the plug-ins in UI in a grouped fashion. |
341 PluginGroups groups; | 341 PluginGroups groups; |
342 for (size_t i = 0; i < plugins.size(); ++i) { | 342 for (size_t i = 0; i < plugins.size(); ++i) { |
(...skipping 21 matching lines...) Expand all Loading... |
364 const WebPluginInfo& group_plugin = *group_plugins[j]; | 364 const WebPluginInfo& group_plugin = *group_plugins[j]; |
365 | 365 |
366 DictionaryValue* plugin_file = new DictionaryValue(); | 366 DictionaryValue* plugin_file = new DictionaryValue(); |
367 plugin_file->SetString("name", group_plugin.name); | 367 plugin_file->SetString("name", group_plugin.name); |
368 plugin_file->SetString("description", group_plugin.desc); | 368 plugin_file->SetString("description", group_plugin.desc); |
369 plugin_file->SetString("path", group_plugin.path.value()); | 369 plugin_file->SetString("path", group_plugin.path.value()); |
370 plugin_file->SetString("version", group_plugin.version); | 370 plugin_file->SetString("version", group_plugin.version); |
371 plugin_file->SetString("type", PluginTypeToString(group_plugin.type)); | 371 plugin_file->SetString("type", PluginTypeToString(group_plugin.type)); |
372 | 372 |
373 ListValue* mime_types = new ListValue(); | 373 ListValue* mime_types = new ListValue(); |
374 const std::vector<webkit::WebPluginMimeType>& plugin_mime_types = | 374 const std::vector<content::WebPluginMimeType>& plugin_mime_types = |
375 group_plugin.mime_types; | 375 group_plugin.mime_types; |
376 for (size_t k = 0; k < plugin_mime_types.size(); ++k) { | 376 for (size_t k = 0; k < plugin_mime_types.size(); ++k) { |
377 DictionaryValue* mime_type = new DictionaryValue(); | 377 DictionaryValue* mime_type = new DictionaryValue(); |
378 mime_type->SetString("mimeType", plugin_mime_types[k].mime_type); | 378 mime_type->SetString("mimeType", plugin_mime_types[k].mime_type); |
379 mime_type->SetString("description", plugin_mime_types[k].description); | 379 mime_type->SetString("description", plugin_mime_types[k].description); |
380 | 380 |
381 ListValue* file_extensions = new ListValue(); | 381 ListValue* file_extensions = new ListValue(); |
382 const std::vector<std::string>& mime_file_extensions = | 382 const std::vector<std::string>& mime_file_extensions = |
383 plugin_mime_types[k].file_extensions; | 383 plugin_mime_types[k].file_extensions; |
384 for (size_t l = 0; l < mime_file_extensions.size(); ++l) | 384 for (size_t l = 0; l < mime_file_extensions.size(); ++l) |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
494 void PluginsUI::RegisterProfilePrefs( | 494 void PluginsUI::RegisterProfilePrefs( |
495 user_prefs::PrefRegistrySyncable* registry) { | 495 user_prefs::PrefRegistrySyncable* registry) { |
496 registry->RegisterBooleanPref( | 496 registry->RegisterBooleanPref( |
497 prefs::kPluginsShowDetails, | 497 prefs::kPluginsShowDetails, |
498 false, | 498 false, |
499 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); | 499 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
500 registry->RegisterDictionaryPref( | 500 registry->RegisterDictionaryPref( |
501 prefs::kContentSettingsPluginWhitelist, | 501 prefs::kContentSettingsPluginWhitelist, |
502 user_prefs::PrefRegistrySyncable::SYNCABLE_PREF); | 502 user_prefs::PrefRegistrySyncable::SYNCABLE_PREF); |
503 } | 503 } |
OLD | NEW |