[email protected] | 5896fa04 | 2012-03-07 04:41:40 | [diff] [blame] | 1 | // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
[email protected] | d8e68201 | 2011-11-17 18:31:54 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #include "content/browser/plugin_data_remover_impl.h" |
| 6 | |
[email protected] | c46cfe2 | 2012-09-27 22:11:55 | [diff] [blame] | 7 | #include <limits> |
| 8 | |
[email protected] | d8e68201 | 2011-11-17 18:31:54 | [diff] [blame] | 9 | #include "base/bind.h" |
| 10 | #include "base/metrics/histogram.h" |
[email protected] | fb44196 | 2013-05-08 05:35:24 | [diff] [blame] | 11 | #include "base/sequenced_task_runner_helpers.h" |
[email protected] | 74ebfb1 | 2013-06-07 20:48:00 | [diff] [blame] | 12 | #include "base/strings/utf_string_conversions.h" |
[email protected] | d8e68201 | 2011-11-17 18:31:54 | [diff] [blame] | 13 | #include "base/synchronization/waitable_event.h" |
| 14 | #include "base/version.h" |
[email protected] | 76b70f9 | 2011-11-21 19:31:14 | [diff] [blame] | 15 | #include "content/browser/plugin_process_host.h" |
[email protected] | e67385f | 2011-12-21 06:00:56 | [diff] [blame] | 16 | #include "content/browser/plugin_service_impl.h" |
[email protected] | 49511a7 | 2012-12-21 02:47:42 | [diff] [blame] | 17 | #include "content/browser/renderer_host/pepper/pepper_flash_file_message_filter.h" |
[email protected] | 4734d0b | 2011-12-03 07:10:44 | [diff] [blame] | 18 | #include "content/common/child_process_host_impl.h" |
[email protected] | 872f3a9 | 2013-05-21 08:16:08 | [diff] [blame] | 19 | #include "content/common/plugin_process_messages.h" |
[email protected] | 1bf0fb2 | 2012-04-12 21:44:16 | [diff] [blame] | 20 | #include "content/public/browser/browser_context.h" |
[email protected] | d8e68201 | 2011-11-17 18:31:54 | [diff] [blame] | 21 | #include "content/public/browser/browser_thread.h" |
[email protected] | 7327029 | 2013-08-09 03:48:07 | [diff] [blame] | 22 | #include "content/public/common/content_constants.h" |
[email protected] | 1bf0fb2 | 2012-04-12 21:44:16 | [diff] [blame] | 23 | #include "content/public/common/pepper_plugin_info.h" |
[email protected] | c3cdc73 | 2012-12-07 09:16:56 | [diff] [blame] | 24 | #include "ppapi/proxy/ppapi_messages.h" |
[email protected] | d8e68201 | 2011-11-17 18:31:54 | [diff] [blame] | 25 | |
[email protected] | 1bf0fb2 | 2012-04-12 21:44:16 | [diff] [blame] | 26 | namespace content { |
[email protected] | d8e68201 | 2011-11-17 18:31:54 | [diff] [blame] | 27 | |
| 28 | namespace { |
| 29 | |
[email protected] | d8e68201 | 2011-11-17 18:31:54 | [diff] [blame] | 30 | // The minimum Flash Player version that implements NPP_ClearSiteData. |
| 31 | const char kMinFlashVersion[] = "10.3"; |
| 32 | const int64 kRemovalTimeoutMs = 10000; |
| 33 | const uint64 kClearAllData = 0; |
| 34 | |
| 35 | } // namespace |
| 36 | |
[email protected] | d8e68201 | 2011-11-17 18:31:54 | [diff] [blame] | 37 | // static |
[email protected] | 1bf0fb2 | 2012-04-12 21:44:16 | [diff] [blame] | 38 | PluginDataRemover* PluginDataRemover::Create(BrowserContext* browser_context) { |
| 39 | return new PluginDataRemoverImpl(browser_context); |
[email protected] | d8e68201 | 2011-11-17 18:31:54 | [diff] [blame] | 40 | } |
| 41 | |
| 42 | // static |
[email protected] | e346424 | 2012-05-05 00:45:38 | [diff] [blame] | 43 | void PluginDataRemover::GetSupportedPlugins( |
[email protected] | d7bd3e5 | 2013-07-21 04:29:20 | [diff] [blame] | 44 | std::vector<WebPluginInfo>* supported_plugins) { |
[email protected] | d8e68201 | 2011-11-17 18:31:54 | [diff] [blame] | 45 | bool allow_wildcard = false; |
[email protected] | d7bd3e5 | 2013-07-21 04:29:20 | [diff] [blame] | 46 | std::vector<WebPluginInfo> plugins; |
[email protected] | d8e68201 | 2011-11-17 18:31:54 | [diff] [blame] | 47 | PluginService::GetInstance()->GetPluginInfoArray( |
[email protected] | c46cfe2 | 2012-09-27 22:11:55 | [diff] [blame] | 48 | GURL(), kFlashPluginSwfMimeType, allow_wildcard, &plugins, NULL); |
[email protected] | c5e4a222 | 2014-01-03 16:06:13 | [diff] [blame] | 49 | Version min_version(kMinFlashVersion); |
[email protected] | d7bd3e5 | 2013-07-21 04:29:20 | [diff] [blame] | 50 | for (std::vector<WebPluginInfo>::iterator it = plugins.begin(); |
[email protected] | e346424 | 2012-05-05 00:45:38 | [diff] [blame] | 51 | it != plugins.end(); ++it) { |
[email protected] | c5e4a222 | 2014-01-03 16:06:13 | [diff] [blame] | 52 | Version version; |
[email protected] | d7bd3e5 | 2013-07-21 04:29:20 | [diff] [blame] | 53 | WebPluginInfo::CreateVersionFromString(it->version, &version); |
[email protected] | 12126d37 | 2012-07-11 18:40:53 | [diff] [blame] | 54 | if (version.IsValid() && min_version.CompareTo(version) == -1) |
[email protected] | e346424 | 2012-05-05 00:45:38 | [diff] [blame] | 55 | supported_plugins->push_back(*it); |
| 56 | } |
[email protected] | d8e68201 | 2011-11-17 18:31:54 | [diff] [blame] | 57 | } |
| 58 | |
[email protected] | 76b70f9 | 2011-11-21 19:31:14 | [diff] [blame] | 59 | class PluginDataRemoverImpl::Context |
| 60 | : public PluginProcessHost::Client, |
[email protected] | 1bf0fb2 | 2012-04-12 21:44:16 | [diff] [blame] | 61 | public PpapiPluginProcessHost::BrokerClient, |
[email protected] | d84effeb | 2012-06-25 17:03:10 | [diff] [blame] | 62 | public IPC::Listener, |
[email protected] | 1464ce1 | 2011-12-08 11:14:32 | [diff] [blame] | 63 | public base::RefCountedThreadSafe<Context, |
| 64 | BrowserThread::DeleteOnIOThread> { |
[email protected] | 76b70f9 | 2011-11-21 19:31:14 | [diff] [blame] | 65 | public: |
[email protected] | 1bf0fb2 | 2012-04-12 21:44:16 | [diff] [blame] | 66 | Context(base::Time begin_time, BrowserContext* browser_context) |
[email protected] | 76b70f9 | 2011-11-21 19:31:14 | [diff] [blame] | 67 | : event_(new base::WaitableEvent(true, false)), |
| 68 | begin_time_(begin_time), |
| 69 | is_removing_(false), |
[email protected] | 1bf0fb2 | 2012-04-12 21:44:16 | [diff] [blame] | 70 | browser_context_path_(browser_context->GetPath()), |
[email protected] | 47f236d | 2013-06-13 13:42:30 | [diff] [blame] | 71 | resource_context_(browser_context->GetResourceContext()) { |
mostynb | 4c27d04 | 2015-03-18 21:47:47 | [diff] [blame] | 72 | DCHECK_CURRENTLY_ON(BrowserThread::UI); |
[email protected] | 1464ce1 | 2011-12-08 11:14:32 | [diff] [blame] | 73 | } |
| 74 | |
[email protected] | 1464ce1 | 2011-12-08 11:14:32 | [diff] [blame] | 75 | void Init(const std::string& mime_type) { |
[email protected] | 76b70f9 | 2011-11-21 19:31:14 | [diff] [blame] | 76 | BrowserThread::PostTask( |
| 77 | BrowserThread::IO, |
| 78 | FROM_HERE, |
[email protected] | 1464ce1 | 2011-12-08 11:14:32 | [diff] [blame] | 79 | base::Bind(&Context::InitOnIOThread, this, mime_type)); |
[email protected] | 76b70f9 | 2011-11-21 19:31:14 | [diff] [blame] | 80 | BrowserThread::PostDelayedTask( |
| 81 | BrowserThread::IO, |
| 82 | FROM_HERE, |
| 83 | base::Bind(&Context::OnTimeout, this), |
[email protected] | 5896fa04 | 2012-03-07 04:41:40 | [diff] [blame] | 84 | base::TimeDelta::FromMilliseconds(kRemovalTimeoutMs)); |
[email protected] | 76b70f9 | 2011-11-21 19:31:14 | [diff] [blame] | 85 | } |
| 86 | |
[email protected] | 1464ce1 | 2011-12-08 11:14:32 | [diff] [blame] | 87 | void InitOnIOThread(const std::string& mime_type) { |
[email protected] | 1bf0fb2 | 2012-04-12 21:44:16 | [diff] [blame] | 88 | PluginServiceImpl* plugin_service = PluginServiceImpl::GetInstance(); |
| 89 | |
| 90 | // Get the plugin file path. |
[email protected] | d7bd3e5 | 2013-07-21 04:29:20 | [diff] [blame] | 91 | std::vector<WebPluginInfo> plugins; |
[email protected] | 1bf0fb2 | 2012-04-12 21:44:16 | [diff] [blame] | 92 | plugin_service->GetPluginInfoArray( |
| 93 | GURL(), mime_type, false, &plugins, NULL); |
[email protected] | 2dec8ec | 2013-02-07 19:20:34 | [diff] [blame] | 94 | base::FilePath plugin_path; |
[email protected] | 1bf0fb2 | 2012-04-12 21:44:16 | [diff] [blame] | 95 | if (!plugins.empty()) // May be empty for some tests. |
| 96 | plugin_path = plugins[0].path; |
| 97 | |
mostynb | 4c27d04 | 2015-03-18 21:47:47 | [diff] [blame] | 98 | DCHECK_CURRENTLY_ON(BrowserThread::IO); |
[email protected] | 1464ce1 | 2011-12-08 11:14:32 | [diff] [blame] | 99 | remove_start_time_ = base::Time::Now(); |
| 100 | is_removing_ = true; |
[email protected] | 1bf0fb2 | 2012-04-12 21:44:16 | [diff] [blame] | 101 | // Balanced in On[Ppapi]ChannelOpened or OnError. Exactly one them will |
| 102 | // eventually be called, so we need to keep this object around until then. |
[email protected] | 1464ce1 | 2011-12-08 11:14:32 | [diff] [blame] | 103 | AddRef(); |
[email protected] | 1bf0fb2 | 2012-04-12 21:44:16 | [diff] [blame] | 104 | |
| 105 | PepperPluginInfo* pepper_info = |
| 106 | plugin_service->GetRegisteredPpapiPluginInfo(plugin_path); |
| 107 | if (pepper_info) { |
[email protected] | 4cce3f3f | 2012-04-24 02:54:04 | [diff] [blame] | 108 | plugin_name_ = pepper_info->name; |
[email protected] | 1bf0fb2 | 2012-04-12 21:44:16 | [diff] [blame] | 109 | // Use the broker since we run this function outside the sandbox. |
[email protected] | 6be31d20 | 2013-02-01 18:20:54 | [diff] [blame] | 110 | plugin_service->OpenChannelToPpapiBroker(0, plugin_path, this); |
[email protected] | 1bf0fb2 | 2012-04-12 21:44:16 | [diff] [blame] | 111 | } else { |
| 112 | plugin_service->OpenChannelToNpapiPlugin( |
| 113 | 0, 0, GURL(), GURL(), mime_type, this); |
| 114 | } |
[email protected] | 1464ce1 | 2011-12-08 11:14:32 | [diff] [blame] | 115 | } |
| 116 | |
| 117 | // Called when a timeout happens in order not to block the client |
| 118 | // indefinitely. |
| 119 | void OnTimeout() { |
| 120 | LOG_IF(ERROR, is_removing_) << "Timed out"; |
| 121 | SignalDone(); |
[email protected] | 76b70f9 | 2011-11-21 19:31:14 | [diff] [blame] | 122 | } |
| 123 | |
| 124 | // PluginProcessHost::Client methods. |
dcheng | c2282aa | 2014-10-21 12:07:58 | [diff] [blame] | 125 | int ID() override { |
[email protected] | 76b70f9 | 2011-11-21 19:31:14 | [diff] [blame] | 126 | // Generate a unique identifier for this PluginProcessHostClient. |
[email protected] | 4734d0b | 2011-12-03 07:10:44 | [diff] [blame] | 127 | return ChildProcessHostImpl::GenerateChildProcessUniqueId(); |
[email protected] | 76b70f9 | 2011-11-21 19:31:14 | [diff] [blame] | 128 | } |
| 129 | |
dcheng | c2282aa | 2014-10-21 12:07:58 | [diff] [blame] | 130 | bool OffTheRecord() override { return false; } |
[email protected] | 76b70f9 | 2011-11-21 19:31:14 | [diff] [blame] | 131 | |
dcheng | c2282aa | 2014-10-21 12:07:58 | [diff] [blame] | 132 | ResourceContext* GetResourceContext() override { return resource_context_; } |
[email protected] | 76b70f9 | 2011-11-21 19:31:14 | [diff] [blame] | 133 | |
dcheng | c2282aa | 2014-10-21 12:07:58 | [diff] [blame] | 134 | void SetPluginInfo(const WebPluginInfo& info) override {} |
[email protected] | 76b70f9 | 2011-11-21 19:31:14 | [diff] [blame] | 135 | |
dcheng | c2282aa | 2014-10-21 12:07:58 | [diff] [blame] | 136 | void OnFoundPluginProcessHost(PluginProcessHost* host) override {} |
[email protected] | 76b70f9 | 2011-11-21 19:31:14 | [diff] [blame] | 137 | |
dcheng | c2282aa | 2014-10-21 12:07:58 | [diff] [blame] | 138 | void OnSentPluginChannelRequest() override {} |
[email protected] | 76b70f9 | 2011-11-21 19:31:14 | [diff] [blame] | 139 | |
dcheng | c2282aa | 2014-10-21 12:07:58 | [diff] [blame] | 140 | void OnChannelOpened(const IPC::ChannelHandle& handle) override { |
[email protected] | 1bf0fb2 | 2012-04-12 21:44:16 | [diff] [blame] | 141 | ConnectToChannel(handle, false); |
[email protected] | 76b70f9 | 2011-11-21 19:31:14 | [diff] [blame] | 142 | // Balancing the AddRef call. |
| 143 | Release(); |
| 144 | } |
| 145 | |
dcheng | c2282aa | 2014-10-21 12:07:58 | [diff] [blame] | 146 | void OnError() override { |
[email protected] | 791ce4ac | 2011-12-21 13:44:34 | [diff] [blame] | 147 | LOG(ERROR) << "Couldn't open plugin channel"; |
[email protected] | 76b70f9 | 2011-11-21 19:31:14 | [diff] [blame] | 148 | SignalDone(); |
| 149 | // Balancing the AddRef call. |
| 150 | Release(); |
| 151 | } |
| 152 | |
[email protected] | 1bf0fb2 | 2012-04-12 21:44:16 | [diff] [blame] | 153 | // PpapiPluginProcessHost::BrokerClient implementation. |
dcheng | c2282aa | 2014-10-21 12:07:58 | [diff] [blame] | 154 | void GetPpapiChannelInfo(base::ProcessHandle* renderer_handle, |
| 155 | int* renderer_id) override { |
[email protected] | 54c23f1 | 2012-05-04 21:01:19 | [diff] [blame] | 156 | *renderer_handle = base::kNullProcessHandle; |
[email protected] | 1bf0fb2 | 2012-04-12 21:44:16 | [diff] [blame] | 157 | *renderer_id = 0; |
| 158 | } |
| 159 | |
dcheng | c2282aa | 2014-10-21 12:07:58 | [diff] [blame] | 160 | void OnPpapiChannelOpened(const IPC::ChannelHandle& channel_handle, |
| 161 | base::ProcessId /* peer_pid */, |
| 162 | int /* child_id */) override { |
[email protected] | 54c23f1 | 2012-05-04 21:01:19 | [diff] [blame] | 163 | if (!channel_handle.name.empty()) |
[email protected] | 1bf0fb2 | 2012-04-12 21:44:16 | [diff] [blame] | 164 | ConnectToChannel(channel_handle, true); |
| 165 | |
| 166 | // Balancing the AddRef call. |
| 167 | Release(); |
| 168 | } |
| 169 | |
[email protected] | d84effeb | 2012-06-25 17:03:10 | [diff] [blame] | 170 | // IPC::Listener methods. |
dcheng | c2282aa | 2014-10-21 12:07:58 | [diff] [blame] | 171 | bool OnMessageReceived(const IPC::Message& message) override { |
[email protected] | 76b70f9 | 2011-11-21 19:31:14 | [diff] [blame] | 172 | IPC_BEGIN_MESSAGE_MAP(Context, message) |
[email protected] | 872f3a9 | 2013-05-21 08:16:08 | [diff] [blame] | 173 | IPC_MESSAGE_HANDLER(PluginProcessHostMsg_ClearSiteDataResult, |
[email protected] | 76b70f9 | 2011-11-21 19:31:14 | [diff] [blame] | 174 | OnClearSiteDataResult) |
[email protected] | 1bf0fb2 | 2012-04-12 21:44:16 | [diff] [blame] | 175 | IPC_MESSAGE_HANDLER(PpapiHostMsg_ClearSiteDataResult, |
[email protected] | 951ef0b | 2012-07-27 22:46:53 | [diff] [blame] | 176 | OnPpapiClearSiteDataResult) |
[email protected] | 76b70f9 | 2011-11-21 19:31:14 | [diff] [blame] | 177 | IPC_MESSAGE_UNHANDLED_ERROR() |
| 178 | IPC_END_MESSAGE_MAP() |
| 179 | |
| 180 | return true; |
| 181 | } |
| 182 | |
dcheng | c2282aa | 2014-10-21 12:07:58 | [diff] [blame] | 183 | void OnChannelError() override { |
[email protected] | 76b70f9 | 2011-11-21 19:31:14 | [diff] [blame] | 184 | if (is_removing_) { |
| 185 | NOTREACHED() << "Channel error"; |
| 186 | SignalDone(); |
| 187 | } |
| 188 | } |
| 189 | |
[email protected] | 76b70f9 | 2011-11-21 19:31:14 | [diff] [blame] | 190 | base::WaitableEvent* event() { return event_.get(); } |
| 191 | |
| 192 | private: |
[email protected] | fb90c94 | 2012-04-27 23:40:50 | [diff] [blame] | 193 | friend struct BrowserThread::DeleteOnThread<BrowserThread::IO>; |
| 194 | friend class base::DeleteHelper<Context>; |
dcheng | c2282aa | 2014-10-21 12:07:58 | [diff] [blame] | 195 | ~Context() override {} |
[email protected] | fb90c94 | 2012-04-27 23:40:50 | [diff] [blame] | 196 | |
[email protected] | 6d17f639 | 2012-12-05 05:24:54 | [diff] [blame] | 197 | IPC::Message* CreatePpapiClearSiteDataMsg(uint64 max_age) { |
[email protected] | 2dec8ec | 2013-02-07 19:20:34 | [diff] [blame] | 198 | base::FilePath profile_path = |
[email protected] | 49511a7 | 2012-12-21 02:47:42 | [diff] [blame] | 199 | PepperFlashFileMessageFilter::GetDataDirName(browser_context_path_); |
[email protected] | 6d17f639 | 2012-12-05 05:24:54 | [diff] [blame] | 200 | // TODO(vtl): This "duplicates" logic in webkit/plugins/ppapi/file_path.cc |
| 201 | // (which prepends the plugin name to the relative part of the path |
| 202 | // instead, with the absolute, profile-dependent part being enforced by |
| 203 | // the browser). |
| 204 | #if defined(OS_WIN) |
[email protected] | 2dec8ec | 2013-02-07 19:20:34 | [diff] [blame] | 205 | base::FilePath plugin_data_path = |
[email protected] | 3295612 | 2013-12-25 07:29:24 | [diff] [blame] | 206 | profile_path.Append(base::FilePath(base::UTF8ToUTF16(plugin_name_))); |
[email protected] | 6d17f639 | 2012-12-05 05:24:54 | [diff] [blame] | 207 | #else |
[email protected] | 2dec8ec | 2013-02-07 19:20:34 | [diff] [blame] | 208 | base::FilePath plugin_data_path = |
| 209 | profile_path.Append(base::FilePath(plugin_name_)); |
[email protected] | 6d17f639 | 2012-12-05 05:24:54 | [diff] [blame] | 210 | #endif // defined(OS_WIN) |
| 211 | return new PpapiMsg_ClearSiteData(0u, plugin_data_path, std::string(), |
| 212 | kClearAllData, max_age); |
| 213 | } |
[email protected] | 6d17f639 | 2012-12-05 05:24:54 | [diff] [blame] | 214 | |
tommycli | e86b298 | 2015-03-16 20:16:45 | [diff] [blame] | 215 | // Connects the client side of a newly opened plugin channel. |
[email protected] | 1bf0fb2 | 2012-04-12 21:44:16 | [diff] [blame] | 216 | void ConnectToChannel(const IPC::ChannelHandle& handle, bool is_ppapi) { |
mostynb | 4c27d04 | 2015-03-18 21:47:47 | [diff] [blame] | 217 | DCHECK_CURRENTLY_ON(BrowserThread::IO); |
[email protected] | 76b70f9 | 2011-11-21 19:31:14 | [diff] [blame] | 218 | |
| 219 | // If we timed out, don't bother connecting. |
| 220 | if (!is_removing_) |
| 221 | return; |
| 222 | |
[email protected] | 1464ce1 | 2011-12-08 11:14:32 | [diff] [blame] | 223 | DCHECK(!channel_.get()); |
[email protected] | e482111a8 | 2014-05-30 03:58:59 | [diff] [blame] | 224 | channel_ = IPC::Channel::CreateClient(handle, this); |
[email protected] | 76b70f9 | 2011-11-21 19:31:14 | [diff] [blame] | 225 | if (!channel_->Connect()) { |
| 226 | NOTREACHED() << "Couldn't connect to plugin"; |
| 227 | SignalDone(); |
| 228 | return; |
| 229 | } |
| 230 | |
[email protected] | 1bf0fb2 | 2012-04-12 21:44:16 | [diff] [blame] | 231 | uint64 max_age = begin_time_.is_null() ? |
| 232 | std::numeric_limits<uint64>::max() : |
| 233 | (base::Time::Now() - begin_time_).InSeconds(); |
| 234 | |
| 235 | IPC::Message* msg; |
| 236 | if (is_ppapi) { |
[email protected] | 6d17f639 | 2012-12-05 05:24:54 | [diff] [blame] | 237 | msg = CreatePpapiClearSiteDataMsg(max_age); |
[email protected] | 1bf0fb2 | 2012-04-12 21:44:16 | [diff] [blame] | 238 | } else { |
[email protected] | 872f3a9 | 2013-05-21 08:16:08 | [diff] [blame] | 239 | msg = new PluginProcessMsg_ClearSiteData( |
| 240 | std::string(), kClearAllData, max_age); |
[email protected] | 1bf0fb2 | 2012-04-12 21:44:16 | [diff] [blame] | 241 | } |
| 242 | if (!channel_->Send(msg)) { |
[email protected] | 76b70f9 | 2011-11-21 19:31:14 | [diff] [blame] | 243 | NOTREACHED() << "Couldn't send ClearSiteData message"; |
| 244 | SignalDone(); |
| 245 | return; |
| 246 | } |
| 247 | } |
| 248 | |
[email protected] | 951ef0b | 2012-07-27 22:46:53 | [diff] [blame] | 249 | // Handles the PpapiHostMsg_ClearSiteDataResult message by delegating to the |
[email protected] | 872f3a9 | 2013-05-21 08:16:08 | [diff] [blame] | 250 | // PluginProcessHostMsg_ClearSiteDataResult handler. |
[email protected] | 951ef0b | 2012-07-27 22:46:53 | [diff] [blame] | 251 | void OnPpapiClearSiteDataResult(uint32 request_id, bool success) { |
| 252 | DCHECK_EQ(0u, request_id); |
| 253 | OnClearSiteDataResult(success); |
| 254 | } |
| 255 | |
[email protected] | 872f3a9 | 2013-05-21 08:16:08 | [diff] [blame] | 256 | // Handles the PluginProcessHostMsg_ClearSiteDataResult message. |
[email protected] | 76b70f9 | 2011-11-21 19:31:14 | [diff] [blame] | 257 | void OnClearSiteDataResult(bool success) { |
| 258 | LOG_IF(ERROR, !success) << "ClearSiteData returned error"; |
| 259 | UMA_HISTOGRAM_TIMES("ClearPluginData.time", |
| 260 | base::Time::Now() - remove_start_time_); |
| 261 | SignalDone(); |
| 262 | } |
| 263 | |
[email protected] | 76b70f9 | 2011-11-21 19:31:14 | [diff] [blame] | 264 | // Signals that we are finished with removing data (successful or not). This |
| 265 | // method is safe to call multiple times. |
| 266 | void SignalDone() { |
mostynb | 4c27d04 | 2015-03-18 21:47:47 | [diff] [blame] | 267 | DCHECK_CURRENTLY_ON(BrowserThread::IO); |
[email protected] | 76b70f9 | 2011-11-21 19:31:14 | [diff] [blame] | 268 | if (!is_removing_) |
| 269 | return; |
| 270 | is_removing_ = false; |
| 271 | event_->Signal(); |
| 272 | } |
| 273 | |
| 274 | scoped_ptr<base::WaitableEvent> event_; |
| 275 | // The point in time when we start removing data. |
| 276 | base::Time remove_start_time_; |
| 277 | // The point in time from which on we remove data. |
| 278 | base::Time begin_time_; |
| 279 | bool is_removing_; |
| 280 | |
[email protected] | 1bf0fb2 | 2012-04-12 21:44:16 | [diff] [blame] | 281 | // Path for the current profile. Must be retrieved on the UI thread from the |
| 282 | // browser context when we start so we can use it later on the I/O thread. |
[email protected] | 2dec8ec | 2013-02-07 19:20:34 | [diff] [blame] | 283 | base::FilePath browser_context_path_; |
[email protected] | 1bf0fb2 | 2012-04-12 21:44:16 | [diff] [blame] | 284 | |
| 285 | // The resource context for the profile. Use only on the I/O thread. |
| 286 | ResourceContext* resource_context_; |
[email protected] | 76b70f9 | 2011-11-21 19:31:14 | [diff] [blame] | 287 | |
[email protected] | 4cce3f3f | 2012-04-24 02:54:04 | [diff] [blame] | 288 | // The name of the plugin. Use only on the I/O thread. |
| 289 | std::string plugin_name_; |
| 290 | |
tommycli | e86b298 | 2015-03-16 20:16:45 | [diff] [blame] | 291 | // The channel is NULL until we have opened a connection to the plugin |
[email protected] | 76b70f9 | 2011-11-21 19:31:14 | [diff] [blame] | 292 | // process. |
[email protected] | 1464ce1 | 2011-12-08 11:14:32 | [diff] [blame] | 293 | scoped_ptr<IPC::Channel> channel_; |
[email protected] | 76b70f9 | 2011-11-21 19:31:14 | [diff] [blame] | 294 | }; |
| 295 | |
| 296 | |
[email protected] | 1bf0fb2 | 2012-04-12 21:44:16 | [diff] [blame] | 297 | PluginDataRemoverImpl::PluginDataRemoverImpl(BrowserContext* browser_context) |
[email protected] | c46cfe2 | 2012-09-27 22:11:55 | [diff] [blame] | 298 | : mime_type_(kFlashPluginSwfMimeType), |
[email protected] | 1bf0fb2 | 2012-04-12 21:44:16 | [diff] [blame] | 299 | browser_context_(browser_context) { |
[email protected] | d8e68201 | 2011-11-17 18:31:54 | [diff] [blame] | 300 | } |
| 301 | |
| 302 | PluginDataRemoverImpl::~PluginDataRemoverImpl() { |
[email protected] | d8e68201 | 2011-11-17 18:31:54 | [diff] [blame] | 303 | } |
| 304 | |
| 305 | base::WaitableEvent* PluginDataRemoverImpl::StartRemoving( |
| 306 | base::Time begin_time) { |
[email protected] | 76b70f9 | 2011-11-21 19:31:14 | [diff] [blame] | 307 | DCHECK(!context_.get()); |
[email protected] | 1bf0fb2 | 2012-04-12 21:44:16 | [diff] [blame] | 308 | context_ = new Context(begin_time, browser_context_); |
[email protected] | 1464ce1 | 2011-12-08 11:14:32 | [diff] [blame] | 309 | context_->Init(mime_type_); |
[email protected] | 76b70f9 | 2011-11-21 19:31:14 | [diff] [blame] | 310 | return context_->event(); |
[email protected] | d8e68201 | 2011-11-17 18:31:54 | [diff] [blame] | 311 | } |
[email protected] | 1bf0fb2 | 2012-04-12 21:44:16 | [diff] [blame] | 312 | |
| 313 | } // namespace content |