Add more checks to investigate SupervisedUserPrefStore crash at startup.
[chromium-blink-merge.git] / chrome / browser / plugins / plugin_infobar_delegates.h
blobd817c2c6f42adbba541748728b733f74ba251b6a
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 "components/infobars/core/confirm_infobar_delegate.h"
10 #include "url/gurl.h"
12 #if defined(ENABLE_PLUGIN_INSTALLATION)
13 #include "chrome/browser/plugins/plugin_installer_observer.h"
14 #endif
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 protected:
27 explicit PluginInfoBarDelegate(const std::string& identifier);
28 ~PluginInfoBarDelegate() override;
30 // ConfirmInfoBarDelegate:
31 bool LinkClicked(WindowOpenDisposition disposition) override;
33 virtual std::string GetLearnMoreURL() const = 0;
35 void LoadBlockedPlugins();
37 private:
38 // ConfirmInfoBarDelegate:
39 int GetIconID() const override;
40 base::string16 GetLinkText() const override;
42 std::string identifier_;
44 DISALLOW_COPY_AND_ASSIGN(PluginInfoBarDelegate);
47 #if defined(ENABLE_PLUGIN_INSTALLATION)
48 // Infobar that's shown when a plug-in is out of date.
49 class OutdatedPluginInfoBarDelegate : public PluginInfoBarDelegate,
50 public WeakPluginInstallerObserver {
51 public:
52 // Creates an outdated plugin infobar and delegate and adds the infobar to
53 // |infobar_service|.
54 static void Create(InfoBarService* infobar_service,
55 PluginInstaller* installer,
56 scoped_ptr<PluginMetadata> metadata);
58 private:
59 OutdatedPluginInfoBarDelegate(PluginInstaller* installer,
60 scoped_ptr<PluginMetadata> metadata,
61 const base::string16& message);
62 ~OutdatedPluginInfoBarDelegate() override;
64 // PluginInfoBarDelegate:
65 base::string16 GetMessageText() const override;
66 base::string16 GetButtonLabel(InfoBarButton button) const override;
67 bool Accept() override;
68 bool Cancel() override;
69 void InfoBarDismissed() override;
70 bool LinkClicked(WindowOpenDisposition disposition) override;
71 std::string GetLearnMoreURL() const override;
73 // PluginInstallerObserver:
74 void DownloadStarted() override;
75 void DownloadError(const std::string& message) override;
76 void DownloadCancelled() override;
77 void DownloadFinished() override;
79 // WeakPluginInstallerObserver:
80 void OnlyWeakObserversLeft() override;
82 // Replaces this infobar with one showing |message|. The new infobar will
83 // not have any buttons (and not call the callback).
84 void ReplaceWithInfoBar(const base::string16& message);
86 scoped_ptr<PluginMetadata> plugin_metadata_;
88 base::string16 message_;
90 DISALLOW_COPY_AND_ASSIGN(OutdatedPluginInfoBarDelegate);
93 // The main purpose for this class is to popup/close the infobar when there is
94 // a missing plugin.
95 class PluginInstallerInfoBarDelegate : public ConfirmInfoBarDelegate,
96 public WeakPluginInstallerObserver {
97 public:
98 typedef base::Callback<void(const PluginMetadata*)> InstallCallback;
100 // Shows an infobar asking whether to install the plugin represented by
101 // |installer|. When the user accepts, |callback| is called.
102 // During installation of the plug-in, the infobar will change to reflect the
103 // installation state.
104 static void Create(InfoBarService* infobar_service,
105 PluginInstaller* installer,
106 scoped_ptr<PluginMetadata> plugin_metadata,
107 const InstallCallback& callback);
109 // Replaces |infobar|, which must currently be owned, with an infobar asking
110 // the user to install or update a particular plugin.
111 static void Replace(infobars::InfoBar* infobar,
112 PluginInstaller* installer,
113 scoped_ptr<PluginMetadata> plugin_metadata,
114 bool new_install,
115 const base::string16& message);
117 private:
118 PluginInstallerInfoBarDelegate(PluginInstaller* installer,
119 scoped_ptr<PluginMetadata> metadata,
120 const InstallCallback& callback,
121 bool new_install,
122 const base::string16& message);
123 ~PluginInstallerInfoBarDelegate() override;
125 // ConfirmInfoBarDelegate:
126 int GetIconID() const override;
127 base::string16 GetMessageText() const override;
128 int GetButtons() const override;
129 base::string16 GetButtonLabel(InfoBarButton button) const override;
130 bool Accept() override;
131 base::string16 GetLinkText() const override;
132 bool LinkClicked(WindowOpenDisposition disposition) override;
134 // PluginInstallerObserver:
135 void DownloadStarted() override;
136 void DownloadError(const std::string& message) override;
137 void DownloadCancelled() override;
138 void DownloadFinished() override;
140 // WeakPluginInstallerObserver:
141 void OnlyWeakObserversLeft() override;
143 // Replaces this infobar with one showing |message|. The new infobar will
144 // not have any buttons (and not call the callback).
145 void ReplaceWithInfoBar(const base::string16& message);
147 scoped_ptr<PluginMetadata> plugin_metadata_;
149 InstallCallback callback_;
151 // True iff the plug-in isn't installed yet.
152 bool new_install_;
154 base::string16 message_;
156 DISALLOW_COPY_AND_ASSIGN(PluginInstallerInfoBarDelegate);
158 #endif // defined(ENABLE_PLUGIN_INSTALLATION)
160 #if defined(OS_WIN)
161 class PluginMetroModeInfoBarDelegate : public ConfirmInfoBarDelegate {
162 public:
163 // The infobar can be used for two purposes: to inform the user about a
164 // missing plugin or to note that a plugin only works in desktop mode. These
165 // purposes require different messages, buttons, etc.
166 enum Mode {
167 MISSING_PLUGIN,
168 DESKTOP_MODE_REQUIRED,
171 // Creates a metro mode infobar and delegate and adds the infobar to
172 // |infobar_service|.
173 static void Create(InfoBarService* infobar_service,
174 Mode mode,
175 const base::string16& name);
177 private:
178 PluginMetroModeInfoBarDelegate(Mode mode, const base::string16& name);
179 virtual ~PluginMetroModeInfoBarDelegate();
181 // ConfirmInfoBarDelegate:
182 virtual int GetIconID() const override;
183 virtual base::string16 GetMessageText() const override;
184 virtual int GetButtons() const override;
185 virtual base::string16 GetButtonLabel(InfoBarButton button) const override;
186 virtual bool Accept() override;
187 virtual base::string16 GetLinkText() const override;
188 virtual bool LinkClicked(WindowOpenDisposition disposition) override;
190 const Mode mode_;
191 const base::string16 name_;
193 DISALLOW_COPY_AND_ASSIGN(PluginMetroModeInfoBarDelegate);
195 #endif // defined(OS_WIN)
197 #endif // CHROME_BROWSER_PLUGINS_PLUGIN_INFOBAR_DELEGATES_H_