Chromium Code Reviews| 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 #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 using content::WebContentsObserver::web_contents; |
|
Bernhard Bauer
2012/09/24 08:55:18
Nit: Could you add a comment to explain that we're
Avi (use Gerrit)
2012/09/24 15:27:51
I'm killing TabContents (see the referenced bug) s
| |
| 39 | 43 |
| 40 private: | 44 private: |
| 45 explicit PluginObserver(content::WebContents* web_contents); | |
|
Bernhard Bauer
2012/09/24 08:55:18
Nit: I think the constructor declaration should co
| |
| 46 static int kUserDataKey; | |
| 47 friend class WebContentsUserData<PluginObserver>; | |
| 48 | |
| 41 class PluginPlaceholderHost; | 49 class PluginPlaceholderHost; |
| 42 | 50 |
| 43 void OnBlockedUnauthorizedPlugin(const string16& name, | 51 void OnBlockedUnauthorizedPlugin(const string16& name, |
| 44 const std::string& identifier); | 52 const std::string& identifier); |
| 45 void OnBlockedOutdatedPlugin(int placeholder_id, | 53 void OnBlockedOutdatedPlugin(int placeholder_id, |
| 46 const std::string& identifier); | 54 const std::string& identifier); |
| 47 #if defined(ENABLE_PLUGIN_INSTALLATION) | 55 #if defined(ENABLE_PLUGIN_INSTALLATION) |
| 48 void OnFindMissingPlugin(int placeholder_id, const std::string& mime_type); | 56 void OnFindMissingPlugin(int placeholder_id, const std::string& mime_type); |
| 49 | 57 |
| 50 void FindMissingPlugin(int placeholder_id, | 58 void FindMissingPlugin(int placeholder_id, |
| 51 const std::string& mime_type, | 59 const std::string& mime_type, |
| 52 PluginFinder* plugin_finder); | 60 PluginFinder* plugin_finder); |
| 53 void FindPluginToUpdate(int placeholder_id, | 61 void FindPluginToUpdate(int placeholder_id, |
| 54 const std::string& identifier, | 62 const std::string& identifier, |
| 55 PluginFinder* plugin_finder); | 63 PluginFinder* plugin_finder); |
| 56 void OnRemovePluginPlaceholderHost(int placeholder_id); | 64 void OnRemovePluginPlaceholderHost(int placeholder_id); |
| 57 #endif | 65 #endif |
| 58 void OnOpenAboutPlugins(); | 66 void OnOpenAboutPlugins(); |
| 59 void OnCouldNotLoadPlugin(const FilePath& plugin_path); | 67 void OnCouldNotLoadPlugin(const FilePath& plugin_path); |
| 60 | 68 |
| 61 base::WeakPtrFactory<PluginObserver> weak_ptr_factory_; | 69 base::WeakPtrFactory<PluginObserver> weak_ptr_factory_; |
| 62 | 70 |
| 63 TabContents* tab_contents_; | |
| 64 | |
| 65 #if defined(ENABLE_PLUGIN_INSTALLATION) | 71 #if defined(ENABLE_PLUGIN_INSTALLATION) |
| 66 // Stores all PluginPlaceholderHosts, keyed by their routing ID. | 72 // Stores all PluginPlaceholderHosts, keyed by their routing ID. |
| 67 std::map<int, PluginPlaceholderHost*> plugin_placeholders_; | 73 std::map<int, PluginPlaceholderHost*> plugin_placeholders_; |
| 68 #endif | 74 #endif |
| 69 | 75 |
| 70 DISALLOW_COPY_AND_ASSIGN(PluginObserver); | 76 DISALLOW_COPY_AND_ASSIGN(PluginObserver); |
| 71 }; | 77 }; |
| 72 | 78 |
| 73 #endif // CHROME_BROWSER_PLUGINS_PLUGIN_OBSERVER_H_ | 79 #endif // CHROME_BROWSER_PLUGINS_PLUGIN_OBSERVER_H_ |
| OLD | NEW |