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
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_PLUGINS_PLUGIN_OBSERVER_H_
6 #define CHROME_BROWSER_PLUGINS_PLUGIN_OBSERVER_H_
8 #include "base/memory/scoped_ptr.h"
9 #include "base/memory/weak_ptr.h"
10 #include "content/public/browser/web_contents_observer.h"
11 #include "content/public/browser/web_contents_user_data.h"
13 #if defined(ENABLE_PLUGIN_INSTALLATION)
18 class InfoBarDelegate
;
22 #if defined(ENABLE_PLUGIN_INSTALLATION)
23 class PluginInstaller
;
24 class PluginPlaceholderHost
;
31 class PluginObserver
: public content::WebContentsObserver
,
32 public content::WebContentsUserData
<PluginObserver
> {
34 virtual ~PluginObserver();
36 // content::WebContentsObserver implementation.
37 virtual void PluginCrashed(const base::FilePath
& plugin_path
,
38 base::ProcessId plugin_pid
) OVERRIDE
;
39 virtual bool OnMessageReceived(const IPC::Message
& message
) OVERRIDE
;
42 explicit PluginObserver(content::WebContents
* web_contents
);
43 friend class content::WebContentsUserData
<PluginObserver
>;
45 class PluginPlaceholderHost
;
47 #if defined(ENABLE_PLUGIN_INSTALLATION)
48 void InstallMissingPlugin(PluginInstaller
* installer
,
49 const PluginMetadata
* plugin_metadata
);
53 void OnBlockedUnauthorizedPlugin(const string16
& name
,
54 const std::string
& identifier
);
55 void OnBlockedOutdatedPlugin(int placeholder_id
,
56 const std::string
& identifier
);
57 #if defined(ENABLE_PLUGIN_INSTALLATION)
58 void OnFindMissingPlugin(int placeholder_id
, const std::string
& mime_type
);
60 void OnRemovePluginPlaceholderHost(int placeholder_id
);
62 void OnOpenAboutPlugins();
63 void OnCouldNotLoadPlugin(const base::FilePath
& plugin_path
);
64 void OnNPAPINotSupported(const std::string
& identifier
);
66 base::WeakPtrFactory
<PluginObserver
> weak_ptr_factory_
;
68 #if defined(ENABLE_PLUGIN_INSTALLATION)
69 // Stores all PluginPlaceholderHosts, keyed by their routing ID.
70 std::map
<int, PluginPlaceholderHost
*> plugin_placeholders_
;
73 DISALLOW_COPY_AND_ASSIGN(PluginObserver
);
76 #endif // CHROME_BROWSER_PLUGINS_PLUGIN_OBSERVER_H_