OLD | NEW |
---|---|
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_data_remover_impl.h" | 5 #include "content/browser/plugin_data_remover_impl.h" |
6 | 6 |
7 #include <limits> | 7 #include <limits> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
11 #include "base/sequenced_task_runner_helpers.h" | 11 #include "base/sequenced_task_runner_helpers.h" |
12 #include "base/synchronization/waitable_event.h" | 12 #include "base/synchronization/waitable_event.h" |
13 #include "base/utf_string_conversions.h" | 13 #include "base/utf_string_conversions.h" |
14 #include "base/version.h" | 14 #include "base/version.h" |
15 #include "content/browser/plugin_process_host.h" | 15 #include "content/browser/plugin_process_host.h" |
16 #include "content/browser/plugin_service_impl.h" | 16 #include "content/browser/plugin_service_impl.h" |
17 #include "content/browser/renderer_host/pepper/pepper_file_message_filter.h" | 17 #include "content/browser/renderer_host/pepper/pepper_file_message_filter.h" |
18 #include "content/common/child_process_host_impl.h" | 18 #include "content/common/child_process_host_impl.h" |
19 #include "content/common/plugin_messages.h" | 19 #include "content/common/plugin_messages.h" |
20 #include "content/public/browser/browser_context.h" | 20 #include "content/public/browser/browser_context.h" |
21 #include "content/public/browser/browser_thread.h" | 21 #include "content/public/browser/browser_thread.h" |
22 #include "content/public/common/pepper_plugin_info.h" | 22 #include "content/public/common/pepper_plugin_info.h" |
23 #if defined(ENABLE_PPAPI) | |
brettw
2012/11/30 23:18:12
#ifdefed includes should go below all the others,
| |
23 #include "ppapi/proxy/ppapi_messages.h" | 24 #include "ppapi/proxy/ppapi_messages.h" |
25 #endif | |
24 #include "webkit/plugins/npapi/plugin_utils.h" | 26 #include "webkit/plugins/npapi/plugin_utils.h" |
25 #include "webkit/plugins/plugin_constants.h" | 27 #include "webkit/plugins/plugin_constants.h" |
26 | 28 |
27 namespace content { | 29 namespace content { |
28 | 30 |
29 namespace { | 31 namespace { |
30 | 32 |
31 // The minimum Flash Player version that implements NPP_ClearSiteData. | 33 // The minimum Flash Player version that implements NPP_ClearSiteData. |
32 const char kMinFlashVersion[] = "10.3"; | 34 const char kMinFlashVersion[] = "10.3"; |
33 const int64 kRemovalTimeoutMs = 10000; | 35 const int64 kRemovalTimeoutMs = 10000; |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
171 | 173 |
172 // Balancing the AddRef call. | 174 // Balancing the AddRef call. |
173 Release(); | 175 Release(); |
174 } | 176 } |
175 | 177 |
176 // IPC::Listener methods. | 178 // IPC::Listener methods. |
177 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE { | 179 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE { |
178 IPC_BEGIN_MESSAGE_MAP(Context, message) | 180 IPC_BEGIN_MESSAGE_MAP(Context, message) |
179 IPC_MESSAGE_HANDLER(PluginHostMsg_ClearSiteDataResult, | 181 IPC_MESSAGE_HANDLER(PluginHostMsg_ClearSiteDataResult, |
180 OnClearSiteDataResult) | 182 OnClearSiteDataResult) |
183 #if defined(ENABLE_PPAPI) | |
181 IPC_MESSAGE_HANDLER(PpapiHostMsg_ClearSiteDataResult, | 184 IPC_MESSAGE_HANDLER(PpapiHostMsg_ClearSiteDataResult, |
182 OnPpapiClearSiteDataResult) | 185 OnPpapiClearSiteDataResult) |
186 #endif | |
183 IPC_MESSAGE_UNHANDLED_ERROR() | 187 IPC_MESSAGE_UNHANDLED_ERROR() |
184 IPC_END_MESSAGE_MAP() | 188 IPC_END_MESSAGE_MAP() |
185 | 189 |
186 return true; | 190 return true; |
187 } | 191 } |
188 | 192 |
189 virtual void OnChannelError() OVERRIDE { | 193 virtual void OnChannelError() OVERRIDE { |
190 if (is_removing_) { | 194 if (is_removing_) { |
191 NOTREACHED() << "Channel error"; | 195 NOTREACHED() << "Channel error"; |
192 SignalDone(); | 196 SignalDone(); |
193 } | 197 } |
194 } | 198 } |
195 | 199 |
196 base::WaitableEvent* event() { return event_.get(); } | 200 base::WaitableEvent* event() { return event_.get(); } |
197 | 201 |
198 private: | 202 private: |
199 friend struct BrowserThread::DeleteOnThread<BrowserThread::IO>; | 203 friend struct BrowserThread::DeleteOnThread<BrowserThread::IO>; |
200 friend class base::DeleteHelper<Context>; | 204 friend class base::DeleteHelper<Context>; |
201 virtual ~Context() {} | 205 virtual ~Context() {} |
202 | 206 |
207 IPC::Message* CreatePpapiClearSiteDataMsg(uint64 max_age) { | |
208 #if defined(ENABLE_PPAPI) | |
209 FilePath profile_path = | |
210 PepperFileMessageFilter::GetDataDirName(browser_context_path_); | |
211 // TODO(vtl): This "duplicates" logic in webkit/plugins/ppapi/file_path.cc | |
212 // (which prepends the plugin name to the relative part of the path | |
213 // instead, with the absolute, profile-dependent part being enforced by | |
214 // the browser). | |
215 #if defined(OS_WIN) | |
216 FilePath plugin_data_path = | |
217 profile_path.Append(FilePath(UTF8ToUTF16(plugin_name_))); | |
218 #else | |
219 FilePath plugin_data_path = profile_path.Append(FilePath(plugin_name_)); | |
220 #endif // defined(OS_WIN) | |
221 return new PpapiMsg_ClearSiteData(0u, plugin_data_path, std::string(), | |
222 kClearAllData, max_age); | |
223 #else | |
224 NOTREACHED() << "CreatePpapiClearSiteDataMsg called with " | |
225 << "ENABLE_PPAPI undefined."; | |
226 return NULL; | |
227 #endif // defined(ENABLE_PPAPI) | |
228 } | |
229 | |
203 // Connects the client side of a newly opened plug-in channel. | 230 // Connects the client side of a newly opened plug-in channel. |
204 void ConnectToChannel(const IPC::ChannelHandle& handle, bool is_ppapi) { | 231 void ConnectToChannel(const IPC::ChannelHandle& handle, bool is_ppapi) { |
205 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 232 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
206 | 233 |
207 // If we timed out, don't bother connecting. | 234 // If we timed out, don't bother connecting. |
208 if (!is_removing_) | 235 if (!is_removing_) |
209 return; | 236 return; |
210 | 237 |
211 DCHECK(!channel_.get()); | 238 DCHECK(!channel_.get()); |
212 channel_.reset(new IPC::Channel(handle, IPC::Channel::MODE_CLIENT, this)); | 239 channel_.reset(new IPC::Channel(handle, IPC::Channel::MODE_CLIENT, this)); |
213 if (!channel_->Connect()) { | 240 if (!channel_->Connect()) { |
214 NOTREACHED() << "Couldn't connect to plugin"; | 241 NOTREACHED() << "Couldn't connect to plugin"; |
215 SignalDone(); | 242 SignalDone(); |
216 return; | 243 return; |
217 } | 244 } |
218 | 245 |
219 uint64 max_age = begin_time_.is_null() ? | 246 uint64 max_age = begin_time_.is_null() ? |
220 std::numeric_limits<uint64>::max() : | 247 std::numeric_limits<uint64>::max() : |
221 (base::Time::Now() - begin_time_).InSeconds(); | 248 (base::Time::Now() - begin_time_).InSeconds(); |
222 | 249 |
223 IPC::Message* msg; | 250 IPC::Message* msg; |
224 if (is_ppapi) { | 251 if (is_ppapi) { |
225 FilePath profile_path = | 252 msg = CreatePpapiClearSiteDataMsg(max_age); |
226 PepperFileMessageFilter::GetDataDirName(browser_context_path_); | |
227 // TODO(vtl): This "duplicates" logic in webkit/plugins/ppapi/file_path.cc | |
228 // (which prepends the plugin name to the relative part of the path | |
229 // instead, with the absolute, profile-dependent part being enforced by | |
230 // the browser). | |
231 #if defined(OS_WIN) | |
232 FilePath plugin_data_path = | |
233 profile_path.Append(FilePath(UTF8ToUTF16(plugin_name_))); | |
234 #else | |
235 FilePath plugin_data_path = profile_path.Append(FilePath(plugin_name_)); | |
236 #endif | |
237 msg = new PpapiMsg_ClearSiteData(0u, plugin_data_path, std::string(), | |
238 kClearAllData, max_age); | |
239 } else { | 253 } else { |
240 msg = new PluginMsg_ClearSiteData(std::string(), kClearAllData, max_age); | 254 msg = new PluginMsg_ClearSiteData(std::string(), kClearAllData, max_age); |
241 } | 255 } |
242 if (!channel_->Send(msg)) { | 256 if (!channel_->Send(msg)) { |
243 NOTREACHED() << "Couldn't send ClearSiteData message"; | 257 NOTREACHED() << "Couldn't send ClearSiteData message"; |
244 SignalDone(); | 258 SignalDone(); |
245 return; | 259 return; |
246 } | 260 } |
247 } | 261 } |
248 | 262 |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
304 | 318 |
305 base::WaitableEvent* PluginDataRemoverImpl::StartRemoving( | 319 base::WaitableEvent* PluginDataRemoverImpl::StartRemoving( |
306 base::Time begin_time) { | 320 base::Time begin_time) { |
307 DCHECK(!context_.get()); | 321 DCHECK(!context_.get()); |
308 context_ = new Context(begin_time, browser_context_); | 322 context_ = new Context(begin_time, browser_context_); |
309 context_->Init(mime_type_); | 323 context_->Init(mime_type_); |
310 return context_->event(); | 324 return context_->event(); |
311 } | 325 } |
312 | 326 |
313 } // namespace content | 327 } // namespace content |
OLD | NEW |