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)
21 #if defined(ENABLE_PLUGIN_INSTALLATION)
22 class PluginInstaller
;
23 class PluginPlaceholderHost
;
31 class InfoBarDelegate
;
34 class PluginObserver
: public content::WebContentsObserver
,
35 public content::WebContentsUserData
<PluginObserver
> {
37 virtual ~PluginObserver();
39 // content::WebContentsObserver implementation.
40 virtual void RenderFrameCreated(
41 content::RenderFrameHost
* render_frame_host
) OVERRIDE
;
42 virtual void PluginCrashed(const base::FilePath
& plugin_path
,
43 base::ProcessId plugin_pid
) OVERRIDE
;
44 virtual bool OnMessageReceived(
45 const IPC::Message
& message
,
46 content::RenderFrameHost
* render_frame_host
) OVERRIDE
;
47 virtual bool OnMessageReceived(const IPC::Message
& message
) OVERRIDE
;
50 explicit PluginObserver(content::WebContents
* web_contents
);
51 friend class content::WebContentsUserData
<PluginObserver
>;
53 class PluginPlaceholderHost
;
55 #if defined(ENABLE_PLUGIN_INSTALLATION)
56 void InstallMissingPlugin(PluginInstaller
* installer
,
57 const PluginMetadata
* plugin_metadata
);
61 void OnBlockedUnauthorizedPlugin(const base::string16
& name
,
62 const std::string
& identifier
);
63 void OnBlockedOutdatedPlugin(int placeholder_id
,
64 const std::string
& identifier
);
65 #if defined(ENABLE_PLUGIN_INSTALLATION)
66 void OnFindMissingPlugin(int placeholder_id
, const std::string
& mime_type
);
68 void OnRemovePluginPlaceholderHost(int placeholder_id
);
70 void OnOpenAboutPlugins();
71 void OnCouldNotLoadPlugin(const base::FilePath
& plugin_path
);
72 void OnNPAPINotSupported(const std::string
& identifier
);
74 #if defined(ENABLE_PLUGIN_INSTALLATION)
75 // Stores all PluginPlaceholderHosts, keyed by their routing ID.
76 std::map
<int, PluginPlaceholderHost
*> plugin_placeholders_
;
79 base::WeakPtrFactory
<PluginObserver
> weak_ptr_factory_
;
81 DISALLOW_COPY_AND_ASSIGN(PluginObserver
);
84 #endif // CHROME_BROWSER_PLUGINS_PLUGIN_OBSERVER_H_