| OLD | NEW |
| 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/plugin/plugin_channel.h" | 5 #include "chrome/plugin/plugin_channel.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/lock.h" | 8 #include "base/lock.h" |
| 9 #include "base/process_util.h" | 9 #include "base/process_util.h" |
| 10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
| (...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 246 | 246 |
| 247 void PluginChannel::OnGenerateRouteID(int* route_id) { | 247 void PluginChannel::OnGenerateRouteID(int* route_id) { |
| 248 *route_id = GenerateRouteID(); | 248 *route_id = GenerateRouteID(); |
| 249 } | 249 } |
| 250 | 250 |
| 251 int PluginChannel::GenerateRouteID() { | 251 int PluginChannel::GenerateRouteID() { |
| 252 static int last_id = 0; | 252 static int last_id = 0; |
| 253 return ++last_id; | 253 return ++last_id; |
| 254 } | 254 } |
| 255 | 255 |
| 256 void PluginChannel::OnClearSiteData(uint64 flags, | 256 void PluginChannel::OnClearSiteData(const std::string& site, |
| 257 const std::string& domain, | 257 uint64 flags, |
| 258 base::Time begin_time) { | 258 base::Time begin_time) { |
| 259 bool success = false; | 259 bool success = false; |
| 260 CommandLine* command_line = CommandLine::ForCurrentProcess(); | 260 CommandLine* command_line = CommandLine::ForCurrentProcess(); |
| 261 FilePath path = command_line->GetSwitchValuePath(switches::kPluginPath); | 261 FilePath path = command_line->GetSwitchValuePath(switches::kPluginPath); |
| 262 scoped_refptr<webkit::npapi::PluginLib> plugin_lib( | 262 scoped_refptr<webkit::npapi::PluginLib> plugin_lib( |
| 263 webkit::npapi::PluginLib::CreatePluginLib(path)); | 263 webkit::npapi::PluginLib::CreatePluginLib(path)); |
| 264 if (plugin_lib.get()) { | 264 if (plugin_lib.get()) { |
| 265 NPError err = plugin_lib->NP_Initialize(); | 265 NPError err = plugin_lib->NP_Initialize(); |
| 266 if (err == NPERR_NO_ERROR) { | 266 if (err == NPERR_NO_ERROR) { |
| 267 scoped_refptr<webkit::npapi::PluginInstance> instance( | 267 const char* site_str = site.empty() ? NULL : site.c_str(); |
| 268 plugin_lib->CreateInstance(std::string())); | |
| 269 | |
| 270 const char* domain_str = domain.empty() ? NULL : domain.c_str(); | |
| 271 uint64 max_age; | 268 uint64 max_age; |
| 272 if (begin_time > base::Time()) { | 269 if (begin_time > base::Time()) { |
| 273 base::TimeDelta delta = base::Time::Now() - begin_time; | 270 base::TimeDelta delta = base::Time::Now() - begin_time; |
| 274 max_age = delta.InSeconds(); | 271 max_age = delta.InSeconds(); |
| 275 } else { | 272 } else { |
| 276 max_age = kuint64max; | 273 max_age = kuint64max; |
| 277 } | 274 } |
| 278 err = instance->NPP_ClearSiteData(flags, domain_str, max_age); | 275 err = plugin_lib->NP_ClearSiteData(site_str, flags, max_age); |
| 279 success = (err == NPERR_NO_ERROR); | 276 success = (err == NPERR_NO_ERROR); |
| 280 } | 277 } |
| 281 } | 278 } |
| 282 Send(new PluginHostMsg_ClearSiteDataResult(success)); | 279 Send(new PluginHostMsg_ClearSiteDataResult(success)); |
| 283 } | 280 } |
| 284 | 281 |
| 285 base::WaitableEvent* PluginChannel::GetModalDialogEvent( | 282 base::WaitableEvent* PluginChannel::GetModalDialogEvent( |
| 286 gfx::NativeViewId containing_window) { | 283 gfx::NativeViewId containing_window) { |
| 287 return filter_->GetModalDialogEvent(containing_window); | 284 return filter_->GetModalDialogEvent(containing_window); |
| 288 } | 285 } |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 320 } | 317 } |
| 321 | 318 |
| 322 bool PluginChannel::Init(MessageLoop* ipc_message_loop, bool create_pipe_now) { | 319 bool PluginChannel::Init(MessageLoop* ipc_message_loop, bool create_pipe_now) { |
| 323 if (!PluginChannelBase::Init(ipc_message_loop, create_pipe_now)) | 320 if (!PluginChannelBase::Init(ipc_message_loop, create_pipe_now)) |
| 324 return false; | 321 return false; |
| 325 | 322 |
| 326 channel_->AddFilter(filter_.get()); | 323 channel_->AddFilter(filter_.get()); |
| 327 return true; | 324 return true; |
| 328 } | 325 } |
| 329 | 326 |
| OLD | NEW |