OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CHROME_BROWSER_PLUGINS_PLUGIN_INFOBAR_DELEGATES_H_ | 5 #ifndef CHROME_BROWSER_PLUGINS_PLUGIN_INFOBAR_DELEGATES_H_ |
6 #define CHROME_BROWSER_PLUGINS_PLUGIN_INFOBAR_DELEGATES_H_ | 6 #define CHROME_BROWSER_PLUGINS_PLUGIN_INFOBAR_DELEGATES_H_ |
7 | 7 |
8 #include "base/callback.h" | 8 #include "base/callback.h" |
9 #include "chrome/browser/infobars/confirm_infobar_delegate.h" | 9 #include "chrome/browser/infobars/confirm_infobar_delegate.h" |
10 #include "url/gurl.h" | 10 #include "url/gurl.h" |
11 | 11 |
12 #if defined(ENABLE_PLUGIN_INSTALLATION) | 12 #if defined(ENABLE_PLUGIN_INSTALLATION) |
13 #include "chrome/browser/plugins/plugin_installer_observer.h" | 13 #include "chrome/browser/plugins/plugin_installer_observer.h" |
14 #endif | 14 #endif |
15 | 15 |
16 class InfoBarService; | 16 class InfoBarService; |
17 class HostContentSettingsMap; | 17 class HostContentSettingsMap; |
18 class PluginMetadata; | 18 class PluginMetadata; |
19 | 19 |
20 namespace content { | 20 namespace content { |
21 class WebContents; | 21 class WebContents; |
22 } | 22 } |
23 | 23 |
24 // Base class for blocked plug-in infobars. | 24 // Base class for blocked plug-in infobars. |
25 class PluginInfoBarDelegate : public ConfirmInfoBarDelegate { | 25 class PluginInfoBarDelegate : public ConfirmInfoBarDelegate { |
26 protected: | 26 protected: |
27 explicit PluginInfoBarDelegate(const std::string& identifier); | 27 PluginInfoBarDelegate(InfoBarService* infobar_service, |
| 28 const std::string& identifier); |
28 virtual ~PluginInfoBarDelegate(); | 29 virtual ~PluginInfoBarDelegate(); |
29 | 30 |
30 // ConfirmInfoBarDelegate: | 31 // ConfirmInfoBarDelegate: |
31 virtual bool LinkClicked(WindowOpenDisposition disposition) OVERRIDE; | 32 virtual bool LinkClicked(WindowOpenDisposition disposition) OVERRIDE; |
32 | 33 |
33 virtual std::string GetLearnMoreURL() const = 0; | 34 virtual std::string GetLearnMoreURL() const = 0; |
34 | 35 |
35 void LoadBlockedPlugins(); | 36 void LoadBlockedPlugins(); |
36 | 37 |
37 private: | 38 private: |
38 // ConfirmInfoBarDelegate: | 39 // ConfirmInfoBarDelegate: |
39 virtual int GetIconID() const OVERRIDE; | 40 virtual int GetIconID() const OVERRIDE; |
40 virtual string16 GetLinkText() const OVERRIDE; | 41 virtual string16 GetLinkText() const OVERRIDE; |
41 | 42 |
42 std::string identifier_; | 43 std::string identifier_; |
43 | 44 |
44 DISALLOW_COPY_AND_ASSIGN(PluginInfoBarDelegate); | 45 DISALLOW_COPY_AND_ASSIGN(PluginInfoBarDelegate); |
45 }; | 46 }; |
46 | 47 |
47 // Infobar that's shown when a plug-in requires user authorization to run. | 48 // Infobar that's shown when a plug-in requires user authorization to run. |
48 class UnauthorizedPluginInfoBarDelegate : public PluginInfoBarDelegate { | 49 class UnauthorizedPluginInfoBarDelegate : public PluginInfoBarDelegate { |
49 public: | 50 public: |
50 // Creates an unauthorized plugin infobar and delegate and adds the infobar to | 51 // Creates an unauthorized plugin infobar delegate and adds it to |
51 // |infobar_service|. | 52 // |infobar_service|. |
52 static void Create(InfoBarService* infobar_service, | 53 static void Create(InfoBarService* infobar_service, |
53 HostContentSettingsMap* content_settings, | 54 HostContentSettingsMap* content_settings, |
54 const string16& name, | 55 const string16& name, |
55 const std::string& identifier); | 56 const std::string& identifier); |
56 | 57 |
57 private: | 58 private: |
58 UnauthorizedPluginInfoBarDelegate(HostContentSettingsMap* content_settings, | 59 UnauthorizedPluginInfoBarDelegate(InfoBarService* infobar_service, |
| 60 HostContentSettingsMap* content_settings, |
59 const string16& name, | 61 const string16& name, |
60 const std::string& identifier); | 62 const std::string& identifier); |
61 virtual ~UnauthorizedPluginInfoBarDelegate(); | 63 virtual ~UnauthorizedPluginInfoBarDelegate(); |
62 | 64 |
63 // PluginInfoBarDelegate: | 65 // PluginInfoBarDelegate: |
64 virtual string16 GetMessageText() const OVERRIDE; | 66 virtual string16 GetMessageText() const OVERRIDE; |
65 virtual string16 GetButtonLabel(InfoBarButton button) const OVERRIDE; | 67 virtual string16 GetButtonLabel(InfoBarButton button) const OVERRIDE; |
66 virtual bool Accept() OVERRIDE; | 68 virtual bool Accept() OVERRIDE; |
67 virtual bool Cancel() OVERRIDE; | 69 virtual bool Cancel() OVERRIDE; |
68 virtual void InfoBarDismissed() OVERRIDE; | 70 virtual void InfoBarDismissed() OVERRIDE; |
69 virtual bool LinkClicked(WindowOpenDisposition disposition) OVERRIDE; | 71 virtual bool LinkClicked(WindowOpenDisposition disposition) OVERRIDE; |
70 virtual std::string GetLearnMoreURL() const OVERRIDE; | 72 virtual std::string GetLearnMoreURL() const OVERRIDE; |
71 | 73 |
72 HostContentSettingsMap* content_settings_; | 74 HostContentSettingsMap* content_settings_; |
73 string16 name_; | 75 string16 name_; |
74 | 76 |
75 DISALLOW_COPY_AND_ASSIGN(UnauthorizedPluginInfoBarDelegate); | 77 DISALLOW_COPY_AND_ASSIGN(UnauthorizedPluginInfoBarDelegate); |
76 }; | 78 }; |
77 | 79 |
78 #if defined(ENABLE_PLUGIN_INSTALLATION) | 80 #if defined(ENABLE_PLUGIN_INSTALLATION) |
79 // Infobar that's shown when a plug-in is out of date. | 81 // Infobar that's shown when a plug-in is out of date. |
80 class OutdatedPluginInfoBarDelegate : public PluginInfoBarDelegate, | 82 class OutdatedPluginInfoBarDelegate : public PluginInfoBarDelegate, |
81 public WeakPluginInstallerObserver { | 83 public WeakPluginInstallerObserver { |
82 public: | 84 public: |
83 // Creates an outdated plugin infobar and delegate and adds the infobar to | 85 // Creates an outdated plugin infobar delegate and adds it to |
84 // |infobar_service|. | 86 // |infobar_service|. |
85 static void Create(InfoBarService* infobar_service, | 87 static void Create(InfoBarService* infobar_service, |
86 PluginInstaller* installer, | 88 PluginInstaller* installer, |
87 scoped_ptr<PluginMetadata> metadata); | 89 scoped_ptr<PluginMetadata> metadata); |
88 | 90 |
89 private: | 91 private: |
90 OutdatedPluginInfoBarDelegate(PluginInstaller* installer, | 92 OutdatedPluginInfoBarDelegate(InfoBarService* infobar_service, |
| 93 PluginInstaller* installer, |
91 scoped_ptr<PluginMetadata> metadata, | 94 scoped_ptr<PluginMetadata> metadata, |
92 const string16& message); | 95 const string16& message); |
93 virtual ~OutdatedPluginInfoBarDelegate(); | 96 virtual ~OutdatedPluginInfoBarDelegate(); |
94 | 97 |
95 // PluginInfoBarDelegate: | 98 // PluginInfoBarDelegate: |
96 virtual string16 GetMessageText() const OVERRIDE; | 99 virtual string16 GetMessageText() const OVERRIDE; |
97 virtual string16 GetButtonLabel(InfoBarButton button) const OVERRIDE; | 100 virtual string16 GetButtonLabel(InfoBarButton button) const OVERRIDE; |
98 virtual bool Accept() OVERRIDE; | 101 virtual bool Accept() OVERRIDE; |
99 virtual bool Cancel() OVERRIDE; | 102 virtual bool Cancel() OVERRIDE; |
100 virtual void InfoBarDismissed() OVERRIDE; | 103 virtual void InfoBarDismissed() OVERRIDE; |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
132 // |installer|. When the user accepts, |callback| is called. | 135 // |installer|. When the user accepts, |callback| is called. |
133 // During installation of the plug-in, the infobar will change to reflect the | 136 // During installation of the plug-in, the infobar will change to reflect the |
134 // installation state. | 137 // installation state. |
135 static void Create(InfoBarService* infobar_service, | 138 static void Create(InfoBarService* infobar_service, |
136 PluginInstaller* installer, | 139 PluginInstaller* installer, |
137 scoped_ptr<PluginMetadata> plugin_metadata, | 140 scoped_ptr<PluginMetadata> plugin_metadata, |
138 const InstallCallback& callback); | 141 const InstallCallback& callback); |
139 | 142 |
140 // Replaces |infobar|, which must currently be owned, with an infobar asking | 143 // Replaces |infobar|, which must currently be owned, with an infobar asking |
141 // the user to install or update a particular plugin. | 144 // the user to install or update a particular plugin. |
142 static void Replace(InfoBar* infobar, | 145 static void Replace(InfoBarDelegate* infobar, |
143 PluginInstaller* installer, | 146 PluginInstaller* installer, |
144 scoped_ptr<PluginMetadata> plugin_metadata, | 147 scoped_ptr<PluginMetadata> plugin_metadata, |
145 bool new_install, | 148 bool new_install, |
146 const string16& message); | 149 const string16& message); |
147 | 150 |
148 private: | 151 private: |
149 PluginInstallerInfoBarDelegate(PluginInstaller* installer, | 152 PluginInstallerInfoBarDelegate(InfoBarService* infobar_service, |
150 scoped_ptr<PluginMetadata> metadata, | 153 PluginInstaller* installer, |
| 154 scoped_ptr<PluginMetadata> plugin_metadata, |
151 const InstallCallback& callback, | 155 const InstallCallback& callback, |
152 bool new_install, | 156 bool new_install, |
153 const string16& message); | 157 const string16& message); |
154 virtual ~PluginInstallerInfoBarDelegate(); | 158 virtual ~PluginInstallerInfoBarDelegate(); |
155 | 159 |
156 // ConfirmInfoBarDelegate: | 160 // ConfirmInfoBarDelegate: |
157 virtual int GetIconID() const OVERRIDE; | 161 virtual int GetIconID() const OVERRIDE; |
158 virtual string16 GetMessageText() const OVERRIDE; | 162 virtual string16 GetMessageText() const OVERRIDE; |
159 virtual int GetButtons() const OVERRIDE; | 163 virtual int GetButtons() const OVERRIDE; |
160 virtual string16 GetButtonLabel(InfoBarButton button) const OVERRIDE; | 164 virtual string16 GetButtonLabel(InfoBarButton button) const OVERRIDE; |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
199 DESKTOP_MODE_REQUIRED, | 203 DESKTOP_MODE_REQUIRED, |
200 }; | 204 }; |
201 | 205 |
202 // Creates a metro mode infobar and delegate and adds the infobar to | 206 // Creates a metro mode infobar and delegate and adds the infobar to |
203 // |infobar_service|. | 207 // |infobar_service|. |
204 static void Create(InfoBarService* infobar_service, | 208 static void Create(InfoBarService* infobar_service, |
205 Mode mode, | 209 Mode mode, |
206 const string16& name); | 210 const string16& name); |
207 | 211 |
208 private: | 212 private: |
209 PluginMetroModeInfoBarDelegate(Mode mode, const string16& name); | 213 PluginMetroModeInfoBarDelegate(InfoBarService* infobar_service, |
| 214 Mode mode, |
| 215 const string16& name); |
210 virtual ~PluginMetroModeInfoBarDelegate(); | 216 virtual ~PluginMetroModeInfoBarDelegate(); |
211 | 217 |
212 // ConfirmInfoBarDelegate: | 218 // ConfirmInfoBarDelegate: |
213 virtual int GetIconID() const OVERRIDE; | 219 virtual int GetIconID() const OVERRIDE; |
214 virtual string16 GetMessageText() const OVERRIDE; | 220 virtual string16 GetMessageText() const OVERRIDE; |
215 virtual int GetButtons() const OVERRIDE; | 221 virtual int GetButtons() const OVERRIDE; |
216 virtual string16 GetButtonLabel(InfoBarButton button) const OVERRIDE; | 222 virtual string16 GetButtonLabel(InfoBarButton button) const OVERRIDE; |
217 virtual bool Accept() OVERRIDE; | 223 virtual bool Accept() OVERRIDE; |
218 virtual string16 GetLinkText() const OVERRIDE; | 224 virtual string16 GetLinkText() const OVERRIDE; |
219 virtual bool LinkClicked(WindowOpenDisposition disposition) OVERRIDE; | 225 virtual bool LinkClicked(WindowOpenDisposition disposition) OVERRIDE; |
220 | 226 |
221 const Mode mode_; | 227 const Mode mode_; |
222 const string16 name_; | 228 const string16 name_; |
223 | 229 |
224 DISALLOW_COPY_AND_ASSIGN(PluginMetroModeInfoBarDelegate); | 230 DISALLOW_COPY_AND_ASSIGN(PluginMetroModeInfoBarDelegate); |
225 }; | 231 }; |
226 #endif // defined(OS_WIN) | 232 #endif // defined(OS_WIN) |
227 | 233 |
228 #endif // CHROME_BROWSER_PLUGINS_PLUGIN_INFOBAR_DELEGATES_H_ | 234 #endif // CHROME_BROWSER_PLUGINS_PLUGIN_INFOBAR_DELEGATES_H_ |
OLD | NEW |