Fix build break
[chromium-blink-merge.git] / chrome / browser / plugins / plugin_infobar_delegates.h
blob5e298e18b3bc3abb19c76e3aea0aa36eef720c8d
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_INFOBAR_DELEGATES_H_
6 #define CHROME_BROWSER_PLUGINS_PLUGIN_INFOBAR_DELEGATES_H_
8 #include "base/callback.h"
9 #include "chrome/browser/infobars/confirm_infobar_delegate.h"
10 #include "googleurl/src/gurl.h"
12 #if defined(ENABLE_PLUGIN_INSTALLATION)
13 #include "chrome/browser/plugins/plugin_installer_observer.h"
14 #endif // defined(ENABLE_PLUGIN_INSTALLATION)
16 class InfoBarService;
17 class HostContentSettingsMap;
18 class PluginMetadata;
20 namespace content {
21 class WebContents;
24 // Base class for blocked plug-in infobars.
25 class PluginInfoBarDelegate : public ConfirmInfoBarDelegate {
26 public:
27 PluginInfoBarDelegate(InfoBarService* infobar_service,
28 const string16& name,
29 const std::string& identifier);
31 protected:
32 virtual ~PluginInfoBarDelegate();
34 // ConfirmInfoBarDelegate:
35 virtual bool LinkClicked(WindowOpenDisposition disposition) OVERRIDE;
37 virtual std::string GetLearnMoreURL() const = 0;
39 void LoadBlockedPlugins();
41 string16 name_;
43 private:
44 // ConfirmInfoBarDelegate:
45 virtual gfx::Image* GetIcon() const OVERRIDE;
46 virtual string16 GetLinkText() const OVERRIDE;
48 std::string identifier_;
50 DISALLOW_COPY_AND_ASSIGN(PluginInfoBarDelegate);
53 // Infobar that's shown when a plug-in requires user authorization to run.
54 class UnauthorizedPluginInfoBarDelegate : public PluginInfoBarDelegate {
55 public:
56 // Creates an unauthorized plugin delegate and adds it to |infobar_service|.
57 static void Create(InfoBarService* infobar_service,
58 HostContentSettingsMap* content_settings,
59 const string16& name,
60 const std::string& identifier);
62 private:
63 UnauthorizedPluginInfoBarDelegate(InfoBarService* infobar_service,
64 HostContentSettingsMap* content_settings,
65 const string16& name,
66 const std::string& identifier);
67 virtual ~UnauthorizedPluginInfoBarDelegate();
69 // PluginInfoBarDelegate:
70 virtual string16 GetMessageText() const OVERRIDE;
71 virtual string16 GetButtonLabel(InfoBarButton button) const OVERRIDE;
72 virtual bool Accept() OVERRIDE;
73 virtual bool Cancel() OVERRIDE;
74 virtual void InfoBarDismissed() OVERRIDE;
75 virtual bool LinkClicked(WindowOpenDisposition disposition) OVERRIDE;
76 virtual std::string GetLearnMoreURL() const OVERRIDE;
78 HostContentSettingsMap* content_settings_;
80 DISALLOW_COPY_AND_ASSIGN(UnauthorizedPluginInfoBarDelegate);
83 #if defined(ENABLE_PLUGIN_INSTALLATION)
84 // Infobar that's shown when a plug-in is out of date.
85 class OutdatedPluginInfoBarDelegate : public PluginInfoBarDelegate,
86 public WeakPluginInstallerObserver {
87 public:
88 // Creates an outdated plugin delegate and adds it to |infobar_service|.
89 static void Create(InfoBarService* infobar_service,
90 PluginInstaller* installer,
91 scoped_ptr<PluginMetadata> metadata);
93 private:
94 OutdatedPluginInfoBarDelegate(InfoBarService* infobar_service,
95 PluginInstaller* installer,
96 scoped_ptr<PluginMetadata> metadata,
97 const string16& message);
98 virtual ~OutdatedPluginInfoBarDelegate();
100 // PluginInfoBarDelegate:
101 virtual string16 GetMessageText() const OVERRIDE;
102 virtual string16 GetButtonLabel(InfoBarButton button) const OVERRIDE;
103 virtual bool Accept() OVERRIDE;
104 virtual bool Cancel() OVERRIDE;
105 virtual void InfoBarDismissed() OVERRIDE;
106 virtual bool LinkClicked(WindowOpenDisposition disposition) OVERRIDE;
107 virtual std::string GetLearnMoreURL() const OVERRIDE;
109 // PluginInstallerObserver:
110 virtual void DownloadStarted() OVERRIDE;
111 virtual void DownloadError(const std::string& message) OVERRIDE;
112 virtual void DownloadCancelled() OVERRIDE;
113 virtual void DownloadFinished() OVERRIDE;
115 // WeakPluginInstallerObserver:
116 virtual void OnlyWeakObserversLeft() OVERRIDE;
118 // Replaces this infobar with one showing |message|. The new infobar will
119 // not have any buttons (and not call the callback).
120 void ReplaceWithInfoBar(const string16& message);
122 scoped_ptr<PluginMetadata> plugin_metadata_;
124 string16 message_;
126 DISALLOW_COPY_AND_ASSIGN(OutdatedPluginInfoBarDelegate);
129 // The main purpose for this class is to popup/close the infobar when there is
130 // a missing plugin.
131 class PluginInstallerInfoBarDelegate : public ConfirmInfoBarDelegate,
132 public WeakPluginInstallerObserver {
133 public:
134 typedef base::Callback<void(const PluginMetadata*)> InstallCallback;
136 // Shows an infobar asking whether to install the plugin represented by
137 // |installer|. When the user accepts, |callback| is called.
138 // During installation of the plug-in, the infobar will change to reflect the
139 // installation state.
140 static void Create(InfoBarService* infobar_service,
141 PluginInstaller* installer,
142 scoped_ptr<PluginMetadata> plugin_metadata,
143 const InstallCallback& callback);
145 // Replaces |infobar|, which must currently be owned, with an infobar asking
146 // the user to install or update a particular plugin.
147 static void Replace(InfoBarDelegate* infobar,
148 PluginInstaller* installer,
149 scoped_ptr<PluginMetadata> metadata,
150 bool new_install,
151 const string16& message);
153 private:
154 PluginInstallerInfoBarDelegate(InfoBarService* infobar_service,
155 PluginInstaller* installer,
156 scoped_ptr<PluginMetadata> plugin_metadata,
157 const InstallCallback& callback,
158 bool new_install,
159 const string16& message);
160 virtual ~PluginInstallerInfoBarDelegate();
162 // ConfirmInfoBarDelegate:
163 virtual gfx::Image* GetIcon() const OVERRIDE;
164 virtual string16 GetMessageText() const OVERRIDE;
165 virtual int GetButtons() const OVERRIDE;
166 virtual string16 GetButtonLabel(InfoBarButton button) const OVERRIDE;
167 virtual bool Accept() OVERRIDE;
168 virtual string16 GetLinkText() const OVERRIDE;
169 virtual bool LinkClicked(WindowOpenDisposition disposition) OVERRIDE;
171 // PluginInstallerObserver:
172 virtual void DownloadStarted() OVERRIDE;
173 virtual void DownloadError(const std::string& message) OVERRIDE;
174 virtual void DownloadCancelled() OVERRIDE;
175 virtual void DownloadFinished() OVERRIDE;
177 // WeakPluginInstallerObserver:
178 virtual void OnlyWeakObserversLeft() OVERRIDE;
180 // Replaces this infobar with one showing |message|. The new infobar will
181 // not have any buttons (and not call the callback).
182 void ReplaceWithInfoBar(const string16& message);
184 scoped_ptr<PluginMetadata> plugin_metadata_;
186 InstallCallback callback_;
188 // True iff the plug-in isn't installed yet.
189 bool new_install_;
191 string16 message_;
193 DISALLOW_COPY_AND_ASSIGN(PluginInstallerInfoBarDelegate);
195 #endif // defined(ENABLE_PLUGIN_INSTALLATION)
197 #if defined(OS_WIN)
198 class PluginMetroModeInfoBarDelegate : public ConfirmInfoBarDelegate {
199 public:
200 // The infobar can be used for two purposes: to inform the user about a
201 // missing plugin or to note that a plugin only works in desktop mode. These
202 // purposes require different messages, buttons, etc.
203 enum Mode {
204 MISSING_PLUGIN,
205 DESKTOP_MODE_REQUIRED,
208 // Creates a metro mode infobar and delegate and adds the infobar to
209 // |infobar_service|.
210 static void Create(InfoBarService* infobar_service,
211 Mode mode,
212 const string16& name);
214 private:
215 PluginMetroModeInfoBarDelegate(InfoBarService* infobar_service,
216 Mode mode,
217 const string16& name);
218 virtual ~PluginMetroModeInfoBarDelegate();
220 // ConfirmInfoBarDelegate:
221 virtual gfx::Image* GetIcon() const OVERRIDE;
222 virtual string16 GetMessageText() const OVERRIDE;
223 virtual int GetButtons() const OVERRIDE;
224 virtual string16 GetButtonLabel(InfoBarButton button) const OVERRIDE;
225 virtual bool Accept() OVERRIDE;
226 virtual bool Cancel() OVERRIDE;
227 virtual string16 GetLinkText() const OVERRIDE;
228 virtual bool LinkClicked(WindowOpenDisposition disposition) OVERRIDE;
230 const Mode mode_;
231 const string16 name_;
233 DISALLOW_COPY_AND_ASSIGN(PluginMetroModeInfoBarDelegate);
235 #endif // defined(OS_WIN)
237 #endif // CHROME_BROWSER_PLUGINS_PLUGIN_INFOBAR_DELEGATES_H_