Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(559)

Side by Side Diff: chrome/browser/ui/hung_plugin_tab_helper.h

Issue 10968043: Switch HungPluginTabHelper to use WebContentsUserData. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/ui/browser.cc ('k') | chrome/browser/ui/hung_plugin_tab_helper.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #ifndef CHROME_BROWSER_UI_HUNG_PLUGIN_TAB_HELPER_H_ 5 #ifndef CHROME_BROWSER_UI_HUNG_PLUGIN_TAB_HELPER_H_
6 #define CHROME_BROWSER_UI_HUNG_PLUGIN_TAB_HELPER_H_ 6 #define CHROME_BROWSER_UI_HUNG_PLUGIN_TAB_HELPER_H_
7 7
8 #include <map> 8 #include <map>
9 9
10 #include "base/file_path.h" 10 #include "base/file_path.h"
11 #include "base/memory/linked_ptr.h" 11 #include "base/memory/linked_ptr.h"
12 #include "base/string16.h" 12 #include "base/string16.h"
13 #include "base/time.h" 13 #include "base/time.h"
14 #include "base/timer.h" 14 #include "base/timer.h"
15 #include "chrome/browser/tab_contents/web_contents_user_data.h"
15 #include "content/public/browser/notification_observer.h" 16 #include "content/public/browser/notification_observer.h"
16 #include "content/public/browser/notification_registrar.h" 17 #include "content/public/browser/notification_registrar.h"
17 #include "content/public/browser/web_contents_observer.h" 18 #include "content/public/browser/web_contents_observer.h"
18 19
19 class FilePath; 20 class FilePath;
20 class InfoBarTabHelper; 21 class InfoBarTabHelper;
21 22
22 // Manages per-tab state with regard to hung plugins. This only handles 23 // Manages per-tab state with regard to hung plugins. This only handles
23 // Pepper plugins which we know are windowless. Hung NPAPI plugins (which 24 // Pepper plugins which we know are windowless. Hung NPAPI plugins (which
24 // may have native windows) can not be handled with infobars and have a 25 // may have native windows) can not be handled with infobars and have a
25 // separate OS-specific hang monitoring. 26 // separate OS-specific hang monitoring.
26 // 27 //
27 // Our job is: 28 // Our job is:
28 // - Pop up an infobar when a plugin is hung. 29 // - Pop up an infobar when a plugin is hung.
29 // - Terminate the plugin process if the user so chooses. 30 // - Terminate the plugin process if the user so chooses.
30 // - Periodically re-show the hung plugin infobar if the user closes it without 31 // - Periodically re-show the hung plugin infobar if the user closes it without
31 // terminating the plugin. 32 // terminating the plugin.
32 // - Hide the infobar if the plugin starts responding again. 33 // - Hide the infobar if the plugin starts responding again.
33 // - Keep track of all of this for any number of plugins. 34 // - Keep track of all of this for any number of plugins.
34 class HungPluginTabHelper : public content::WebContentsObserver, 35 class HungPluginTabHelper : public content::WebContentsObserver,
35 public content::NotificationObserver { 36 public content::NotificationObserver,
37 public WebContentsUserData<HungPluginTabHelper> {
36 public: 38 public:
37 explicit HungPluginTabHelper(content::WebContents* contents);
38 virtual ~HungPluginTabHelper(); 39 virtual ~HungPluginTabHelper();
39 40
40 // content::WebContentsObserver overrides: 41 // content::WebContentsObserver overrides:
41 virtual void PluginCrashed(const FilePath& plugin_path) OVERRIDE; 42 virtual void PluginCrashed(const FilePath& plugin_path) OVERRIDE;
42 virtual void PluginHungStatusChanged(int plugin_child_id, 43 virtual void PluginHungStatusChanged(int plugin_child_id,
43 const FilePath& plugin_path, 44 const FilePath& plugin_path,
44 bool is_hung) OVERRIDE; 45 bool is_hung) OVERRIDE;
45 46
46 // NotificationObserver overrides. 47 // NotificationObserver overrides.
47 virtual void Observe(int type, 48 virtual void Observe(int type,
48 const content::NotificationSource& source, 49 const content::NotificationSource& source,
49 const content::NotificationDetails& details) OVERRIDE; 50 const content::NotificationDetails& details) OVERRIDE;
50 51
51 private: 52 private:
53 explicit HungPluginTabHelper(content::WebContents* contents);
54 static int kUserDataKey;
55 friend class WebContentsUserData<HungPluginTabHelper>;
56
52 class InfoBarDelegate; 57 class InfoBarDelegate;
53 friend class InfoBarDelegate; 58 friend class InfoBarDelegate;
54 59
55 // Per-plugin state (since there could be more than one plugin hung). The 60 // Per-plugin state (since there could be more than one plugin hung). The
56 // integer key is the child process ID of the plugin process. This maintains 61 // integer key is the child process ID of the plugin process. This maintains
57 // the state for all plugins on this page that are currently hung, whether or 62 // the state for all plugins on this page that are currently hung, whether or
58 // not we're currently showing the infobar. 63 // not we're currently showing the infobar.
59 struct PluginState { 64 struct PluginState {
60 // Initializes the plugin state to be a hung plugin. 65 // Initializes the plugin state to be a hung plugin.
61 PluginState(const FilePath& p, const string16& n); 66 PluginState(const FilePath& p, const string16& n);
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 105
101 content::NotificationRegistrar registrar_; 106 content::NotificationRegistrar registrar_;
102 107
103 // All currently hung plugins. 108 // All currently hung plugins.
104 PluginStateMap hung_plugins_; 109 PluginStateMap hung_plugins_;
105 110
106 DISALLOW_COPY_AND_ASSIGN(HungPluginTabHelper); 111 DISALLOW_COPY_AND_ASSIGN(HungPluginTabHelper);
107 }; 112 };
108 113
109 #endif // CHROME_BROWSER_UI_HUNG_PLUGIN_TAB_HELPER_H_ 114 #endif // CHROME_BROWSER_UI_HUNG_PLUGIN_TAB_HELPER_H_
OLDNEW
« no previous file with comments | « chrome/browser/ui/browser.cc ('k') | chrome/browser/ui/hung_plugin_tab_helper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698