| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/plugin_updater.h" | 5 #include "chrome/browser/plugin_updater.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/path_service.h" | 10 #include "base/path_service.h" |
| (...skipping 26 matching lines...) Expand all Loading... |
| 37 group = PluginGroup::FindHardcodedPluginGroup(web_plugin); | 37 group = PluginGroup::FindHardcodedPluginGroup(web_plugin); |
| 38 plugin_groups->push_back(linked_ptr<PluginGroup>(group)); | 38 plugin_groups->push_back(linked_ptr<PluginGroup>(group)); |
| 39 } | 39 } |
| 40 group->AddPlugin(web_plugin, i); | 40 group->AddPlugin(web_plugin, i); |
| 41 } | 41 } |
| 42 } | 42 } |
| 43 | 43 |
| 44 static DictionaryValue* CreatePluginFileSummary( | 44 static DictionaryValue* CreatePluginFileSummary( |
| 45 const WebPluginInfo& plugin) { | 45 const WebPluginInfo& plugin) { |
| 46 DictionaryValue* data = new DictionaryValue(); | 46 DictionaryValue* data = new DictionaryValue(); |
| 47 data->SetString(L"path", plugin.path.value()); | 47 data->SetString("path", plugin.path.value()); |
| 48 data->SetStringFromUTF16(L"name", plugin.name); | 48 data->SetString("name", plugin.name); |
| 49 data->SetStringFromUTF16(L"version", plugin.version); | 49 data->SetString("version", plugin.version); |
| 50 data->SetBoolean(L"enabled", plugin.enabled); | 50 data->SetBoolean("enabled", plugin.enabled); |
| 51 return data; | 51 return data; |
| 52 } | 52 } |
| 53 | 53 |
| 54 ListValue* GetPluginGroupsData() { | 54 ListValue* GetPluginGroupsData() { |
| 55 std::vector<linked_ptr<PluginGroup> > plugin_groups; | 55 std::vector<linked_ptr<PluginGroup> > plugin_groups; |
| 56 GetPluginGroups(&plugin_groups); | 56 GetPluginGroups(&plugin_groups); |
| 57 | 57 |
| 58 // Construct DictionaryValues to return to the UI | 58 // Construct DictionaryValues to return to the UI |
| 59 ListValue* plugin_groups_data = new ListValue(); | 59 ListValue* plugin_groups_data = new ListValue(); |
| 60 for (std::vector<linked_ptr<PluginGroup> >::iterator it = | 60 for (std::vector<linked_ptr<PluginGroup> >::iterator it = |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 122 it != saved_plugins_list->end(); | 122 it != saved_plugins_list->end(); |
| 123 ++it) { | 123 ++it) { |
| 124 if (!(*it)->IsType(Value::TYPE_DICTIONARY)) { | 124 if (!(*it)->IsType(Value::TYPE_DICTIONARY)) { |
| 125 LOG(WARNING) << "Invalid entry in " << prefs::kPluginsPluginsList; | 125 LOG(WARNING) << "Invalid entry in " << prefs::kPluginsPluginsList; |
| 126 continue; // Oops, don't know what to do with this item. | 126 continue; // Oops, don't know what to do with this item. |
| 127 } | 127 } |
| 128 | 128 |
| 129 DictionaryValue* plugin = static_cast<DictionaryValue*>(*it); | 129 DictionaryValue* plugin = static_cast<DictionaryValue*>(*it); |
| 130 string16 group_name; | 130 string16 group_name; |
| 131 bool enabled = true; | 131 bool enabled = true; |
| 132 plugin->GetBoolean(L"enabled", &enabled); | 132 plugin->GetBoolean("enabled", &enabled); |
| 133 | 133 |
| 134 FilePath::StringType path; | 134 FilePath::StringType path; |
| 135 // The plugin list constains all the plugin files in addition to the | 135 // The plugin list constains all the plugin files in addition to the |
| 136 // plugin groups. | 136 // plugin groups. |
| 137 if (plugin->GetString(L"path", &path)) { | 137 if (plugin->GetString("path", &path)) { |
| 138 // Files have a path attribute, groups don't. | 138 // Files have a path attribute, groups don't. |
| 139 FilePath plugin_path(path); | 139 FilePath plugin_path(path); |
| 140 if (update_internal_dir && | 140 if (update_internal_dir && |
| 141 FilePath::CompareIgnoreCase(plugin_path.DirName().value(), | 141 FilePath::CompareIgnoreCase(plugin_path.DirName().value(), |
| 142 last_internal_dir.value()) == 0) { | 142 last_internal_dir.value()) == 0) { |
| 143 // If the internal plugin directory has changed and if the plugin | 143 // If the internal plugin directory has changed and if the plugin |
| 144 // looks internal, update its path in the prefs. | 144 // looks internal, update its path in the prefs. |
| 145 plugin_path = cur_internal_dir.Append(plugin_path.BaseName()); | 145 plugin_path = cur_internal_dir.Append(plugin_path.BaseName()); |
| 146 path = plugin_path.value(); | 146 path = plugin_path.value(); |
| 147 plugin->SetString(L"path", path); | 147 plugin->SetString("path", path); |
| 148 } | 148 } |
| 149 | 149 |
| 150 if (FilePath::CompareIgnoreCase(path, pdf_path_str) == 0) { | 150 if (FilePath::CompareIgnoreCase(path, pdf_path_str) == 0) { |
| 151 found_internal_pdf = true; | 151 found_internal_pdf = true; |
| 152 if (!enabled && force_enable_internal_pdf) { | 152 if (!enabled && force_enable_internal_pdf) { |
| 153 enabled = true; | 153 enabled = true; |
| 154 plugin->SetBoolean(L"enabled", true); | 154 plugin->SetBoolean("enabled", true); |
| 155 } | 155 } |
| 156 } | 156 } |
| 157 if (!enabled) | 157 if (!enabled) |
| 158 NPAPI::PluginList::Singleton()->DisablePlugin(plugin_path); | 158 NPAPI::PluginList::Singleton()->DisablePlugin(plugin_path); |
| 159 } else if (!enabled && plugin->GetStringAsUTF16(L"name", &group_name)) { | 159 } else if (!enabled && plugin->GetStringAsUTF16("name", &group_name)) { |
| 160 // Otherwise this is a list of groups. | 160 // Otherwise this is a list of groups. |
| 161 EnablePluginGroup(false, group_name); | 161 EnablePluginGroup(false, group_name); |
| 162 } | 162 } |
| 163 } | 163 } |
| 164 } | 164 } |
| 165 | 165 |
| 166 // Build the set of policy-disabled plugins once and cache it. | 166 // Build the set of policy-disabled plugins once and cache it. |
| 167 // Don't do this in the constructor, there's no profile available there. | 167 // Don't do this in the constructor, there's no profile available there. |
| 168 std::set<string16> policy_disabled_plugins; | 168 std::set<string16> policy_disabled_plugins; |
| 169 const ListValue* plugin_blacklist = | 169 const ListValue* plugin_blacklist = |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 233 it != plugin_groups.end(); | 233 it != plugin_groups.end(); |
| 234 ++it) { | 234 ++it) { |
| 235 // Don't save preferences for vulnerable pugins. | 235 // Don't save preferences for vulnerable pugins. |
| 236 if (!(*it)->IsVulnerable()) { | 236 if (!(*it)->IsVulnerable()) { |
| 237 plugins_list->Append((*it)->GetSummary()); | 237 plugins_list->Append((*it)->GetSummary()); |
| 238 } | 238 } |
| 239 } | 239 } |
| 240 } | 240 } |
| 241 | 241 |
| 242 } // namespace plugin_updater | 242 } // namespace plugin_updater |
| OLD | NEW |