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"
12 #if defined(ENABLE_PLUGIN_INSTALLATION)
13 #include "chrome/browser/plugins/plugin_installer_observer.h"
17 class HostContentSettingsMap
;
24 // Base class for blocked plugin infobars.
25 class PluginInfoBarDelegate
: public ConfirmInfoBarDelegate
{
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();
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 plugin is out of date.
49 class OutdatedPluginInfoBarDelegate
: public PluginInfoBarDelegate
,
50 public WeakPluginInstallerObserver
{
52 // Creates an outdated plugin infobar and delegate and adds the infobar to
54 static void Create(InfoBarService
* infobar_service
,
55 PluginInstaller
* installer
,
56 scoped_ptr
<PluginMetadata
> metadata
);
58 // Replaces |infobar|, which must currently be owned, with an infobar asking
59 // the user to update a particular plugin.
60 static void Replace(infobars::InfoBar
* infobar
,
61 PluginInstaller
* installer
,
62 scoped_ptr
<PluginMetadata
> plugin_metadata
,
63 const base::string16
& message
);
66 OutdatedPluginInfoBarDelegate(PluginInstaller
* installer
,
67 scoped_ptr
<PluginMetadata
> metadata
,
68 const base::string16
& message
);
69 ~OutdatedPluginInfoBarDelegate() override
;
71 // PluginInfoBarDelegate:
72 void InfoBarDismissed() override
;
73 base::string16
GetMessageText() const override
;
74 base::string16
GetButtonLabel(InfoBarButton button
) const override
;
75 bool Accept() override
;
76 bool Cancel() override
;
77 bool LinkClicked(WindowOpenDisposition disposition
) override
;
78 std::string
GetLearnMoreURL() const override
;
80 // PluginInstallerObserver:
81 void DownloadStarted() override
;
82 void DownloadError(const std::string
& message
) override
;
83 void DownloadCancelled() override
;
84 void DownloadFinished() override
;
86 // WeakPluginInstallerObserver:
87 void OnlyWeakObserversLeft() override
;
89 // Replaces this infobar with one showing |message|. The new infobar will
90 // not have any buttons (and not call the callback).
91 void ReplaceWithInfoBar(const base::string16
& message
);
93 scoped_ptr
<PluginMetadata
> plugin_metadata_
;
95 base::string16 message_
;
97 DISALLOW_COPY_AND_ASSIGN(OutdatedPluginInfoBarDelegate
);
99 #endif // defined(ENABLE_PLUGIN_INSTALLATION)
102 class PluginMetroModeInfoBarDelegate
: public ConfirmInfoBarDelegate
{
104 // The infobar can be used for two purposes: to inform the user about a
105 // missing plugin or to note that a plugin only works in desktop mode. These
106 // purposes require different messages, buttons, etc.
109 DESKTOP_MODE_REQUIRED
,
112 // Creates a metro mode infobar and delegate and adds the infobar to
113 // |infobar_service|.
114 static void Create(InfoBarService
* infobar_service
,
116 const base::string16
& name
);
119 PluginMetroModeInfoBarDelegate(Mode mode
, const base::string16
& name
);
120 virtual ~PluginMetroModeInfoBarDelegate();
122 // ConfirmInfoBarDelegate:
123 virtual int GetIconID() const override
;
124 virtual base::string16
GetMessageText() const override
;
125 virtual int GetButtons() const override
;
126 virtual base::string16
GetButtonLabel(InfoBarButton button
) const override
;
127 virtual bool Accept() override
;
128 virtual base::string16
GetLinkText() const override
;
129 virtual bool LinkClicked(WindowOpenDisposition disposition
) override
;
132 const base::string16 name_
;
134 DISALLOW_COPY_AND_ASSIGN(PluginMetroModeInfoBarDelegate
);
136 #endif // defined(OS_WIN)
138 #endif // CHROME_BROWSER_PLUGINS_PLUGIN_INFOBAR_DELEGATES_H_