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

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

Issue 2811037: Group plugins in about:plugins and show update link for out-of-date ones. (Closed) Base URL: git://codf21.jail.google.com/chromium.git
Patch Set: Fix some HTML issues. 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 | « chrome/browser/plugin_service.h ('k') | chrome/browser/plugin_updater.h » ('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 "build/build_config.h" 5 #include "build/build_config.h"
6 6
7 #include "chrome/browser/plugin_service.h" 7 #include "chrome/browser/plugin_service.h"
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/path_service.h" 10 #include "base/path_service.h"
11 #include "base/string_util.h" 11 #include "base/string_util.h"
12 #include "base/thread.h" 12 #include "base/thread.h"
13 #include "base/values.h" 13 #include "base/values.h"
14 #include "base/waitable_event.h" 14 #include "base/waitable_event.h"
15 #include "chrome/browser/browser_process.h" 15 #include "chrome/browser/browser_process.h"
16 #include "chrome/browser/chrome_plugin_host.h" 16 #include "chrome/browser/chrome_plugin_host.h"
17 #include "chrome/browser/chrome_thread.h" 17 #include "chrome/browser/chrome_thread.h"
18 #include "chrome/browser/extensions/extensions_service.h" 18 #include "chrome/browser/extensions/extensions_service.h"
19 #include "chrome/browser/plugin_process_host.h" 19 #include "chrome/browser/plugin_process_host.h"
20 #include "chrome/browser/plugin_updater.h"
20 #include "chrome/browser/pref_service.h" 21 #include "chrome/browser/pref_service.h"
21 #include "chrome/browser/profile.h" 22 #include "chrome/browser/profile.h"
22 #include "chrome/browser/renderer_host/render_process_host.h" 23 #include "chrome/browser/renderer_host/render_process_host.h"
23 #include "chrome/common/chrome_plugin_lib.h" 24 #include "chrome/common/chrome_plugin_lib.h"
24 #include "chrome/common/chrome_paths.h" 25 #include "chrome/common/chrome_paths.h"
25 #include "chrome/common/chrome_switches.h" 26 #include "chrome/common/chrome_switches.h"
26 #include "chrome/common/default_plugin.h" 27 #include "chrome/common/default_plugin.h"
27 #include "chrome/common/extensions/extension.h" 28 #include "chrome/common/extensions/extension.h"
28 #include "chrome/common/gpu_plugin.h" 29 #include "chrome/common/gpu_plugin.h"
29 #include "chrome/common/logging_chrome.h" 30 #include "chrome/common/logging_chrome.h"
(...skipping 16 matching lines...) Expand all
46 for (ChildProcessHost::Iterator iter(ChildProcessInfo::PLUGIN_PROCESS); 47 for (ChildProcessHost::Iterator iter(ChildProcessInfo::PLUGIN_PROCESS);
47 !iter.Done(); ++iter) { 48 !iter.Done(); ++iter) {
48 PluginProcessHost* plugin = static_cast<PluginProcessHost*>(*iter); 49 PluginProcessHost* plugin = static_cast<PluginProcessHost*>(*iter);
49 plugin->OnAppActivation(); 50 plugin->OnAppActivation();
50 } 51 }
51 } 52 }
52 #endif 53 #endif
53 54
54 // static 55 // static
55 bool PluginService::enable_chrome_plugins_ = true; 56 bool PluginService::enable_chrome_plugins_ = true;
56 #if defined(OS_CHROMEOS)
57 bool PluginService::enable_internal_pdf_ = true;
58 #else
59 bool PluginService::enable_internal_pdf_ = false;
60 #endif
61 57
62 // static 58 // static
63 void PluginService::InitGlobalInstance(Profile* profile) { 59 void PluginService::InitGlobalInstance(Profile* profile) {
64 DCHECK(ChromeThread::CurrentlyOn(ChromeThread::UI)); 60 DCHECK(ChromeThread::CurrentlyOn(ChromeThread::UI));
65 61
66 bool update_internal_dir = false; 62 // We first group the plugins and then figure out which groups to disable.
67 FilePath last_internal_dir = 63 PluginUpdater::GetInstance()->DisablePluginGroupsFromPrefs(profile);
68 profile->GetPrefs()->GetFilePath(prefs::kPluginsLastInternalDirectory);
69 FilePath cur_internal_dir;
70 if (PathService::Get(chrome::DIR_INTERNAL_PLUGINS, &cur_internal_dir) &&
71 cur_internal_dir != last_internal_dir) {
72 update_internal_dir = true;
73 profile->GetPrefs()->SetFilePath(
74 prefs::kPluginsLastInternalDirectory, cur_internal_dir);
75 }
76
77 bool found_internal_pdf = false;
78 bool force_enable_internal_pdf = false;
79 FilePath pdf_path;
80 PathService::Get(chrome::FILE_PDF_PLUGIN, &pdf_path);
81 FilePath::StringType pdf_path_str = pdf_path.value();
82 if (enable_internal_pdf_ &&
83 !profile->GetPrefs()->GetBoolean(prefs::kPluginsEnabledInternalPDF)) {
84 // We switched to the internal pdf plugin being on by default, and so we
85 // need to force it to be enabled. We only want to do it this once though,
86 // i.e. we don't want to enable it again if the user disables it afterwards.
87 profile->GetPrefs()->SetBoolean(prefs::kPluginsEnabledInternalPDF, true);
88 force_enable_internal_pdf = true;
89 }
90
91 // Disable plugins listed as disabled in prefs.
92 if (ListValue* saved_plugins_list =
93 profile->GetPrefs()->GetMutableList(prefs::kPluginsPluginsList)) {
94 for (ListValue::const_iterator it = saved_plugins_list->begin();
95 it != saved_plugins_list->end();
96 ++it) {
97 if (!(*it)->IsType(Value::TYPE_DICTIONARY)) {
98 LOG(WARNING) << "Invalid entry in " << prefs::kPluginsPluginsList;
99 continue; // Oops, don't know what to do with this item.
100 }
101
102 DictionaryValue* plugin = static_cast<DictionaryValue*>(*it);
103 FilePath::StringType path;
104 if (!plugin->GetString(L"path", &path))
105 continue;
106
107 bool enabled = true;
108 plugin->GetBoolean(L"enabled", &enabled);
109
110 FilePath plugin_path(path);
111 if (update_internal_dir &&
112 FilePath::CompareIgnoreCase(plugin_path.DirName().value(),
113 last_internal_dir.value()) == 0) {
114 // If the internal plugin directory has changed and if the plugin looks
115 // internal, update its path in the prefs.
116 plugin_path = cur_internal_dir.Append(plugin_path.BaseName());
117 path = plugin_path.value();
118 plugin->SetString(L"path", path);
119 }
120
121 if (FilePath::CompareIgnoreCase(path, pdf_path_str) == 0) {
122 found_internal_pdf = true;
123 if (!enabled && force_enable_internal_pdf) {
124 enabled = true;
125 plugin->SetBoolean(L"enabled", true);
126 }
127 }
128
129 if (!enabled)
130 NPAPI::PluginList::Singleton()->DisablePlugin(plugin_path);
131 }
132 }
133
134 if (!enable_internal_pdf_ && !found_internal_pdf) {
135 // The internal PDF plugin is disabled by default, and the user hasn't
136 // overridden the default.
137 NPAPI::PluginList::Singleton()->DisablePlugin(pdf_path);
138 }
139 64
140 // Have Chrome plugins write their data to the profile directory. 65 // Have Chrome plugins write their data to the profile directory.
141 GetInstance()->SetChromePluginDataDir(profile->GetPath()); 66 GetInstance()->SetChromePluginDataDir(profile->GetPath());
142 } 67 }
143 68
144 // static 69 // static
145 PluginService* PluginService::GetInstance() { 70 PluginService* PluginService::GetInstance() {
146 return Singleton<PluginService>::get(); 71 return Singleton<PluginService>::get();
147 } 72 }
148 73
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after
441 info.mime_types = ASCIIToWide(JoinString(plugins[i].mime_types, '|')); 366 info.mime_types = ASCIIToWide(JoinString(plugins[i].mime_types, '|'));
442 367
443 // These NPAPI entry points will never be called. TODO(darin): Come up 368 // These NPAPI entry points will never be called. TODO(darin): Come up
444 // with a cleaner way to register pepper plugins with the NPAPI PluginList, 369 // with a cleaner way to register pepper plugins with the NPAPI PluginList,
445 // or perhaps refactor the PluginList to be less specific to NPAPI. 370 // or perhaps refactor the PluginList to be less specific to NPAPI.
446 memset(&info.entry_points, 0, sizeof(info.entry_points)); 371 memset(&info.entry_points, 0, sizeof(info.entry_points));
447 372
448 NPAPI::PluginList::Singleton()->RegisterInternalPlugin(info); 373 NPAPI::PluginList::Singleton()->RegisterInternalPlugin(info);
449 } 374 }
450 } 375 }
OLDNEW
« no previous file with comments | « chrome/browser/plugin_service.h ('k') | chrome/browser/plugin_updater.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698