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