| 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/dom_ui/plugins_ui.h" | 5 #include "chrome/browser/dom_ui/plugins_ui.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <set> |
| 8 #include <string> | 9 #include <string> |
| 9 #include <vector> | 10 #include <vector> |
| 10 | 11 |
| 11 #include "app/l10n_util.h" | 12 #include "app/l10n_util.h" |
| 12 #include "app/resource_bundle.h" | 13 #include "app/resource_bundle.h" |
| 13 #include "base/message_loop.h" | 14 #include "base/message_loop.h" |
| 14 #include "base/path_service.h" | 15 #include "base/path_service.h" |
| 15 #include "base/singleton.h" | 16 #include "base/singleton.h" |
| 16 #include "base/values.h" | 17 #include "base/values.h" |
| 17 #include "chrome/browser/browser.h" | 18 #include "chrome/browser/browser.h" |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 140 | 141 |
| 141 // Callback for the "enablePlugin" message. | 142 // Callback for the "enablePlugin" message. |
| 142 void HandleEnablePluginMessage(const ListValue* args); | 143 void HandleEnablePluginMessage(const ListValue* args); |
| 143 | 144 |
| 144 // Callback for the "showTermsOfService" message. This really just opens a new | 145 // Callback for the "showTermsOfService" message. This really just opens a new |
| 145 // window with about:terms. Flash can't link directly to about:terms due to | 146 // window with about:terms. Flash can't link directly to about:terms due to |
| 146 // the security model. | 147 // the security model. |
| 147 void HandleShowTermsOfServiceMessage(const ListValue* args); | 148 void HandleShowTermsOfServiceMessage(const ListValue* args); |
| 148 | 149 |
| 149 private: | 150 private: |
| 151 // Creates a dictionary containing all the information about the given plugin; |
| 152 // this is put into the list to "return" for the "requestPluginsData" message. |
| 153 DictionaryValue* CreatePluginDetailValue( |
| 154 const WebPluginInfo& plugin, |
| 155 const std::set<string16>& plugin_blacklist_set); |
| 156 |
| 157 // Creates a dictionary containing the important parts of the information |
| 158 // about the given plugin; this is put into a list and saved in prefs. |
| 159 DictionaryValue* CreatePluginSummaryValue(const WebPluginInfo& plugin); |
| 160 |
| 161 // Update the user preferences to reflect the current (user-selected) state of |
| 162 // plugins. |
| 163 void UpdatePreferences(); |
| 164 |
| 150 DISALLOW_COPY_AND_ASSIGN(PluginsDOMHandler); | 165 DISALLOW_COPY_AND_ASSIGN(PluginsDOMHandler); |
| 151 }; | 166 }; |
| 152 | 167 |
| 153 void PluginsDOMHandler::RegisterMessages() { | 168 void PluginsDOMHandler::RegisterMessages() { |
| 154 dom_ui_->RegisterMessageCallback("requestPluginsData", | 169 dom_ui_->RegisterMessageCallback("requestPluginsData", |
| 155 NewCallback(this, &PluginsDOMHandler::HandleRequestPluginsData)); | 170 NewCallback(this, &PluginsDOMHandler::HandleRequestPluginsData)); |
| 156 dom_ui_->RegisterMessageCallback("enablePlugin", | 171 dom_ui_->RegisterMessageCallback("enablePlugin", |
| 157 NewCallback(this, &PluginsDOMHandler::HandleEnablePluginMessage)); | 172 NewCallback(this, &PluginsDOMHandler::HandleEnablePluginMessage)); |
| 158 dom_ui_->RegisterMessageCallback("showTermsOfService", | 173 dom_ui_->RegisterMessageCallback("showTermsOfService", |
| 159 NewCallback(this, &PluginsDOMHandler::HandleShowTermsOfServiceMessage)); | 174 NewCallback(this, &PluginsDOMHandler::HandleShowTermsOfServiceMessage)); |
| 160 } | 175 } |
| 161 | 176 |
| 162 void PluginsDOMHandler::HandleRequestPluginsData(const ListValue* args) { | 177 void PluginsDOMHandler::HandleRequestPluginsData(const ListValue* args) { |
| 163 DictionaryValue results; | 178 DictionaryValue* results = new DictionaryValue(); |
| 164 results.Set("plugins", plugin_updater::GetPluginGroupsData()); | 179 results->Set("plugins", plugin_updater::GetPluginGroupsData()); |
| 165 dom_ui_->CallJavascriptFunction(L"returnPluginsData", results); | 180 |
| 181 dom_ui_->CallJavascriptFunction(L"returnPluginsData", *results); |
| 166 } | 182 } |
| 167 | 183 |
| 168 void PluginsDOMHandler::HandleEnablePluginMessage(const ListValue* args) { | 184 void PluginsDOMHandler::HandleEnablePluginMessage(const ListValue* args) { |
| 169 // Be robust in accepting badness since plug-ins display HTML (hence | 185 // Be robust in accepting badness since plug-ins display HTML (hence |
| 170 // JavaScript). | 186 // JavaScript). |
| 171 if (args->GetSize() != 3) | 187 if (args->GetSize() != 3) |
| 172 return; | 188 return; |
| 173 | 189 |
| 174 std::string enable_str; | 190 std::string enable_str; |
| 175 std::string is_group_str; | 191 std::string is_group_str; |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 236 void PluginsUI::RegisterUserPrefs(PrefService* prefs) { | 252 void PluginsUI::RegisterUserPrefs(PrefService* prefs) { |
| 237 FilePath internal_dir; | 253 FilePath internal_dir; |
| 238 PathService::Get(chrome::DIR_INTERNAL_PLUGINS, &internal_dir); | 254 PathService::Get(chrome::DIR_INTERNAL_PLUGINS, &internal_dir); |
| 239 prefs->RegisterFilePathPref(prefs::kPluginsLastInternalDirectory, | 255 prefs->RegisterFilePathPref(prefs::kPluginsLastInternalDirectory, |
| 240 internal_dir); | 256 internal_dir); |
| 241 | 257 |
| 242 prefs->RegisterListPref(prefs::kPluginsPluginsBlacklist); | 258 prefs->RegisterListPref(prefs::kPluginsPluginsBlacklist); |
| 243 prefs->RegisterListPref(prefs::kPluginsPluginsList); | 259 prefs->RegisterListPref(prefs::kPluginsPluginsList); |
| 244 prefs->RegisterBooleanPref(prefs::kPluginsEnabledInternalPDF, false); | 260 prefs->RegisterBooleanPref(prefs::kPluginsEnabledInternalPDF, false); |
| 245 } | 261 } |
| OLD | NEW |