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