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

Side by Side Diff: content/browser/plugin_service_impl.cc

Issue 632833002: Remove raw handles from base::win::RegKey (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove XP specific code. Created 6 years, 2 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 | « content/browser/plugin_service_impl.h ('k') | net/dns/dns_config_service_win.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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "content/browser/plugin_service_impl.h" 5 #include "content/browser/plugin_service_impl.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/compiler_specific.h" 9 #include "base/compiler_specific.h"
10 #include "base/files/file_path.h" 10 #include "base/files/file_path.h"
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 // the number of processes which start at least one NPAPI/PPAPI Flash process. 150 // the number of processes which start at least one NPAPI/PPAPI Flash process.
151 static bool counted = false; 151 static bool counted = false;
152 if (!counted) { 152 if (!counted) {
153 counted = true; 153 counted = true;
154 UMA_HISTOGRAM_ENUMERATION("Plugin.FlashUsage", TOTAL_BROWSER_PROCESSES, 154 UMA_HISTOGRAM_ENUMERATION("Plugin.FlashUsage", TOTAL_BROWSER_PROCESSES,
155 FLASH_USAGE_ENUM_COUNT); 155 FLASH_USAGE_ENUM_COUNT);
156 } 156 }
157 } 157 }
158 158
159 PluginServiceImpl::~PluginServiceImpl() { 159 PluginServiceImpl::~PluginServiceImpl() {
160 #if defined(OS_WIN)
161 // Release the events since they're owned by RegKey, not WaitableEvent.
162 hkcu_watcher_.StopWatching();
163 hklm_watcher_.StopWatching();
164 if (hkcu_event_)
165 hkcu_event_->Release();
166 if (hklm_event_)
167 hklm_event_->Release();
168 #endif
169 // Make sure no plugin channel requests have been leaked. 160 // Make sure no plugin channel requests have been leaked.
170 DCHECK(pending_plugin_clients_.empty()); 161 DCHECK(pending_plugin_clients_.empty());
171 } 162 }
172 163
173 void PluginServiceImpl::Init() { 164 void PluginServiceImpl::Init() {
174 plugin_list_token_ = BrowserThread::GetBlockingPool()->GetSequenceToken(); 165 plugin_list_token_ = BrowserThread::GetBlockingPool()->GetSequenceToken();
175 PluginList::Singleton()->set_will_load_plugins_callback( 166 PluginList::Singleton()->set_will_load_plugins_callback(
176 base::Bind(&WillLoadPluginsCallback, plugin_list_token_)); 167 base::Bind(&WillLoadPluginsCallback, plugin_list_token_));
177 168
178 RegisterPepperPlugins(); 169 RegisterPepperPlugins();
(...skipping 14 matching lines...) Expand all
193 } 184 }
194 185
195 void PluginServiceImpl::StartWatchingPlugins() { 186 void PluginServiceImpl::StartWatchingPlugins() {
196 // Start watching for changes in the plugin list. This means watching 187 // Start watching for changes in the plugin list. This means watching
197 // for changes in the Windows registry keys and on both Windows and POSIX 188 // for changes in the Windows registry keys and on both Windows and POSIX
198 // watch for changes in the paths that are expected to contain plugins. 189 // watch for changes in the paths that are expected to contain plugins.
199 #if defined(OS_WIN) 190 #if defined(OS_WIN)
200 if (hkcu_key_.Create(HKEY_CURRENT_USER, 191 if (hkcu_key_.Create(HKEY_CURRENT_USER,
201 kRegistryMozillaPlugins, 192 kRegistryMozillaPlugins,
202 KEY_NOTIFY) == ERROR_SUCCESS) { 193 KEY_NOTIFY) == ERROR_SUCCESS) {
203 if (hkcu_key_.StartWatching() == ERROR_SUCCESS) { 194 base::win::RegKey::ChangeCallback callback =
204 hkcu_event_.reset(new base::WaitableEvent(hkcu_key_.watch_event())); 195 base::Bind(&PluginServiceImpl::OnKeyChanged, base::Unretained(this),
205 base::WaitableEventWatcher::EventCallback callback = 196 base::Unretained(&hkcu_key_));
206 base::Bind(&PluginServiceImpl::OnWaitableEventSignaled, 197 hkcu_key_.StartWatching(callback);
207 base::Unretained(this));
208 hkcu_watcher_.StartWatching(hkcu_event_.get(), callback);
209 }
210 } 198 }
211 if (hklm_key_.Create(HKEY_LOCAL_MACHINE, 199 if (hklm_key_.Create(HKEY_LOCAL_MACHINE,
212 kRegistryMozillaPlugins, 200 kRegistryMozillaPlugins,
213 KEY_NOTIFY) == ERROR_SUCCESS) { 201 KEY_NOTIFY) == ERROR_SUCCESS) {
214 if (hklm_key_.StartWatching() == ERROR_SUCCESS) { 202 base::win::RegKey::ChangeCallback callback =
215 hklm_event_.reset(new base::WaitableEvent(hklm_key_.watch_event())); 203 base::Bind(&PluginServiceImpl::OnKeyChanged, base::Unretained(this),
216 base::WaitableEventWatcher::EventCallback callback = 204 base::Unretained(&hkcu_key_));
217 base::Bind(&PluginServiceImpl::OnWaitableEventSignaled, 205 hklm_key_.StartWatching(callback);
218 base::Unretained(this));
219 hklm_watcher_.StartWatching(hklm_event_.get(), callback);
220 }
221 } 206 }
222 #endif 207 #endif
223 #if defined(OS_POSIX) && !defined(OS_OPENBSD) && !defined(OS_ANDROID) 208 #if defined(OS_POSIX) && !defined(OS_OPENBSD) && !defined(OS_ANDROID)
224 // On ChromeOS the user can't install plugins anyway and on Windows all 209 // On ChromeOS the user can't install plugins anyway and on Windows all
225 // important plugins register themselves in the registry so no need to do that. 210 // important plugins register themselves in the registry so no need to do that.
226 211
227 // Get the list of all paths for registering the FilePathWatchers 212 // Get the list of all paths for registering the FilePathWatchers
228 // that will track and if needed reload the list of plugins on runtime. 213 // that will track and if needed reload the list of plugins on runtime.
229 std::vector<base::FilePath> plugin_dirs; 214 std::vector<base::FilePath> plugin_dirs;
230 PluginList::Singleton()->GetPluginDirectories(&plugin_dirs); 215 PluginList::Singleton()->GetPluginDirectories(&plugin_dirs);
(...skipping 404 matching lines...) Expand 10 before | Expand all | Expand 10 after
635 // sure g_thread_init() gets called since plugins may call glib at load. 620 // sure g_thread_init() gets called since plugins may call glib at load.
636 621
637 if (!plugin_loader_.get()) 622 if (!plugin_loader_.get())
638 plugin_loader_ = new PluginLoaderPosix; 623 plugin_loader_ = new PluginLoaderPosix;
639 624
640 plugin_loader_->GetPlugins( 625 plugin_loader_->GetPlugins(
641 base::Bind(&ForwardCallback, make_scoped_refptr(target_loop), callback)); 626 base::Bind(&ForwardCallback, make_scoped_refptr(target_loop), callback));
642 } 627 }
643 #endif 628 #endif
644 629
645 void PluginServiceImpl::OnWaitableEventSignaled(
646 base::WaitableEvent* waitable_event) {
647 #if defined(OS_WIN) 630 #if defined(OS_WIN)
648 if (waitable_event == hkcu_event_) { 631 void PluginServiceImpl::OnKeyChanged(base::win::RegKey* key) {
649 hkcu_key_.StartWatching(); 632 key->StartWatching(base::Bind(&PluginServiceImpl::OnKeyChanged,
650 } else { 633 base::Unretained(this),
651 hklm_key_.StartWatching(); 634 base::Unretained(&hkcu_key_)));
652 }
653 635
654 PluginList::Singleton()->RefreshPlugins(); 636 PluginList::Singleton()->RefreshPlugins();
655 PurgePluginListCache(NULL, false); 637 PurgePluginListCache(NULL, false);
656 #else 638 }
657 // This event should only get signaled on a Windows machine.
658 NOTREACHED();
659 #endif // defined(OS_WIN) 639 #endif // defined(OS_WIN)
660 }
661 640
662 void PluginServiceImpl::RegisterPepperPlugins() { 641 void PluginServiceImpl::RegisterPepperPlugins() {
663 ComputePepperPluginList(&ppapi_plugins_); 642 ComputePepperPluginList(&ppapi_plugins_);
664 for (size_t i = 0; i < ppapi_plugins_.size(); ++i) { 643 for (size_t i = 0; i < ppapi_plugins_.size(); ++i) {
665 RegisterInternalPlugin(ppapi_plugins_[i].ToWebPluginInfo(), true); 644 RegisterInternalPlugin(ppapi_plugins_[i].ToWebPluginInfo(), true);
666 } 645 }
667 } 646 }
668 647
669 // There should generally be very few plugins so a brute-force search is fine. 648 // There should generally be very few plugins so a brute-force search is fine.
670 PepperPluginInfo* PluginServiceImpl::GetRegisteredPpapiPluginInfo( 649 PepperPluginInfo* PluginServiceImpl::GetRegisteredPpapiPluginInfo(
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
859 #endif 838 #endif
860 839
861 bool PluginServiceImpl::PpapiDevChannelSupported( 840 bool PluginServiceImpl::PpapiDevChannelSupported(
862 BrowserContext* browser_context, 841 BrowserContext* browser_context,
863 const GURL& document_url) { 842 const GURL& document_url) {
864 return content::GetContentClient()->browser()-> 843 return content::GetContentClient()->browser()->
865 IsPluginAllowedToUseDevChannelAPIs(browser_context, document_url); 844 IsPluginAllowedToUseDevChannelAPIs(browser_context, document_url);
866 } 845 }
867 846
868 } // namespace content 847 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/plugin_service_impl.h ('k') | net/dns/dns_config_service_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698