| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/ui/hung_plugin_tab_helper.h" | 5 #include "chrome/browser/ui/hung_plugin_tab_helper.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/files/file_path.h" | 8 #include "base/files/file_path.h" |
| 9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "base/process/process.h" | 10 #include "base/process/process.h" |
| 11 #include "base/rand_util.h" | 11 #include "base/rand_util.h" |
| 12 #include "build/build_config.h" | 12 #include "build/build_config.h" |
| 13 #include "chrome/browser/chrome_notification_types.h" | 13 #include "chrome/browser/chrome_notification_types.h" |
| 14 #include "chrome/browser/infobars/confirm_infobar_delegate.h" | 14 #include "chrome/browser/infobars/confirm_infobar_delegate.h" |
| 15 #include "chrome/browser/infobars/infobar.h" | 15 #include "chrome/browser/infobars/infobar.h" |
| 16 #include "chrome/browser/infobars/infobar_manager.h" |
| 16 #include "chrome/browser/infobars/infobar_service.h" | 17 #include "chrome/browser/infobars/infobar_service.h" |
| 17 #include "chrome/common/chrome_version_info.h" | 18 #include "chrome/common/chrome_version_info.h" |
| 18 #include "content/public/browser/browser_child_process_host_iterator.h" | 19 #include "content/public/browser/browser_child_process_host_iterator.h" |
| 19 #include "content/public/browser/browser_thread.h" | 20 #include "content/public/browser/browser_thread.h" |
| 20 #include "content/public/browser/child_process_data.h" | 21 #include "content/public/browser/child_process_data.h" |
| 21 #include "content/public/browser/notification_details.h" | 22 #include "content/public/browser/notification_details.h" |
| 22 #include "content/public/browser/notification_service.h" | 23 #include "content/public/browser/notification_service.h" |
| 23 #include "content/public/browser/plugin_service.h" | 24 #include "content/public/browser/plugin_service.h" |
| 24 #include "content/public/browser/render_process_host.h" | 25 #include "content/public/browser/render_process_host.h" |
| 25 #include "content/public/common/process_type.h" | 26 #include "content/public/common/process_type.h" |
| (...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 271 void HungPluginTabHelper::PluginCrashed(const base::FilePath& plugin_path, | 272 void HungPluginTabHelper::PluginCrashed(const base::FilePath& plugin_path, |
| 272 base::ProcessId plugin_pid) { | 273 base::ProcessId plugin_pid) { |
| 273 // TODO(brettw) ideally this would take the child process ID. When we do this | 274 // TODO(brettw) ideally this would take the child process ID. When we do this |
| 274 // for NaCl plugins, we'll want to know exactly which process it was since | 275 // for NaCl plugins, we'll want to know exactly which process it was since |
| 275 // the path won't be useful. | 276 // the path won't be useful. |
| 276 InfoBarService* infobar_service = | 277 InfoBarService* infobar_service = |
| 277 InfoBarService::FromWebContents(web_contents()); | 278 InfoBarService::FromWebContents(web_contents()); |
| 278 if (!infobar_service) | 279 if (!infobar_service) |
| 279 return; | 280 return; |
| 280 | 281 |
| 282 InfoBarManager* infobar_manager = infobar_service->infobar_manager(); |
| 281 // For now, just do a brute-force search to see if we have this plugin. Since | 283 // For now, just do a brute-force search to see if we have this plugin. Since |
| 282 // we'll normally have 0 or 1, this is fast. | 284 // we'll normally have 0 or 1, this is fast. |
| 283 for (PluginStateMap::iterator i = hung_plugins_.begin(); | 285 for (PluginStateMap::iterator i = hung_plugins_.begin(); |
| 284 i != hung_plugins_.end(); ++i) { | 286 i != hung_plugins_.end(); ++i) { |
| 285 if (i->second->path == plugin_path) { | 287 if (i->second->path == plugin_path) { |
| 286 if (i->second->infobar) | 288 if (i->second->infobar) |
| 287 infobar_service->RemoveInfoBar(i->second->infobar); | 289 infobar_manager->RemoveInfoBar(i->second->infobar); |
| 288 hung_plugins_.erase(i); | 290 hung_plugins_.erase(i); |
| 289 break; | 291 break; |
| 290 } | 292 } |
| 291 } | 293 } |
| 292 } | 294 } |
| 293 | 295 |
| 294 void HungPluginTabHelper::PluginHungStatusChanged( | 296 void HungPluginTabHelper::PluginHungStatusChanged( |
| 295 int plugin_child_id, | 297 int plugin_child_id, |
| 296 const base::FilePath& plugin_path, | 298 const base::FilePath& plugin_path, |
| 297 bool is_hung) { | 299 bool is_hung) { |
| 298 InfoBarService* infobar_service = | 300 InfoBarService* infobar_service = |
| 299 InfoBarService::FromWebContents(web_contents()); | 301 InfoBarService::FromWebContents(web_contents()); |
| 300 if (!infobar_service) | 302 if (!infobar_service) |
| 301 return; | 303 return; |
| 302 | 304 |
| 305 InfoBarManager* infobar_manager = infobar_service->infobar_manager(); |
| 303 PluginStateMap::iterator found = hung_plugins_.find(plugin_child_id); | 306 PluginStateMap::iterator found = hung_plugins_.find(plugin_child_id); |
| 304 if (found != hung_plugins_.end()) { | 307 if (found != hung_plugins_.end()) { |
| 305 if (!is_hung) { | 308 if (!is_hung) { |
| 306 // Hung plugin became un-hung, close the infobar and delete our info. | 309 // Hung plugin became un-hung, close the infobar and delete our info. |
| 307 if (found->second->infobar) | 310 if (found->second->infobar) |
| 308 infobar_service->RemoveInfoBar(found->second->infobar); | 311 infobar_manager->RemoveInfoBar(found->second->infobar); |
| 309 hung_plugins_.erase(found); | 312 hung_plugins_.erase(found); |
| 310 } | 313 } |
| 311 return; | 314 return; |
| 312 } | 315 } |
| 313 | 316 |
| 314 base::string16 plugin_name = | 317 base::string16 plugin_name = |
| 315 content::PluginService::GetInstance()->GetPluginDisplayNameByPath( | 318 content::PluginService::GetInstance()->GetPluginDisplayNameByPath( |
| 316 plugin_path); | 319 plugin_path); |
| 317 | 320 |
| 318 linked_ptr<PluginState> state(new PluginState(plugin_path, plugin_name)); | 321 linked_ptr<PluginState> state(new PluginState(plugin_path, plugin_name)); |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 409 | 412 |
| 410 DCHECK(!state->infobar); | 413 DCHECK(!state->infobar); |
| 411 state->infobar = HungPluginInfoBarDelegate::Create(infobar_service, this, | 414 state->infobar = HungPluginInfoBarDelegate::Create(infobar_service, this, |
| 412 child_id, state->name); | 415 child_id, state->name); |
| 413 } | 416 } |
| 414 | 417 |
| 415 void HungPluginTabHelper::CloseBar(PluginState* state) { | 418 void HungPluginTabHelper::CloseBar(PluginState* state) { |
| 416 InfoBarService* infobar_service = | 419 InfoBarService* infobar_service = |
| 417 InfoBarService::FromWebContents(web_contents()); | 420 InfoBarService::FromWebContents(web_contents()); |
| 418 if (infobar_service && state->infobar) { | 421 if (infobar_service && state->infobar) { |
| 419 infobar_service->RemoveInfoBar(state->infobar); | 422 infobar_service->infobar_manager()->RemoveInfoBar(state->infobar); |
| 420 state->infobar = NULL; | 423 state->infobar = NULL; |
| 421 } | 424 } |
| 422 } | 425 } |
| OLD | NEW |