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