Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(71)

Side by Side Diff: chrome/browser/dom_ui/plugins_ui.cc

Issue 2955005: Factor out PluginGroup into a separate class in common/. (Closed)
Patch Set: baseline updates Created 10 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | chrome/browser/plugin_service.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 dom_ui_->RegisterMessageCallback("enablePlugin", 160 dom_ui_->RegisterMessageCallback("enablePlugin",
161 NewCallback(this, &PluginsDOMHandler::HandleEnablePluginMessage)); 161 NewCallback(this, &PluginsDOMHandler::HandleEnablePluginMessage));
162 dom_ui_->RegisterMessageCallback("showTermsOfService", 162 dom_ui_->RegisterMessageCallback("showTermsOfService",
163 NewCallback(this, &PluginsDOMHandler::HandleShowTermsOfServiceMessage)); 163 NewCallback(this, &PluginsDOMHandler::HandleShowTermsOfServiceMessage));
164 } 164 }
165 165
166 void PluginsDOMHandler::HandleRequestPluginsData(const Value* value) { 166 void PluginsDOMHandler::HandleRequestPluginsData(const Value* value) {
167 DictionaryValue* results = new DictionaryValue(); 167 DictionaryValue* results = new DictionaryValue();
168 168
169 // Grouped plugins. 169 // Grouped plugins.
170 results->Set(L"plugins", PluginUpdater::GetInstance()->GetPluginGroupsData()); 170 results->Set(L"plugins", plugin_updater::GetPluginGroupsData());
171 171
172 dom_ui_->CallJavascriptFunction(L"returnPluginsData", *results); 172 dom_ui_->CallJavascriptFunction(L"returnPluginsData", *results);
173 } 173 }
174 174
175 void PluginsDOMHandler::HandleEnablePluginMessage(const Value* value) { 175 void PluginsDOMHandler::HandleEnablePluginMessage(const Value* value) {
176 // Be robust in accepting badness since plug-ins display HTML (hence 176 // Be robust in accepting badness since plug-ins display HTML (hence
177 // JavaScript). 177 // JavaScript).
178 if (!value->IsType(Value::TYPE_LIST)) 178 if (!value->IsType(Value::TYPE_LIST))
179 return; 179 return;
180 180
181 const ListValue* list = static_cast<const ListValue*>(value); 181 const ListValue* list = static_cast<const ListValue*>(value);
182 if (list->GetSize() != 3) 182 if (list->GetSize() != 3)
183 return; 183 return;
184 184
185 std::string enable_str; 185 std::string enable_str;
186 std::string is_group_str; 186 std::string is_group_str;
187 if (!list->GetString(1, &enable_str) || 187 if (!list->GetString(1, &enable_str) || !list->GetString(2, &is_group_str))
188 !list->GetString(2, &is_group_str))
189 return; 188 return;
190 189
191 if (is_group_str == "true") { 190 if (is_group_str == "true") {
192 std::wstring group_name; 191 std::wstring group_name;
193 if (!list->GetString(0, &group_name)) 192 if (!list->GetString(0, &group_name))
194 return; 193 return;
195 194
196 PluginUpdater::GetInstance()->EnablePluginGroup(enable_str == "true", 195 plugin_updater::EnablePluginGroup(enable_str == "true",
197 WideToUTF16(group_name)); 196 WideToUTF16(group_name));
198 } else { 197 } else {
199 FilePath::StringType file_path; 198 FilePath::StringType file_path;
200 if (!list->GetString(0, &file_path)) 199 if (!list->GetString(0, &file_path))
201 return; 200 return;
202 201
203 PluginUpdater::GetInstance()->EnablePluginFile(enable_str == "true", 202 plugin_updater::EnablePluginFile(enable_str == "true", file_path);
204 file_path);
205 } 203 }
206 204
207 // TODO(viettrungluu): We might also want to ensure that the plugins 205 // TODO(viettrungluu): We might also want to ensure that the plugins
208 // list is always written to prefs even when the user hasn't disabled a 206 // list is always written to prefs even when the user hasn't disabled a
209 // plugin. <http://crbug.com/39101> 207 // plugin. <http://crbug.com/39101>
210 PluginUpdater::GetInstance()->UpdatePreferences(dom_ui_->GetProfile()); 208 plugin_updater::UpdatePreferences(dom_ui_->GetProfile());
211 } 209 }
212 210
213 void PluginsDOMHandler::HandleShowTermsOfServiceMessage(const Value* value) { 211 void PluginsDOMHandler::HandleShowTermsOfServiceMessage(const Value* value) {
214 // Show it in a new browser window.... 212 // Show it in a new browser window....
215 Browser* browser = Browser::Create(dom_ui_->GetProfile()); 213 Browser* browser = Browser::Create(dom_ui_->GetProfile());
216 browser->OpenURL(GURL(chrome::kAboutTermsURL), 214 browser->OpenURL(GURL(chrome::kAboutTermsURL),
217 GURL(), NEW_FOREGROUND_TAB, PageTransition::LINK); 215 GURL(), NEW_FOREGROUND_TAB, PageTransition::LINK);
218 browser->window()->Show(); 216 browser->window()->Show();
219 } 217 }
220 218
(...skipping 28 matching lines...) Expand all
249 // static 247 // static
250 void PluginsUI::RegisterUserPrefs(PrefService* prefs) { 248 void PluginsUI::RegisterUserPrefs(PrefService* prefs) {
251 FilePath internal_dir; 249 FilePath internal_dir;
252 PathService::Get(chrome::DIR_INTERNAL_PLUGINS, &internal_dir); 250 PathService::Get(chrome::DIR_INTERNAL_PLUGINS, &internal_dir);
253 prefs->RegisterFilePathPref(prefs::kPluginsLastInternalDirectory, 251 prefs->RegisterFilePathPref(prefs::kPluginsLastInternalDirectory,
254 internal_dir); 252 internal_dir);
255 253
256 prefs->RegisterListPref(prefs::kPluginsPluginsList); 254 prefs->RegisterListPref(prefs::kPluginsPluginsList);
257 prefs->RegisterBooleanPref(prefs::kPluginsEnabledInternalPDF, false); 255 prefs->RegisterBooleanPref(prefs::kPluginsEnabledInternalPDF, false);
258 } 256 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/plugin_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698