| 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/process_util.h" | 8 #include "base/process_util.h" |
| 9 #include "build/build_config.h" |
| 9 #include "chrome/browser/infobars/infobar_tab_helper.h" | 10 #include "chrome/browser/infobars/infobar_tab_helper.h" |
| 10 #include "chrome/browser/tab_contents/confirm_infobar_delegate.h" | 11 #include "chrome/browser/tab_contents/confirm_infobar_delegate.h" |
| 11 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" | 12 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" |
| 12 #include "content/public/browser/browser_thread.h" | 13 #include "content/public/browser/browser_thread.h" |
| 13 #include "content/public/browser/browser_child_process_host_iterator.h" | 14 #include "content/public/browser/browser_child_process_host_iterator.h" |
| 14 #include "content/public/browser/child_process_data.h" | 15 #include "content/public/browser/child_process_data.h" |
| 15 #include "content/public/browser/plugin_service.h" | 16 #include "content/public/browser/plugin_service.h" |
| 16 #include "content/public/common/result_codes.h" | 17 #include "content/public/common/result_codes.h" |
| 17 #include "grit/chromium_strings.h" | 18 #include "grit/chromium_strings.h" |
| 18 #include "grit/generated_resources.h" | 19 #include "grit/generated_resources.h" |
| 19 #include "grit/locale_settings.h" | 20 #include "grit/locale_settings.h" |
| 20 #include "grit/theme_resources_standard.h" | 21 #include "grit/theme_resources_standard.h" |
| 21 #include "ui/base/l10n/l10n_util.h" | 22 #include "ui/base/l10n/l10n_util.h" |
| 22 #include "ui/base/resource/resource_bundle.h" | 23 #include "ui/base/resource/resource_bundle.h" |
| 23 | 24 |
| 25 #if defined(OS_WIN) |
| 26 #include "chrome/browser/hang_monitor/hang_crash_dump_win.h" |
| 27 #endif |
| 28 |
| 24 namespace { | 29 namespace { |
| 25 | 30 |
| 26 // Delay in seconds before re-showing the hung plugin message. This will be | 31 // Delay in seconds before re-showing the hung plugin message. This will be |
| 27 // increased each time. | 32 // increased each time. |
| 28 const int kInitialReshowDelaySec = 10; | 33 const int kInitialReshowDelaySec = 10; |
| 29 | 34 |
| 30 // Called on the I/O thread to actually kill the plugin with the given child | 35 // Called on the I/O thread to actually kill the plugin with the given child |
| 31 // ID. We specifically don't want this to be a member function since if the | 36 // ID. We specifically don't want this to be a member function since if the |
| 32 // user chooses to kill the plugin, we want to kill it even if they close the | 37 // user chooses to kill the plugin, we want to kill it even if they close the |
| 33 // tab first. | 38 // tab first. |
| 34 // | 39 // |
| 35 // Be careful with the child_id. It's supplied by the renderer which might be | 40 // Be careful with the child_id. It's supplied by the renderer which might be |
| 36 // hacked. | 41 // hacked. |
| 37 void KillPluginOnIOThread(int child_id) { | 42 void KillPluginOnIOThread(int child_id) { |
| 38 content::BrowserChildProcessHostIterator iter( | 43 content::BrowserChildProcessHostIterator iter( |
| 39 content::PROCESS_TYPE_PPAPI_PLUGIN); | 44 content::PROCESS_TYPE_PPAPI_PLUGIN); |
| 40 while (!iter.Done()) { | 45 while (!iter.Done()) { |
| 41 const content::ChildProcessData& data = iter.GetData(); | 46 const content::ChildProcessData& data = iter.GetData(); |
| 42 if (data.id == child_id) { | 47 if (data.id == child_id) { |
| 43 // TODO(brettw) bug 123021: it might be nice to do some stuff to capture | 48 #if defined(OS_WIN) |
| 44 // a stack. The NPAPI Windows hang monitor does some cool stuff in | 49 CrashDumpAndTerminateHungChildProcess(data.handle); |
| 45 // hung_window_detector.cc. | 50 #else |
| 46 base::KillProcess(data.handle, content::RESULT_CODE_HUNG, false); | 51 base::KillProcess(data.handle, content::RESULT_CODE_HUNG, false); |
| 52 #endif |
| 47 break; | 53 break; |
| 48 } | 54 } |
| 49 ++iter; | 55 ++iter; |
| 50 } | 56 } |
| 51 // Ignore the case where we didn't find the plugin, it may have terminated | 57 // Ignore the case where we didn't find the plugin, it may have terminated |
| 52 // before this function could run. | 58 // before this function could run. |
| 53 } | 59 } |
| 54 | 60 |
| 55 } // namespace | 61 } // namespace |
| 56 | 62 |
| (...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 259 } | 265 } |
| 260 } | 266 } |
| 261 | 267 |
| 262 InfoBarTabHelper* HungPluginTabHelper::GetInfoBarHelper() { | 268 InfoBarTabHelper* HungPluginTabHelper::GetInfoBarHelper() { |
| 263 TabContentsWrapper* tcw = | 269 TabContentsWrapper* tcw = |
| 264 TabContentsWrapper::GetCurrentWrapperForContents(web_contents()); | 270 TabContentsWrapper::GetCurrentWrapperForContents(web_contents()); |
| 265 if (!tcw) | 271 if (!tcw) |
| 266 return NULL; | 272 return NULL; |
| 267 return tcw->infobar_tab_helper(); | 273 return tcw->infobar_tab_helper(); |
| 268 } | 274 } |
| OLD | NEW |