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

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

Issue 5278001: Add a preference to clear Flash LSO data in the Clear Browsing Data dialog. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 10 years, 1 month 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
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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/message_loop_proxy.h" 7 #include "base/message_loop_proxy.h"
8 #include "base/version.h"
8 #include "chrome/browser/browser_thread.h" 9 #include "chrome/browser/browser_thread.h"
9 #include "chrome/browser/plugin_service.h" 10 #include "chrome/browser/plugin_service.h"
10 #include "chrome/common/plugin_messages.h" 11 #include "chrome/common/plugin_messages.h"
11 #include "ipc/ipc_channel.h" 12 #include "ipc/ipc_channel.h"
13 #include "webkit/glue/plugins/plugin_group.h"
14 #include "webkit/glue/plugins/plugin_list.h"
12 15
13 #if defined(OS_POSIX) 16 #if defined(OS_POSIX)
14 #include "ipc/ipc_channel_posix.h" 17 #include "ipc/ipc_channel_posix.h"
15 #endif 18 #endif
16 19
17 namespace { 20 namespace {
18 const std::string flash_mime_type = "application/x-shockwave-flash"; 21 const std::string flash_mime_type = "application/x-shockwave-flash";
22 const std::string min_flash_version = "10.2";
19 const int64 timeout_ms = 10000; 23 const int64 timeout_ms = 10000;
20 } 24 }
21 25
22 PluginDataRemover::PluginDataRemover() 26 PluginDataRemover::PluginDataRemover()
23 : channel_(NULL), 27 : channel_(NULL),
24 method_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) { 28 method_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) {
25 } 29 }
26 30
27 PluginDataRemover::~PluginDataRemover() { 31 PluginDataRemover::~PluginDataRemover() {
28 DCHECK(!done_task_.get()); 32 DCHECK(!done_task_.get());
29 if (!BrowserThread::DeleteSoon(BrowserThread::IO, FROM_HERE, channel_)) 33 if (!BrowserThread::DeleteSoon(BrowserThread::IO, FROM_HERE, channel_))
30 delete channel_; 34 delete channel_;
31 } 35 }
32 36
33 void PluginDataRemover::StartRemoving(base::Time begin_time, Task* done_task) { 37 void PluginDataRemover::StartRemoving(base::Time begin_time, Task* done_task) {
34 DCHECK(!done_task_.get()); 38 DCHECK(!done_task_.get());
35 begin_time_ = begin_time; 39 begin_time_ = begin_time;
36 40
37 message_loop_ = base::MessageLoopProxy::CreateForCurrentThread(); 41 message_loop_ = base::MessageLoopProxy::CreateForCurrentThread();
38 done_task_.reset(done_task); 42 done_task_.reset(done_task);
39 43
40 PluginService::GetInstance()->OpenChannelToPlugin( 44 PluginService::GetInstance()->OpenChannelToPlugin(
41 GURL(), flash_mime_type, this); 45 GURL(), flash_mime_type, this);
42 46
43 BrowserThread::PostDelayedTask( 47 MessageLoop::current()->PostDelayedTask(
44 BrowserThread::IO,
45 FROM_HERE, 48 FROM_HERE,
46 method_factory_.NewRunnableMethod(&PluginDataRemover::OnTimeout), 49 method_factory_.NewRunnableMethod(&PluginDataRemover::OnTimeout),
47 timeout_ms); 50 timeout_ms);
48 } 51 }
49 52
50 int PluginDataRemover::ID() { 53 int PluginDataRemover::ID() {
51 // Generate an ID for the browser process. 54 // Generate an ID for the browser process.
52 return ChildProcessInfo::GenerateChildProcessUniqueId(); 55 return ChildProcessInfo::GenerateChildProcessUniqueId();
53 } 56 }
54 57
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 IPC_MESSAGE_UNHANDLED_ERROR() 106 IPC_MESSAGE_UNHANDLED_ERROR()
104 IPC_END_MESSAGE_MAP() 107 IPC_END_MESSAGE_MAP()
105 } 108 }
106 109
107 void PluginDataRemover::OnChannelError() { 110 void PluginDataRemover::OnChannelError() {
108 NOTREACHED() << "Channel error"; 111 NOTREACHED() << "Channel error";
109 SignalDone(); 112 SignalDone();
110 } 113 }
111 114
112 void PluginDataRemover::SignalDone() { 115 void PluginDataRemover::SignalDone() {
113 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 116 // This method could be called from the timeout callback while in another
117 // callback, so we keep a lock while releasing |done_task_|.
118 AutoLock lock(task_lock_);
114 if (!done_task_.get()) 119 if (!done_task_.get())
115 return; 120 return;
116 message_loop_->PostTask(FROM_HERE, done_task_.release()); 121 message_loop_->PostTask(FROM_HERE, done_task_.release());
117 message_loop_ = NULL; 122 message_loop_ = NULL;
118 } 123 }
124
125 // static
126 bool PluginDataRemover::IsSupported() {
127 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
128 bool allow_wildcard = false;
129 WebPluginInfo plugin;
130 std::string mime_type;
131 if (!NPAPI::PluginList::Singleton()->GetPluginInfo(GURL(),
132 flash_mime_type,
133 allow_wildcard,
134 &plugin,
135 &mime_type))
136 return false;
137 scoped_ptr<Version> version(
138 PluginGroup::CreateVersionFromString(plugin.version));
139 scoped_ptr<Version> min_version(
140 Version::GetVersionFromString(min_flash_version));
141 return plugin.enabled &&
142 version.get()
143 && min_version->CompareTo(*version) == -1;
144 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698