OLD | NEW |
---|---|
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_data_remover_helper.h" | 5 #include "chrome/browser/plugin_data_remover_helper.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/callback.h" | |
10 #include "base/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
11 #include "chrome/browser/plugin_data_remover.h" | 12 #include "chrome/browser/plugin_data_remover.h" |
12 #include "chrome/browser/plugin_prefs.h" | 13 #include "chrome/browser/plugin_prefs.h" |
13 #include "chrome/browser/prefs/pref_service.h" | 14 #include "chrome/browser/prefs/pref_service.h" |
14 #include "chrome/browser/profiles/profile.h" | 15 #include "chrome/browser/profiles/profile.h" |
15 #include "chrome/common/chrome_notification_types.h" | 16 #include "chrome/common/chrome_notification_types.h" |
16 #include "content/browser/browser_thread.h" | 17 #include "content/browser/browser_thread.h" |
18 #include "content/browser/plugin_service.h" | |
17 #include "content/common/notification_service.h" | 19 #include "content/common/notification_service.h" |
18 | 20 |
19 // The internal class is refcounted so it can outlive PluginDataRemoverHelper. | 21 // The internal class is refcounted so it can outlive PluginDataRemoverHelper. |
Bernhard Bauer
2011/10/05 13:00:46
If we're doing everything on the UI thread now, th
Robert Sesek
2011/10/05 18:27:16
Done.
| |
20 class PluginDataRemoverHelper::Internal | 22 class PluginDataRemoverHelper::Internal |
21 : public base::RefCountedThreadSafe<PluginDataRemoverHelper::Internal> { | 23 : public base::RefCountedThreadSafe<PluginDataRemoverHelper::Internal> { |
22 public: | 24 public: |
23 Internal(const char* pref_name, Profile* profile) | 25 Internal(const char* pref_name, Profile* profile) |
24 : pref_name_(pref_name), profile_(profile) {} | 26 : pref_name_(pref_name), profile_(profile) {} |
25 | 27 |
26 void StartUpdate() { | 28 void StartUpdate() { |
27 BrowserThread::PostTask( | 29 PluginService::GetInstance()->GetPlugins( |
28 BrowserThread::FILE, | 30 base::Bind(&PluginDataRemoverHelper::Internal::GotPlugins, this, |
29 FROM_HERE, | 31 make_scoped_refptr(PluginPrefs::GetForProfile(profile_)))); |
30 base::Bind(&PluginDataRemoverHelper::Internal::UpdateOnFileThread, | |
31 this, | |
32 make_scoped_refptr(PluginPrefs::GetForProfile(profile_)))); | |
33 } | 32 } |
34 | 33 |
35 void Invalidate() { | 34 void Invalidate() { |
36 profile_ = NULL; | 35 profile_ = NULL; |
37 } | 36 } |
38 | 37 |
39 private: | 38 private: |
40 friend class base::RefCountedThreadSafe<Internal>; | 39 friend class base::RefCountedThreadSafe<Internal>; |
41 | 40 |
42 ~Internal() {} | 41 ~Internal() {} |
43 | 42 |
44 void UpdateOnFileThread(scoped_refptr<PluginPrefs> plugin_prefs) { | 43 void GotPlugins(scoped_refptr<PluginPrefs> plugin_prefs, |
45 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); | 44 const std::vector<webkit::WebPluginInfo>& plugins) { |
46 bool result = PluginDataRemover::IsSupported(plugin_prefs); | 45 bool result = PluginDataRemover::IsSupported(plugin_prefs); |
47 BrowserThread::PostTask( | 46 BrowserThread::PostTask( |
48 BrowserThread::UI, | 47 BrowserThread::UI, |
49 FROM_HERE, | 48 FROM_HERE, |
50 base::Bind(&PluginDataRemoverHelper::Internal::SetPrefOnUIThread, | 49 base::Bind(&PluginDataRemoverHelper::Internal::SetPrefOnUIThread, |
51 this, | 50 this, |
52 result)); | 51 result)); |
53 } | 52 } |
54 | 53 |
55 void SetPrefOnUIThread(bool value) { | 54 void SetPrefOnUIThread(bool value) { |
(...skipping 29 matching lines...) Expand all Loading... | |
85 | 84 |
86 void PluginDataRemoverHelper::Observe(int type, | 85 void PluginDataRemoverHelper::Observe(int type, |
87 const NotificationSource& source, | 86 const NotificationSource& source, |
88 const NotificationDetails& details) { | 87 const NotificationDetails& details) { |
89 if (type == chrome::NOTIFICATION_PLUGIN_ENABLE_STATUS_CHANGED) { | 88 if (type == chrome::NOTIFICATION_PLUGIN_ENABLE_STATUS_CHANGED) { |
90 internal_->StartUpdate(); | 89 internal_->StartUpdate(); |
91 } else { | 90 } else { |
92 NOTREACHED(); | 91 NOTREACHED(); |
93 } | 92 } |
94 } | 93 } |
OLD | NEW |