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