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

Side by Side Diff: chrome/browser/plugin_updater.cc

Issue 7648017: Make WebPluginInfo more generic (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 4 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 | Annotate | Revision Log
« no previous file with comments | « chrome/browser/plugin_updater.h ('k') | chrome/browser/ui/cocoa/drag_util.mm » ('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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 8
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/message_loop.h" 10 #include "base/message_loop.h"
11 #include "base/path_service.h" 11 #include "base/path_service.h"
12 #include "base/utf_string_conversions.h" 12 #include "base/utf_string_conversions.h"
13 #include "base/values.h" 13 #include "base/values.h"
14 #include "base/version.h" 14 #include "base/version.h"
15 #include "chrome/browser/prefs/pref_service.h" 15 #include "chrome/browser/prefs/pref_service.h"
16 #include "chrome/browser/prefs/scoped_user_pref_update.h" 16 #include "chrome/browser/prefs/scoped_user_pref_update.h"
17 #include "chrome/browser/profiles/profile.h" 17 #include "chrome/browser/profiles/profile.h"
18 #include "chrome/common/chrome_content_client.h" 18 #include "chrome/common/chrome_content_client.h"
19 #include "chrome/common/chrome_notification_types.h" 19 #include "chrome/common/chrome_notification_types.h"
20 #include "chrome/common/chrome_paths.h" 20 #include "chrome/common/chrome_paths.h"
21 #include "chrome/common/pref_names.h" 21 #include "chrome/common/pref_names.h"
22 #include "content/browser/browser_thread.h" 22 #include "content/browser/browser_thread.h"
23 #include "content/common/notification_service.h" 23 #include "content/common/notification_service.h"
24 #include "webkit/plugins/npapi/plugin_list.h" 24 #include "webkit/plugins/npapi/plugin_list.h"
25 #include "webkit/plugins/npapi/webplugininfo.h" 25 #include "webkit/plugins/webplugininfo.h"
26 26
27 // How long to wait to save the plugin enabled information, which might need to 27 // How long to wait to save the plugin enabled information, which might need to
28 // go to disk. 28 // go to disk.
29 #define kPluginUpdateDelayMs (60 * 1000) 29 #define kPluginUpdateDelayMs (60 * 1000)
30 30
31 PluginUpdater::PluginUpdater() 31 PluginUpdater::PluginUpdater()
32 : notify_pending_(false) { 32 : notify_pending_(false) {
33 } 33 }
34 34
35 DictionaryValue* PluginUpdater::CreatePluginFileSummary( 35 DictionaryValue* PluginUpdater::CreatePluginFileSummary(
36 const webkit::npapi::WebPluginInfo& plugin) { 36 const webkit::WebPluginInfo& plugin) {
37 DictionaryValue* data = new DictionaryValue(); 37 DictionaryValue* data = new DictionaryValue();
38 data->SetString("path", plugin.path.value()); 38 data->SetString("path", plugin.path.value());
39 data->SetString("name", plugin.name); 39 data->SetString("name", plugin.name);
40 data->SetString("version", plugin.version); 40 data->SetString("version", plugin.version);
41 data->SetBoolean("enabled", webkit::npapi::IsPluginEnabled(plugin)); 41 data->SetBoolean("enabled", webkit::IsPluginEnabled(plugin));
42 return data; 42 return data;
43 } 43 }
44 44
45 // static 45 // static
46 ListValue* PluginUpdater::GetPluginGroupsData() { 46 ListValue* PluginUpdater::GetPluginGroupsData() {
47 std::vector<webkit::npapi::PluginGroup> plugin_groups; 47 std::vector<webkit::npapi::PluginGroup> plugin_groups;
48 webkit::npapi::PluginList::Singleton()->GetPluginGroups(true, &plugin_groups); 48 webkit::npapi::PluginList::Singleton()->GetPluginGroups(true, &plugin_groups);
49 49
50 // Construct DictionaryValues to return to the UI 50 // Construct DictionaryValues to return to the UI
51 ListValue* plugin_groups_data = new ListValue(); 51 ListValue* plugin_groups_data = new ListValue();
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
256 256
257 void PluginUpdater::UpdatePreferences(Profile* profile, int delay_ms) { 257 void PluginUpdater::UpdatePreferences(Profile* profile, int delay_ms) {
258 BrowserThread::PostDelayedTask( 258 BrowserThread::PostDelayedTask(
259 BrowserThread::FILE, 259 BrowserThread::FILE,
260 FROM_HERE, 260 FROM_HERE,
261 NewRunnableFunction( 261 NewRunnableFunction(
262 &PluginUpdater::GetPreferencesDataOnFileThread, profile), delay_ms); 262 &PluginUpdater::GetPreferencesDataOnFileThread, profile), delay_ms);
263 } 263 }
264 264
265 void PluginUpdater::GetPreferencesDataOnFileThread(void* profile) { 265 void PluginUpdater::GetPreferencesDataOnFileThread(void* profile) {
266 std::vector<webkit::npapi::WebPluginInfo> plugins; 266 std::vector<webkit::WebPluginInfo> plugins;
267 webkit::npapi::PluginList::Singleton()->GetPlugins(&plugins); 267 webkit::npapi::PluginList::Singleton()->GetPlugins(&plugins);
268 268
269 std::vector<webkit::npapi::PluginGroup> groups; 269 std::vector<webkit::npapi::PluginGroup> groups;
270 webkit::npapi::PluginList::Singleton()->GetPluginGroups(false, &groups); 270 webkit::npapi::PluginList::Singleton()->GetPluginGroups(false, &groups);
271 271
272 BrowserThread::PostTask( 272 BrowserThread::PostTask(
273 BrowserThread::UI, 273 BrowserThread::UI,
274 FROM_HERE, 274 FROM_HERE,
275 NewRunnableFunction(&PluginUpdater::OnUpdatePreferences, 275 NewRunnableFunction(&PluginUpdater::OnUpdatePreferences,
276 static_cast<Profile*>(profile), 276 static_cast<Profile*>(profile),
277 plugins, groups)); 277 plugins, groups));
278 } 278 }
279 279
280 void PluginUpdater::OnUpdatePreferences( 280 void PluginUpdater::OnUpdatePreferences(
281 Profile* profile, 281 Profile* profile,
282 const std::vector<webkit::npapi::WebPluginInfo>& plugins, 282 const std::vector<webkit::WebPluginInfo>& plugins,
283 const std::vector<webkit::npapi::PluginGroup>& groups) { 283 const std::vector<webkit::npapi::PluginGroup>& groups) {
284 ListPrefUpdate update(profile->GetPrefs(), prefs::kPluginsPluginsList); 284 ListPrefUpdate update(profile->GetPrefs(), prefs::kPluginsPluginsList);
285 ListValue* plugins_list = update.Get(); 285 ListValue* plugins_list = update.Get();
286 plugins_list->Clear(); 286 plugins_list->Clear();
287 287
288 FilePath internal_dir; 288 FilePath internal_dir;
289 if (PathService::Get(chrome::DIR_INTERNAL_PLUGINS, &internal_dir)) 289 if (PathService::Get(chrome::DIR_INTERNAL_PLUGINS, &internal_dir))
290 profile->GetPrefs()->SetFilePath(prefs::kPluginsLastInternalDirectory, 290 profile->GetPrefs()->SetFilePath(prefs::kPluginsLastInternalDirectory,
291 internal_dir); 291 internal_dir);
292 292
293 // Add the plugin files. 293 // Add the plugin files.
294 for (size_t i = 0; i < plugins.size(); ++i) { 294 for (size_t i = 0; i < plugins.size(); ++i) {
295 DictionaryValue* summary = CreatePluginFileSummary(plugins[i]); 295 DictionaryValue* summary = CreatePluginFileSummary(plugins[i]);
296 // If the plugin is managed by policy, store the user preferred state 296 // If the plugin is managed by policy, store the user preferred state
297 // instead. 297 // instead.
298 if (plugins[i].enabled & webkit::npapi::WebPluginInfo::MANAGED_MASK) { 298 if (plugins[i].enabled & webkit::WebPluginInfo::MANAGED_MASK) {
299 bool user_enabled = 299 bool user_enabled =
300 (plugins[i].enabled & webkit::npapi::WebPluginInfo::USER_MASK) == 300 (plugins[i].enabled & webkit::WebPluginInfo::USER_MASK) ==
301 webkit::npapi::WebPluginInfo::USER_ENABLED; 301 webkit::WebPluginInfo::USER_ENABLED;
302 summary->SetBoolean("enabled", user_enabled); 302 summary->SetBoolean("enabled", user_enabled);
303 } 303 }
304 plugins_list->Append(summary); 304 plugins_list->Append(summary);
305 } 305 }
306 306
307 // Add the groups as well. 307 // Add the groups as well.
308 for (size_t i = 0; i < groups.size(); ++i) { 308 for (size_t i = 0; i < groups.size(); ++i) {
309 DictionaryValue* summary = groups[i].GetSummary(); 309 DictionaryValue* summary = groups[i].GetSummary();
310 // If the plugin is disabled only by policy don't store this state in the 310 // If the plugin is disabled only by policy don't store this state in the
311 // user pref store. 311 // user pref store.
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
346 prefs->RegisterFilePathPref(prefs::kPluginsLastInternalDirectory, 346 prefs->RegisterFilePathPref(prefs::kPluginsLastInternalDirectory,
347 internal_dir, 347 internal_dir,
348 PrefService::UNSYNCABLE_PREF); 348 PrefService::UNSYNCABLE_PREF);
349 prefs->RegisterListPref(prefs::kPluginsDisabledPlugins, 349 prefs->RegisterListPref(prefs::kPluginsDisabledPlugins,
350 PrefService::UNSYNCABLE_PREF); 350 PrefService::UNSYNCABLE_PREF);
351 prefs->RegisterListPref(prefs::kPluginsDisabledPluginsExceptions, 351 prefs->RegisterListPref(prefs::kPluginsDisabledPluginsExceptions,
352 PrefService::UNSYNCABLE_PREF); 352 PrefService::UNSYNCABLE_PREF);
353 prefs->RegisterListPref(prefs::kPluginsEnabledPlugins, 353 prefs->RegisterListPref(prefs::kPluginsEnabledPlugins,
354 PrefService::UNSYNCABLE_PREF); 354 PrefService::UNSYNCABLE_PREF);
355 } 355 }
OLDNEW
« no previous file with comments | « chrome/browser/plugin_updater.h ('k') | chrome/browser/ui/cocoa/drag_util.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698