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 "content/browser/plugin_data_remover_impl.h" | 5 #include "content/browser/plugin_data_remover_impl.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/metrics/histogram.h" | 8 #include "base/metrics/histogram.h" |
9 #include "base/synchronization/waitable_event.h" | 9 #include "base/synchronization/waitable_event.h" |
10 #include "base/version.h" | 10 #include "base/version.h" |
(...skipping 14 matching lines...) Expand all Loading... |
25 const char kMinFlashVersion[] = "10.3"; | 25 const char kMinFlashVersion[] = "10.3"; |
26 const int64 kRemovalTimeoutMs = 10000; | 26 const int64 kRemovalTimeoutMs = 10000; |
27 const uint64 kClearAllData = 0; | 27 const uint64 kClearAllData = 0; |
28 | 28 |
29 } // namespace | 29 } // namespace |
30 | 30 |
31 namespace content { | 31 namespace content { |
32 | 32 |
33 // static | 33 // static |
34 PluginDataRemover* PluginDataRemover::Create( | 34 PluginDataRemover* PluginDataRemover::Create( |
35 const content::ResourceContext& resource_context) { | 35 content::ResourceContext* resource_context) { |
36 return new PluginDataRemoverImpl(resource_context); | 36 return new PluginDataRemoverImpl(resource_context); |
37 } | 37 } |
38 | 38 |
39 // static | 39 // static |
40 bool PluginDataRemover::IsSupported(webkit::WebPluginInfo* plugin) { | 40 bool PluginDataRemover::IsSupported(webkit::WebPluginInfo* plugin) { |
41 bool allow_wildcard = false; | 41 bool allow_wildcard = false; |
42 std::vector<webkit::WebPluginInfo> plugins; | 42 std::vector<webkit::WebPluginInfo> plugins; |
43 PluginService::GetInstance()->GetPluginInfoArray( | 43 PluginService::GetInstance()->GetPluginInfoArray( |
44 GURL(), kFlashMimeType, allow_wildcard, &plugins, NULL); | 44 GURL(), kFlashMimeType, allow_wildcard, &plugins, NULL); |
45 std::vector<webkit::WebPluginInfo>::iterator plugin_it = plugins.begin(); | 45 std::vector<webkit::WebPluginInfo>::iterator plugin_it = plugins.begin(); |
(...skipping 11 matching lines...) Expand all Loading... |
57 | 57 |
58 } | 58 } |
59 | 59 |
60 class PluginDataRemoverImpl::Context | 60 class PluginDataRemoverImpl::Context |
61 : public PluginProcessHost::Client, | 61 : public PluginProcessHost::Client, |
62 public IPC::Channel::Listener, | 62 public IPC::Channel::Listener, |
63 public base::RefCountedThreadSafe<Context, | 63 public base::RefCountedThreadSafe<Context, |
64 BrowserThread::DeleteOnIOThread> { | 64 BrowserThread::DeleteOnIOThread> { |
65 public: | 65 public: |
66 Context(base::Time begin_time, | 66 Context(base::Time begin_time, |
67 const content::ResourceContext& resource_context) | 67 content::ResourceContext* resource_context) |
68 : event_(new base::WaitableEvent(true, false)), | 68 : event_(new base::WaitableEvent(true, false)), |
69 begin_time_(begin_time), | 69 begin_time_(begin_time), |
70 is_removing_(false), | 70 is_removing_(false), |
71 resource_context_(resource_context), | 71 resource_context_(resource_context), |
72 channel_(NULL) { | 72 channel_(NULL) { |
73 } | 73 } |
74 | 74 |
75 virtual ~Context() { | 75 virtual ~Context() { |
76 } | 76 } |
77 | 77 |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
109 // PluginProcessHost::Client methods. | 109 // PluginProcessHost::Client methods. |
110 virtual int ID() OVERRIDE { | 110 virtual int ID() OVERRIDE { |
111 // Generate a unique identifier for this PluginProcessHostClient. | 111 // Generate a unique identifier for this PluginProcessHostClient. |
112 return ChildProcessHostImpl::GenerateChildProcessUniqueId(); | 112 return ChildProcessHostImpl::GenerateChildProcessUniqueId(); |
113 } | 113 } |
114 | 114 |
115 virtual bool OffTheRecord() OVERRIDE { | 115 virtual bool OffTheRecord() OVERRIDE { |
116 return false; | 116 return false; |
117 } | 117 } |
118 | 118 |
119 virtual const content::ResourceContext& GetResourceContext() OVERRIDE { | 119 virtual content::ResourceContext* GetResourceContext() OVERRIDE { |
120 return resource_context_; | 120 return resource_context_; |
121 } | 121 } |
122 | 122 |
123 virtual void SetPluginInfo(const webkit::WebPluginInfo& info) OVERRIDE { | 123 virtual void SetPluginInfo(const webkit::WebPluginInfo& info) OVERRIDE { |
124 } | 124 } |
125 | 125 |
126 virtual void OnFoundPluginProcessHost(PluginProcessHost* host) OVERRIDE { | 126 virtual void OnFoundPluginProcessHost(PluginProcessHost* host) OVERRIDE { |
127 } | 127 } |
128 | 128 |
129 virtual void OnSentPluginChannelRequest() OVERRIDE { | 129 virtual void OnSentPluginChannelRequest() OVERRIDE { |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
207 } | 207 } |
208 | 208 |
209 scoped_ptr<base::WaitableEvent> event_; | 209 scoped_ptr<base::WaitableEvent> event_; |
210 // The point in time when we start removing data. | 210 // The point in time when we start removing data. |
211 base::Time remove_start_time_; | 211 base::Time remove_start_time_; |
212 // The point in time from which on we remove data. | 212 // The point in time from which on we remove data. |
213 base::Time begin_time_; | 213 base::Time begin_time_; |
214 bool is_removing_; | 214 bool is_removing_; |
215 | 215 |
216 // The resource context for the profile. | 216 // The resource context for the profile. |
217 const content::ResourceContext& resource_context_; | 217 content::ResourceContext* resource_context_; |
218 | 218 |
219 // The channel is NULL until we have opened a connection to the plug-in | 219 // The channel is NULL until we have opened a connection to the plug-in |
220 // process. | 220 // process. |
221 scoped_ptr<IPC::Channel> channel_; | 221 scoped_ptr<IPC::Channel> channel_; |
222 }; | 222 }; |
223 | 223 |
224 | 224 |
225 PluginDataRemoverImpl::PluginDataRemoverImpl( | 225 PluginDataRemoverImpl::PluginDataRemoverImpl( |
226 const content::ResourceContext& resource_context) | 226 content::ResourceContext* resource_context) |
227 : mime_type_(kFlashMimeType), | 227 : mime_type_(kFlashMimeType), |
228 resource_context_(resource_context) { | 228 resource_context_(resource_context) { |
229 } | 229 } |
230 | 230 |
231 PluginDataRemoverImpl::~PluginDataRemoverImpl() { | 231 PluginDataRemoverImpl::~PluginDataRemoverImpl() { |
232 } | 232 } |
233 | 233 |
234 base::WaitableEvent* PluginDataRemoverImpl::StartRemoving( | 234 base::WaitableEvent* PluginDataRemoverImpl::StartRemoving( |
235 base::Time begin_time) { | 235 base::Time begin_time) { |
236 DCHECK(!context_.get()); | 236 DCHECK(!context_.get()); |
237 context_ = new Context(begin_time, resource_context_); | 237 context_ = new Context(begin_time, resource_context_); |
238 context_->Init(mime_type_); | 238 context_->Init(mime_type_); |
239 return context_->event(); | 239 return context_->event(); |
240 } | 240 } |
OLD | NEW |