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" |
(...skipping 23 matching lines...) Expand all Loading... |
34 | 34 |
35 } // namespace | 35 } // namespace |
36 | 36 |
37 // static | 37 // static |
38 PluginDataRemover* PluginDataRemover::Create(BrowserContext* browser_context) { | 38 PluginDataRemover* PluginDataRemover::Create(BrowserContext* browser_context) { |
39 return new PluginDataRemoverImpl(browser_context); | 39 return new PluginDataRemoverImpl(browser_context); |
40 } | 40 } |
41 | 41 |
42 // static | 42 // static |
43 void PluginDataRemover::GetSupportedPlugins( | 43 void PluginDataRemover::GetSupportedPlugins( |
44 std::vector<webkit::WebPluginInfo>* supported_plugins) { | 44 std::vector<WebPluginInfo>* supported_plugins) { |
45 bool allow_wildcard = false; | 45 bool allow_wildcard = false; |
46 std::vector<webkit::WebPluginInfo> plugins; | 46 std::vector<WebPluginInfo> plugins; |
47 PluginService::GetInstance()->GetPluginInfoArray( | 47 PluginService::GetInstance()->GetPluginInfoArray( |
48 GURL(), kFlashPluginSwfMimeType, allow_wildcard, &plugins, NULL); | 48 GURL(), kFlashPluginSwfMimeType, allow_wildcard, &plugins, NULL); |
49 Version min_version(kMinFlashVersion); | 49 Version min_version(kMinFlashVersion); |
50 for (std::vector<webkit::WebPluginInfo>::iterator it = plugins.begin(); | 50 for (std::vector<WebPluginInfo>::iterator it = plugins.begin(); |
51 it != plugins.end(); ++it) { | 51 it != plugins.end(); ++it) { |
52 Version version; | 52 Version version; |
53 webkit::WebPluginInfo::CreateVersionFromString(it->version, &version); | 53 WebPluginInfo::CreateVersionFromString(it->version, &version); |
54 if (version.IsValid() && min_version.CompareTo(version) == -1) | 54 if (version.IsValid() && min_version.CompareTo(version) == -1) |
55 supported_plugins->push_back(*it); | 55 supported_plugins->push_back(*it); |
56 } | 56 } |
57 } | 57 } |
58 | 58 |
59 class PluginDataRemoverImpl::Context | 59 class PluginDataRemoverImpl::Context |
60 : public PluginProcessHost::Client, | 60 : public PluginProcessHost::Client, |
61 public PpapiPluginProcessHost::BrokerClient, | 61 public PpapiPluginProcessHost::BrokerClient, |
62 public IPC::Listener, | 62 public IPC::Listener, |
63 public base::RefCountedThreadSafe<Context, | 63 public base::RefCountedThreadSafe<Context, |
(...skipping 17 matching lines...) Expand all Loading... |
81 BrowserThread::IO, | 81 BrowserThread::IO, |
82 FROM_HERE, | 82 FROM_HERE, |
83 base::Bind(&Context::OnTimeout, this), | 83 base::Bind(&Context::OnTimeout, this), |
84 base::TimeDelta::FromMilliseconds(kRemovalTimeoutMs)); | 84 base::TimeDelta::FromMilliseconds(kRemovalTimeoutMs)); |
85 } | 85 } |
86 | 86 |
87 void InitOnIOThread(const std::string& mime_type) { | 87 void InitOnIOThread(const std::string& mime_type) { |
88 PluginServiceImpl* plugin_service = PluginServiceImpl::GetInstance(); | 88 PluginServiceImpl* plugin_service = PluginServiceImpl::GetInstance(); |
89 | 89 |
90 // Get the plugin file path. | 90 // Get the plugin file path. |
91 std::vector<webkit::WebPluginInfo> plugins; | 91 std::vector<WebPluginInfo> plugins; |
92 plugin_service->GetPluginInfoArray( | 92 plugin_service->GetPluginInfoArray( |
93 GURL(), mime_type, false, &plugins, NULL); | 93 GURL(), mime_type, false, &plugins, NULL); |
94 base::FilePath plugin_path; | 94 base::FilePath plugin_path; |
95 if (!plugins.empty()) // May be empty for some tests. | 95 if (!plugins.empty()) // May be empty for some tests. |
96 plugin_path = plugins[0].path; | 96 plugin_path = plugins[0].path; |
97 | 97 |
98 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 98 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
99 remove_start_time_ = base::Time::Now(); | 99 remove_start_time_ = base::Time::Now(); |
100 is_removing_ = true; | 100 is_removing_ = true; |
101 // Balanced in On[Ppapi]ChannelOpened or OnError. Exactly one them will | 101 // Balanced in On[Ppapi]ChannelOpened or OnError. Exactly one them will |
(...skipping 26 matching lines...) Expand all Loading... |
128 } | 128 } |
129 | 129 |
130 virtual bool OffTheRecord() OVERRIDE { | 130 virtual bool OffTheRecord() OVERRIDE { |
131 return false; | 131 return false; |
132 } | 132 } |
133 | 133 |
134 virtual ResourceContext* GetResourceContext() OVERRIDE { | 134 virtual ResourceContext* GetResourceContext() OVERRIDE { |
135 return resource_context_; | 135 return resource_context_; |
136 } | 136 } |
137 | 137 |
138 virtual void SetPluginInfo(const webkit::WebPluginInfo& info) OVERRIDE {} | 138 virtual void SetPluginInfo(const WebPluginInfo& info) OVERRIDE {} |
139 | 139 |
140 virtual void OnFoundPluginProcessHost(PluginProcessHost* host) OVERRIDE {} | 140 virtual void OnFoundPluginProcessHost(PluginProcessHost* host) OVERRIDE {} |
141 | 141 |
142 virtual void OnSentPluginChannelRequest() OVERRIDE {} | 142 virtual void OnSentPluginChannelRequest() OVERRIDE {} |
143 | 143 |
144 virtual void OnChannelOpened(const IPC::ChannelHandle& handle) OVERRIDE { | 144 virtual void OnChannelOpened(const IPC::ChannelHandle& handle) OVERRIDE { |
145 ConnectToChannel(handle, false); | 145 ConnectToChannel(handle, false); |
146 // Balancing the AddRef call. | 146 // Balancing the AddRef call. |
147 Release(); | 147 Release(); |
148 } | 148 } |
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
309 | 309 |
310 base::WaitableEvent* PluginDataRemoverImpl::StartRemoving( | 310 base::WaitableEvent* PluginDataRemoverImpl::StartRemoving( |
311 base::Time begin_time) { | 311 base::Time begin_time) { |
312 DCHECK(!context_.get()); | 312 DCHECK(!context_.get()); |
313 context_ = new Context(begin_time, browser_context_); | 313 context_ = new Context(begin_time, browser_context_); |
314 context_->Init(mime_type_); | 314 context_->Init(mime_type_); |
315 return context_->event(); | 315 return context_->event(); |
316 } | 316 } |
317 | 317 |
318 } // namespace content | 318 } // namespace content |
OLD | NEW |