Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(95)

Side by Side Diff: chrome/browser/plugin_data_remover.cc

Issue 7387010: Add PluginServiceFilter interface. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix unit test Created 9 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/plugin_data_remover.h ('k') | chrome/browser/plugin_data_remover_browsertest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "chrome/browser/plugin_data_remover.h" 5 #include "chrome/browser/plugin_data_remover.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/message_loop_proxy.h" 8 #include "base/message_loop_proxy.h"
9 #include "base/metrics/histogram.h" 9 #include "base/metrics/histogram.h"
10 #include "base/synchronization/waitable_event.h" 10 #include "base/synchronization/waitable_event.h"
11 #include "base/version.h" 11 #include "base/version.h"
12 #include "chrome/browser/plugin_prefs.h" 12 #include "chrome/browser/plugin_prefs.h"
13 #include "chrome/browser/profiles/profile.h"
13 #include "chrome/common/chrome_switches.h" 14 #include "chrome/common/chrome_switches.h"
14 #include "content/browser/browser_thread.h" 15 #include "content/browser/browser_thread.h"
15 #include "content/browser/plugin_service.h" 16 #include "content/browser/plugin_service.h"
16 #include "content/common/plugin_messages.h" 17 #include "content/common/plugin_messages.h"
17 #include "webkit/plugins/npapi/plugin_group.h" 18 #include "webkit/plugins/npapi/plugin_group.h"
18 #include "webkit/plugins/npapi/plugin_list.h" 19 #include "webkit/plugins/npapi/plugin_list.h"
19 20
20 #if defined(OS_POSIX) 21 #if defined(OS_POSIX)
21 #include "ipc/ipc_channel_posix.h" 22 #include "ipc/ipc_channel_posix.h"
22 #endif 23 #endif
23 24
24 namespace { 25 namespace {
25 26
26 const char* kFlashMimeType = "application/x-shockwave-flash"; 27 const char* kFlashMimeType = "application/x-shockwave-flash";
27 // The minimum Flash Player version that implements NPP_ClearSiteData. 28 // The minimum Flash Player version that implements NPP_ClearSiteData.
28 const char* kMinFlashVersion = "10.3"; 29 const char* kMinFlashVersion = "10.3";
29 const int64 kRemovalTimeoutMs = 10000; 30 const int64 kRemovalTimeoutMs = 10000;
30 const uint64 kClearAllData = 0; 31 const uint64 kClearAllData = 0;
31 32
32 } // namespace 33 } // namespace
33 34
34 PluginDataRemover::PluginDataRemover() 35 PluginDataRemover::PluginDataRemover(Profile* profile)
35 : mime_type_(kFlashMimeType), 36 : mime_type_(kFlashMimeType),
36 is_removing_(false), 37 is_removing_(false),
38 context_(profile->GetResourceContext()),
37 event_(new base::WaitableEvent(true, false)), 39 event_(new base::WaitableEvent(true, false)),
38 channel_(NULL) { 40 channel_(NULL) {
39 } 41 }
40 42
41 PluginDataRemover::~PluginDataRemover() { 43 PluginDataRemover::~PluginDataRemover() {
42 DCHECK(!is_removing_); 44 DCHECK(!is_removing_);
43 if (channel_) 45 if (channel_)
44 BrowserThread::DeleteSoon(BrowserThread::IO, FROM_HERE, channel_); 46 BrowserThread::DeleteSoon(BrowserThread::IO, FROM_HERE, channel_);
45 } 47 }
46 48
47 base::WaitableEvent* PluginDataRemover::StartRemoving(base::Time begin_time) { 49 base::WaitableEvent* PluginDataRemover::StartRemoving(base::Time begin_time) {
48 DCHECK(!is_removing_); 50 DCHECK(!is_removing_);
49 remove_start_time_ = base::Time::Now(); 51 remove_start_time_ = base::Time::Now();
50 begin_time_ = begin_time; 52 begin_time_ = begin_time;
51 53
52 is_removing_ = true; 54 is_removing_ = true;
53 55
54 // Balanced in OnChannelOpened or OnError. Exactly one them will eventually be 56 // Balanced in OnChannelOpened or OnError. Exactly one them will eventually be
55 // called, so we need to keep this object around until then. 57 // called, so we need to keep this object around until then.
56 AddRef(); 58 AddRef();
57 PluginService::GetInstance()->OpenChannelToNpapiPlugin( 59 PluginService::GetInstance()->OpenChannelToNpapiPlugin(
58 0, 0, GURL(), mime_type_, this); 60 0, 0, GURL(), GURL(), mime_type_, this);
59 61
60 BrowserThread::PostDelayedTask( 62 BrowserThread::PostDelayedTask(
61 BrowserThread::IO, 63 BrowserThread::IO,
62 FROM_HERE, 64 FROM_HERE,
63 NewRunnableMethod(this, &PluginDataRemover::OnTimeout), 65 NewRunnableMethod(this, &PluginDataRemover::OnTimeout),
64 kRemovalTimeoutMs); 66 kRemovalTimeoutMs);
65 67
66 return event_.get(); 68 return event_.get();
67 } 69 }
68 70
(...skipping 11 matching lines...) Expand all
80 82
81 int PluginDataRemover::ID() { 83 int PluginDataRemover::ID() {
82 // Generate a unique identifier for this PluginProcessHostClient. 84 // Generate a unique identifier for this PluginProcessHostClient.
83 return ChildProcessInfo::GenerateChildProcessUniqueId(); 85 return ChildProcessInfo::GenerateChildProcessUniqueId();
84 } 86 }
85 87
86 bool PluginDataRemover::OffTheRecord() { 88 bool PluginDataRemover::OffTheRecord() {
87 return false; 89 return false;
88 } 90 }
89 91
92 const content::ResourceContext& PluginDataRemover::GetResourceContext() {
93 return context_;
94 }
95
90 void PluginDataRemover::SetPluginInfo( 96 void PluginDataRemover::SetPluginInfo(
91 const webkit::WebPluginInfo& info) { 97 const webkit::WebPluginInfo& info) {
92 } 98 }
93 99
94 void PluginDataRemover::OnChannelOpened(const IPC::ChannelHandle& handle) { 100 void PluginDataRemover::OnChannelOpened(const IPC::ChannelHandle& handle) {
95 ConnectToChannel(handle); 101 ConnectToChannel(handle);
96 // Balancing the AddRef call in StartRemoving. 102 // Balancing the AddRef call in StartRemoving.
97 Release(); 103 Release();
98 } 104 }
99 105
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
179 webkit::npapi::PluginGroup::CreateVersionFromString(plugin->version)); 185 webkit::npapi::PluginGroup::CreateVersionFromString(plugin->version));
180 scoped_ptr<Version> min_version(Version::GetVersionFromString( 186 scoped_ptr<Version> min_version(Version::GetVersionFromString(
181 CommandLine::ForCurrentProcess()->GetSwitchValueASCII( 187 CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
182 switches::kMinClearSiteDataFlashVersion))); 188 switches::kMinClearSiteDataFlashVersion)));
183 if (!min_version.get()) 189 if (!min_version.get())
184 min_version.reset(Version::GetVersionFromString(kMinFlashVersion)); 190 min_version.reset(Version::GetVersionFromString(kMinFlashVersion));
185 return plugin_prefs->IsPluginEnabled(*plugin) && 191 return plugin_prefs->IsPluginEnabled(*plugin) &&
186 version.get() && 192 version.get() &&
187 min_version->CompareTo(*version) == -1; 193 min_version->CompareTo(*version) == -1;
188 } 194 }
OLDNEW
« no previous file with comments | « chrome/browser/plugin_data_remover.h ('k') | chrome/browser/plugin_data_remover_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698