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