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

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

Issue 7477044: Use PluginPrefs in ChromePluginServiceFilter to check whether a plugin is enabled. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: sync Created 9 years, 4 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/profiles/profile.h"
12 #include "chrome/common/chrome_switches.h" 13 #include "chrome/common/chrome_switches.h"
13 #include "content/browser/browser_thread.h" 14 #include "content/browser/browser_thread.h"
14 #include "content/browser/plugin_service.h" 15 #include "content/browser/plugin_service.h"
15 #include "content/common/plugin_messages.h" 16 #include "content/common/plugin_messages.h"
16 #include "webkit/plugins/npapi/plugin_group.h" 17 #include "webkit/plugins/npapi/plugin_group.h"
17 #include "webkit/plugins/npapi/plugin_list.h" 18 #include "webkit/plugins/npapi/plugin_list.h"
18 19
19 #if defined(OS_POSIX) 20 #if defined(OS_POSIX)
20 #include "ipc/ipc_channel_posix.h" 21 #include "ipc/ipc_channel_posix.h"
21 #endif 22 #endif
22 23
23 namespace { 24 namespace {
24 25
25 const char* kFlashMimeType = "application/x-shockwave-flash"; 26 const char* kFlashMimeType = "application/x-shockwave-flash";
26 // The minimum Flash Player version that implements NPP_ClearSiteData. 27 // The minimum Flash Player version that implements NPP_ClearSiteData.
27 const char* kMinFlashVersion = "10.3"; 28 const char* kMinFlashVersion = "10.3";
28 const int64 kRemovalTimeoutMs = 10000; 29 const int64 kRemovalTimeoutMs = 10000;
29 const uint64 kClearAllData = 0; 30 const uint64 kClearAllData = 0;
30 31
31 } // namespace 32 } // namespace
32 33
33 PluginDataRemover::PluginDataRemover() 34 PluginDataRemover::PluginDataRemover(Profile* profile)
34 : mime_type_(kFlashMimeType), 35 : mime_type_(kFlashMimeType),
35 is_removing_(false), 36 is_removing_(false),
37 context_(profile->GetResourceContext()),
36 event_(new base::WaitableEvent(true, false)), 38 event_(new base::WaitableEvent(true, false)),
37 channel_(NULL) { 39 channel_(NULL) {
38 } 40 }
39 41
40 PluginDataRemover::~PluginDataRemover() { 42 PluginDataRemover::~PluginDataRemover() {
41 DCHECK(!is_removing_); 43 DCHECK(!is_removing_);
42 if (channel_) 44 if (channel_)
43 BrowserThread::DeleteSoon(BrowserThread::IO, FROM_HERE, channel_); 45 BrowserThread::DeleteSoon(BrowserThread::IO, FROM_HERE, channel_);
44 } 46 }
45 47
46 base::WaitableEvent* PluginDataRemover::StartRemoving(base::Time begin_time) { 48 base::WaitableEvent* PluginDataRemover::StartRemoving(base::Time begin_time) {
47 DCHECK(!is_removing_); 49 DCHECK(!is_removing_);
48 remove_start_time_ = base::Time::Now(); 50 remove_start_time_ = base::Time::Now();
49 begin_time_ = begin_time; 51 begin_time_ = begin_time;
50 52
51 is_removing_ = true; 53 is_removing_ = true;
52 54
53 // Balanced in OnChannelOpened or OnError. Exactly one them will eventually be 55 // Balanced in OnChannelOpened or OnError. Exactly one them will eventually be
54 // called, so we need to keep this object around until then. 56 // called, so we need to keep this object around until then.
55 AddRef(); 57 AddRef();
56 PluginService::GetInstance()->OpenChannelToNpapiPlugin( 58 PluginService::GetInstance()->OpenChannelToNpapiPlugin(
57 0, 0, GURL(), mime_type_, this); 59 0, 0, GURL(), GURL(), mime_type_, this);
58 60
59 BrowserThread::PostDelayedTask( 61 BrowserThread::PostDelayedTask(
60 BrowserThread::IO, 62 BrowserThread::IO,
61 FROM_HERE, 63 FROM_HERE,
62 NewRunnableMethod(this, &PluginDataRemover::OnTimeout), 64 NewRunnableMethod(this, &PluginDataRemover::OnTimeout),
63 kRemovalTimeoutMs); 65 kRemovalTimeoutMs);
64 66
65 return event_.get(); 67 return event_.get();
66 } 68 }
67 69
(...skipping 11 matching lines...) Expand all
79 81
80 int PluginDataRemover::ID() { 82 int PluginDataRemover::ID() {
81 // Generate a unique identifier for this PluginProcessHostClient. 83 // Generate a unique identifier for this PluginProcessHostClient.
82 return ChildProcessInfo::GenerateChildProcessUniqueId(); 84 return ChildProcessInfo::GenerateChildProcessUniqueId();
83 } 85 }
84 86
85 bool PluginDataRemover::OffTheRecord() { 87 bool PluginDataRemover::OffTheRecord() {
86 return false; 88 return false;
87 } 89 }
88 90
91 const content::ResourceContext& PluginDataRemover::GetResourceContext() {
92 return context_;
93 }
94
89 void PluginDataRemover::SetPluginInfo( 95 void PluginDataRemover::SetPluginInfo(
90 const webkit::npapi::WebPluginInfo& info) { 96 const webkit::npapi::WebPluginInfo& info) {
91 } 97 }
92 98
93 void PluginDataRemover::OnChannelOpened(const IPC::ChannelHandle& handle) { 99 void PluginDataRemover::OnChannelOpened(const IPC::ChannelHandle& handle) {
94 ConnectToChannel(handle); 100 ConnectToChannel(handle);
95 // Balancing the AddRef call in StartRemoving. 101 // Balancing the AddRef call in StartRemoving.
96 Release(); 102 Release();
97 } 103 }
98 104
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
178 webkit::npapi::PluginGroup::CreateVersionFromString(plugin->version)); 184 webkit::npapi::PluginGroup::CreateVersionFromString(plugin->version));
179 scoped_ptr<Version> min_version(Version::GetVersionFromString( 185 scoped_ptr<Version> min_version(Version::GetVersionFromString(
180 CommandLine::ForCurrentProcess()->GetSwitchValueASCII( 186 CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
181 switches::kMinClearSiteDataFlashVersion))); 187 switches::kMinClearSiteDataFlashVersion)));
182 if (!min_version.get()) 188 if (!min_version.get())
183 min_version.reset(Version::GetVersionFromString(kMinFlashVersion)); 189 min_version.reset(Version::GetVersionFromString(kMinFlashVersion));
184 return webkit::npapi::IsPluginEnabled(*plugin) && 190 return webkit::npapi::IsPluginEnabled(*plugin) &&
185 version.get() && 191 version.get() &&
186 min_version->CompareTo(*version) == -1; 192 min_version->CompareTo(*version) == -1;
187 } 193 }
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