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

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

Issue 1991005: (1) Group plugins with the same name together. (2) Show a download link for p... (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: '' Created 10 years, 6 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/dom_ui/plugins_ui.cc ('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/extensions/extension.h" 27 #include "chrome/common/extensions/extension.h"
27 #include "chrome/common/gpu_plugin.h" 28 #include "chrome/common/gpu_plugin.h"
28 #include "chrome/common/logging_chrome.h" 29 #include "chrome/common/logging_chrome.h"
29 #include "chrome/common/notification_type.h" 30 #include "chrome/common/notification_type.h"
(...skipping 19 matching lines...) Expand all
49 } 50 }
50 #endif 51 #endif
51 52
52 // static 53 // static
53 bool PluginService::enable_chrome_plugins_ = true; 54 bool PluginService::enable_chrome_plugins_ = true;
54 55
55 // static 56 // static
56 void PluginService::InitGlobalInstance(Profile* profile) { 57 void PluginService::InitGlobalInstance(Profile* profile) {
57 DCHECK(ChromeThread::CurrentlyOn(ChromeThread::UI)); 58 DCHECK(ChromeThread::CurrentlyOn(ChromeThread::UI));
58 59
59 bool update_internal_dir = false; 60 // We first group the plugins and then figure out which groups to disable.
60 FilePath last_internal_dir = 61 PluginUpdater::GetInstance()->DisablePluginGroupsFromPrefs(profile);
61 profile->GetPrefs()->GetFilePath(prefs::kPluginsLastInternalDirectory);
62 FilePath cur_internal_dir;
63 if (PathService::Get(chrome::DIR_INTERNAL_PLUGINS, &cur_internal_dir))
64 update_internal_dir = (cur_internal_dir != last_internal_dir);
65
66 // Disable plugins listed as disabled in prefs.
67 if (const ListValue* saved_plugins_list =
68 profile->GetPrefs()->GetList(prefs::kPluginsPluginsList)) {
69 for (ListValue::const_iterator it = saved_plugins_list->begin();
70 it != saved_plugins_list->end();
71 ++it) {
72 if (!(*it)->IsType(Value::TYPE_DICTIONARY)) {
73 LOG(WARNING) << "Invalid entry in " << prefs::kPluginsPluginsList;
74 continue; // Oops, don't know what to do with this item.
75 }
76
77 DictionaryValue* plugin = static_cast<DictionaryValue*>(*it);
78 FilePath::StringType path;
79 bool enabled = true;
80 plugin->GetBoolean(L"enabled", &enabled);
81 if (!enabled && plugin->GetString(L"path", &path)) {
82 FilePath plugin_path(path);
83 NPAPI::PluginList::Singleton()->DisablePlugin(plugin_path);
84
85 // If the internal plugin directory has changed and if the plugin looks
86 // internal, also disable it in the current internal plugins directory.
87 if (update_internal_dir &&
88 plugin_path.DirName() == last_internal_dir) {
89 NPAPI::PluginList::Singleton()->DisablePlugin(
90 cur_internal_dir.Append(plugin_path.BaseName()));
91 }
92 }
93 }
94 }
95 62
96 // Have Chrome plugins write their data to the profile directory. 63 // Have Chrome plugins write their data to the profile directory.
97 GetInstance()->SetChromePluginDataDir(profile->GetPath()); 64 GetInstance()->SetChromePluginDataDir(profile->GetPath());
98 } 65 }
99 66
100 // static 67 // static
101 PluginService* PluginService::GetInstance() { 68 PluginService* PluginService::GetInstance() {
102 return Singleton<PluginService>::get(); 69 return Singleton<PluginService>::get();
103 } 70 }
104 71
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after
368 PrivatePluginMap::iterator it = private_plugins_.find(plugin_path); 335 PrivatePluginMap::iterator it = private_plugins_.find(plugin_path);
369 if (it == private_plugins_.end()) 336 if (it == private_plugins_.end())
370 return true; // This plugin is not private, so it's allowed everywhere. 337 return true; // This plugin is not private, so it's allowed everywhere.
371 338
372 // We do a dumb compare of scheme and host, rather than using the domain 339 // We do a dumb compare of scheme and host, rather than using the domain
373 // service, since we only care about this for extensions. 340 // service, since we only care about this for extensions.
374 const GURL& required_url = it->second; 341 const GURL& required_url = it->second;
375 return (url.scheme() == required_url.scheme() && 342 return (url.scheme() == required_url.scheme() &&
376 url.host() == required_url.host()); 343 url.host() == required_url.host());
377 } 344 }
OLDNEW
« no previous file with comments | « chrome/browser/dom_ui/plugins_ui.cc ('k') | chrome/browser/plugin_updater.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698