Upstream version 7.36.149.0
[platform/framework/web/crosswalk.git] / src / chrome / browser / plugins / plugin_observer.h
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.
4
5 #ifndef CHROME_BROWSER_PLUGINS_PLUGIN_OBSERVER_H_
6 #define CHROME_BROWSER_PLUGINS_PLUGIN_OBSERVER_H_
7
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"
12
13 #if defined(ENABLE_PLUGIN_INSTALLATION)
14 #include <map>
15 #endif
16
17 class GURL;
18 class PluginFinder;
19 class PluginMetadata;
20
21 #if defined(ENABLE_PLUGIN_INSTALLATION)
22 class PluginInstaller;
23 class PluginPlaceholderHost;
24 #endif
25
26 namespace content {
27 class WebContents;
28 }
29
30 namespace infobars {
31 class InfoBarDelegate;
32 }
33
34 class PluginObserver : public content::WebContentsObserver,
35                        public content::WebContentsUserData<PluginObserver> {
36  public:
37   virtual ~PluginObserver();
38
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(const IPC::Message& message) OVERRIDE;
45
46  private:
47   explicit PluginObserver(content::WebContents* web_contents);
48   friend class content::WebContentsUserData<PluginObserver>;
49
50   class PluginPlaceholderHost;
51
52 #if defined(ENABLE_PLUGIN_INSTALLATION)
53   void InstallMissingPlugin(PluginInstaller* installer,
54                             const PluginMetadata* plugin_metadata);
55 #endif
56
57   // Message handlers:
58   void OnBlockedUnauthorizedPlugin(const base::string16& name,
59                                    const std::string& identifier);
60   void OnBlockedOutdatedPlugin(int placeholder_id,
61                                const std::string& identifier);
62 #if defined(ENABLE_PLUGIN_INSTALLATION)
63   void OnFindMissingPlugin(int placeholder_id, const std::string& mime_type);
64
65   void OnRemovePluginPlaceholderHost(int placeholder_id);
66 #endif
67   void OnOpenAboutPlugins();
68   void OnCouldNotLoadPlugin(const base::FilePath& plugin_path);
69   void OnNPAPINotSupported(const std::string& identifier);
70
71 #if defined(ENABLE_PLUGIN_INSTALLATION)
72   // Stores all PluginPlaceholderHosts, keyed by their routing ID.
73   std::map<int, PluginPlaceholderHost*> plugin_placeholders_;
74 #endif
75
76   base::WeakPtrFactory<PluginObserver> weak_ptr_factory_;
77
78   DISALLOW_COPY_AND_ASSIGN(PluginObserver);
79 };
80
81 #endif  // CHROME_BROWSER_PLUGINS_PLUGIN_OBSERVER_H_