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

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

Issue 6148006: Update our use of the NPAPI ClearSiteData API. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: review Created 9 years, 11 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 | « no previous file | chrome/common/plugin_messages_internal.h » ('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) 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/metrics/histogram.h" 8 #include "base/metrics/histogram.h"
9 #include "base/version.h" 9 #include "base/version.h"
10 #include "chrome/browser/browser_thread.h" 10 #include "chrome/browser/browser_thread.h"
11 #include "chrome/browser/plugin_service.h" 11 #include "chrome/browser/plugin_service.h"
12 #include "chrome/common/plugin_messages.h" 12 #include "chrome/common/plugin_messages.h"
13 #include "webkit/plugins/npapi/plugin_group.h" 13 #include "webkit/plugins/npapi/plugin_group.h"
14 #include "webkit/plugins/npapi/plugin_list.h" 14 #include "webkit/plugins/npapi/plugin_list.h"
15 15
16 #if defined(OS_POSIX) 16 #if defined(OS_POSIX)
17 #include "ipc/ipc_channel_posix.h" 17 #include "ipc/ipc_channel_posix.h"
18 #endif 18 #endif
19 19
20 namespace { 20 namespace {
21 const char* g_flash_mime_type = "application/x-shockwave-flash"; 21 const char* kFlashMimeType = "application/x-shockwave-flash";
22 // TODO(bauerb): Update minimum required Flash version as soon as there is one 22 // TODO(bauerb): Update minimum required Flash version as soon as there is one
23 // implementing the API. 23 // implementing the API.
24 const char* g_min_flash_version = "100"; 24 const char* kMinFlashVersion = "100";
25 const int64 g_timeout_ms = 10000; 25 const int64 kRemovalTimeoutMs = 10000;
26 const uint64 kClearAllData = 0;
26 } // namespace 27 } // namespace
27 28
28 PluginDataRemover::PluginDataRemover() 29 PluginDataRemover::PluginDataRemover()
29 : is_removing_(false), 30 : is_removing_(false),
30 channel_(NULL) { } 31 channel_(NULL) { }
31 32
32 PluginDataRemover::~PluginDataRemover() { 33 PluginDataRemover::~PluginDataRemover() {
33 DCHECK(!is_removing_); 34 DCHECK(!is_removing_);
34 if (channel_) 35 if (channel_)
35 BrowserThread::DeleteSoon(BrowserThread::IO, FROM_HERE, channel_); 36 BrowserThread::DeleteSoon(BrowserThread::IO, FROM_HERE, channel_);
36 } 37 }
37 38
38 void PluginDataRemover::StartRemoving(base::Time begin_time, Task* done_task) { 39 void PluginDataRemover::StartRemoving(base::Time begin_time, Task* done_task) {
39 DCHECK(!done_task_.get()); 40 DCHECK(!done_task_.get());
40 DCHECK(!is_removing_); 41 DCHECK(!is_removing_);
41 remove_start_time_ = base::Time::Now(); 42 remove_start_time_ = base::Time::Now();
42 begin_time_ = begin_time; 43 begin_time_ = begin_time;
43 44
44 message_loop_ = base::MessageLoopProxy::CreateForCurrentThread(); 45 message_loop_ = base::MessageLoopProxy::CreateForCurrentThread();
45 done_task_.reset(done_task); 46 done_task_.reset(done_task);
46 is_removing_ = true; 47 is_removing_ = true;
47 48
48 AddRef(); 49 AddRef();
49 PluginService::GetInstance()->OpenChannelToPlugin( 50 PluginService::GetInstance()->OpenChannelToPlugin(
50 GURL(), g_flash_mime_type, this); 51 GURL(), kFlashMimeType, this);
51 52
52 BrowserThread::PostDelayedTask( 53 BrowserThread::PostDelayedTask(
53 BrowserThread::IO, 54 BrowserThread::IO,
54 FROM_HERE, 55 FROM_HERE,
55 NewRunnableMethod(this, &PluginDataRemover::OnTimeout), 56 NewRunnableMethod(this, &PluginDataRemover::OnTimeout),
56 g_timeout_ms); 57 kRemovalTimeoutMs);
57 } 58 }
58 59
59 int PluginDataRemover::ID() { 60 int PluginDataRemover::ID() {
60 // Generate an ID for the browser process. 61 // Generate an ID for the browser process.
61 return ChildProcessInfo::GenerateChildProcessUniqueId(); 62 return ChildProcessInfo::GenerateChildProcessUniqueId();
62 } 63 }
63 64
64 bool PluginDataRemover::OffTheRecord() { 65 bool PluginDataRemover::OffTheRecord() {
65 return false; 66 return false;
66 } 67 }
(...skipping 16 matching lines...) Expand all
83 84
84 DCHECK(!channel_); 85 DCHECK(!channel_);
85 channel_ = new IPC::Channel(handle, IPC::Channel::MODE_CLIENT, this); 86 channel_ = new IPC::Channel(handle, IPC::Channel::MODE_CLIENT, this);
86 if (!channel_->Connect()) { 87 if (!channel_->Connect()) {
87 LOG(DFATAL) << "Couldn't connect to plugin"; 88 LOG(DFATAL) << "Couldn't connect to plugin";
88 SignalDone(); 89 SignalDone();
89 return; 90 return;
90 } 91 }
91 92
92 if (!channel_->Send( 93 if (!channel_->Send(
93 new PluginMsg_ClearSiteData(0, std::string(), begin_time_))) { 94 new PluginMsg_ClearSiteData(std::string(),
95 kClearAllData,
96 begin_time_))) {
94 LOG(DFATAL) << "Couldn't send ClearSiteData message"; 97 LOG(DFATAL) << "Couldn't send ClearSiteData message";
95 SignalDone(); 98 SignalDone();
96 } 99 }
97 } 100 }
98 101
99 void PluginDataRemover::OnError() { 102 void PluginDataRemover::OnError() {
100 NOTREACHED() << "Couldn't open plugin channel"; 103 NOTREACHED() << "Couldn't open plugin channel";
101 SignalDone(); 104 SignalDone();
102 Release(); 105 Release();
103 } 106 }
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 message_loop_ = NULL; 143 message_loop_ = NULL;
141 } 144 }
142 } 145 }
143 146
144 // static 147 // static
145 bool PluginDataRemover::IsSupported() { 148 bool PluginDataRemover::IsSupported() {
146 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); 149 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
147 bool allow_wildcard = false; 150 bool allow_wildcard = false;
148 webkit::npapi::WebPluginInfo plugin; 151 webkit::npapi::WebPluginInfo plugin;
149 std::string mime_type; 152 std::string mime_type;
150 if (!webkit::npapi::PluginList::Singleton()->GetPluginInfo(GURL(), 153 if (!webkit::npapi::PluginList::Singleton()->GetPluginInfo(
151 g_flash_mime_type, 154 GURL(), kFlashMimeType, allow_wildcard, &plugin, &mime_type)) {
152 allow_wildcard,
153 &plugin,
154 &mime_type))
155 return false; 155 return false;
156 }
156 scoped_ptr<Version> version( 157 scoped_ptr<Version> version(
157 webkit::npapi::PluginGroup::CreateVersionFromString(plugin.version)); 158 webkit::npapi::PluginGroup::CreateVersionFromString(plugin.version));
158 scoped_ptr<Version> min_version( 159 scoped_ptr<Version> min_version(
159 Version::GetVersionFromString(g_min_flash_version)); 160 Version::GetVersionFromString(kMinFlashVersion));
160 return plugin.enabled && 161 return plugin.enabled &&
161 version.get() && 162 version.get() &&
162 min_version->CompareTo(*version) == -1; 163 min_version->CompareTo(*version) == -1;
163 } 164 }
OLDNEW
« no previous file with comments | « no previous file | chrome/common/plugin_messages_internal.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698