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

Side by Side Diff: chrome/browser/plugins/plugin_observer.h

Issue 10961051: Switch PluginObserver to use WebContentsUserData. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: commentary Created 8 years, 2 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
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_PLUGINS_PLUGIN_OBSERVER_H_ 5 #ifndef CHROME_BROWSER_PLUGINS_PLUGIN_OBSERVER_H_
6 #define CHROME_BROWSER_PLUGINS_PLUGIN_OBSERVER_H_ 6 #define CHROME_BROWSER_PLUGINS_PLUGIN_OBSERVER_H_
7 7
8 #include "base/memory/weak_ptr.h" 8 #include "base/memory/weak_ptr.h"
9 #include "chrome/browser/tab_contents/web_contents_user_data.h"
9 #include "content/public/browser/web_contents_observer.h" 10 #include "content/public/browser/web_contents_observer.h"
10 11
11 #if defined(ENABLE_PLUGIN_INSTALLATION) 12 #if defined(ENABLE_PLUGIN_INSTALLATION)
12 #include <map> 13 #include <map>
13 #endif 14 #endif
14 15
15 class GURL; 16 class GURL;
16 class InfoBarDelegate; 17 class InfoBarDelegate;
17 class PluginFinder; 18 class PluginFinder;
18 class TabContents;
19 19
20 #if defined(ENABLE_PLUGIN_INSTALLATION) 20 #if defined(ENABLE_PLUGIN_INSTALLATION)
21 class PluginInstaller; 21 class PluginInstaller;
22 class PluginPlaceholderHost; 22 class PluginPlaceholderHost;
23 #endif 23 #endif
24 24
25 class PluginObserver : public content::WebContentsObserver { 25 namespace content {
26 class WebContents;
27 }
28
29 class PluginObserver : public content::WebContentsObserver,
30 public WebContentsUserData<PluginObserver> {
26 public: 31 public:
27 explicit PluginObserver(TabContents* tab_contents);
28 virtual ~PluginObserver(); 32 virtual ~PluginObserver();
29 33
30 // content::WebContentsObserver implementation. 34 // content::WebContentsObserver implementation.
31 virtual void PluginCrashed(const FilePath& plugin_path) OVERRIDE; 35 virtual void PluginCrashed(const FilePath& plugin_path) OVERRIDE;
32 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; 36 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
33 37
34 #if defined(ENABLE_PLUGIN_INSTALLATION) 38 #if defined(ENABLE_PLUGIN_INSTALLATION)
35 void InstallMissingPlugin(PluginInstaller* installer); 39 void InstallMissingPlugin(PluginInstaller* installer);
36 #endif 40 #endif
37 41
38 TabContents* tab_contents() { return tab_contents_; } 42 // Make public the web_contents() accessor that is protected in the parent.
43 using content::WebContentsObserver::web_contents;
39 44
40 private: 45 private:
46 explicit PluginObserver(content::WebContents* web_contents);
47 static int kUserDataKey;
48 friend class WebContentsUserData<PluginObserver>;
49
41 class PluginPlaceholderHost; 50 class PluginPlaceholderHost;
42 51
43 void OnBlockedUnauthorizedPlugin(const string16& name, 52 void OnBlockedUnauthorizedPlugin(const string16& name,
44 const std::string& identifier); 53 const std::string& identifier);
45 void OnBlockedOutdatedPlugin(int placeholder_id, 54 void OnBlockedOutdatedPlugin(int placeholder_id,
46 const std::string& identifier); 55 const std::string& identifier);
47 #if defined(ENABLE_PLUGIN_INSTALLATION) 56 #if defined(ENABLE_PLUGIN_INSTALLATION)
48 void OnFindMissingPlugin(int placeholder_id, const std::string& mime_type); 57 void OnFindMissingPlugin(int placeholder_id, const std::string& mime_type);
49 58
50 void FindMissingPlugin(int placeholder_id, 59 void FindMissingPlugin(int placeholder_id,
51 const std::string& mime_type, 60 const std::string& mime_type,
52 PluginFinder* plugin_finder); 61 PluginFinder* plugin_finder);
53 void FindPluginToUpdate(int placeholder_id, 62 void FindPluginToUpdate(int placeholder_id,
54 const std::string& identifier, 63 const std::string& identifier,
55 PluginFinder* plugin_finder); 64 PluginFinder* plugin_finder);
56 void OnRemovePluginPlaceholderHost(int placeholder_id); 65 void OnRemovePluginPlaceholderHost(int placeholder_id);
57 #endif 66 #endif
58 void OnOpenAboutPlugins(); 67 void OnOpenAboutPlugins();
59 void OnCouldNotLoadPlugin(const FilePath& plugin_path); 68 void OnCouldNotLoadPlugin(const FilePath& plugin_path);
60 69
61 base::WeakPtrFactory<PluginObserver> weak_ptr_factory_; 70 base::WeakPtrFactory<PluginObserver> weak_ptr_factory_;
62 71
63 TabContents* tab_contents_;
64
65 #if defined(ENABLE_PLUGIN_INSTALLATION) 72 #if defined(ENABLE_PLUGIN_INSTALLATION)
66 // Stores all PluginPlaceholderHosts, keyed by their routing ID. 73 // Stores all PluginPlaceholderHosts, keyed by their routing ID.
67 std::map<int, PluginPlaceholderHost*> plugin_placeholders_; 74 std::map<int, PluginPlaceholderHost*> plugin_placeholders_;
68 #endif 75 #endif
69 76
70 DISALLOW_COPY_AND_ASSIGN(PluginObserver); 77 DISALLOW_COPY_AND_ASSIGN(PluginObserver);
71 }; 78 };
72 79
73 #endif // CHROME_BROWSER_PLUGINS_PLUGIN_OBSERVER_H_ 80 #endif // CHROME_BROWSER_PLUGINS_PLUGIN_OBSERVER_H_
OLDNEW
« no previous file with comments | « chrome/browser/plugins/plugin_infobar_delegates.cc ('k') | chrome/browser/plugins/plugin_observer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698