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