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_PLUGIN_INFOBAR_DELEGATES_H_ | 5 #ifndef CHROME_BROWSER_PLUGIN_INFOBAR_DELEGATES_H_ |
6 #define CHROME_BROWSER_PLUGIN_INFOBAR_DELEGATES_H_ | 6 #define CHROME_BROWSER_PLUGIN_INFOBAR_DELEGATES_H_ |
7 | 7 |
8 #include "base/callback.h" | 8 #include "base/callback.h" |
9 #include "chrome/browser/api/infobars/confirm_infobar_delegate.h" | 9 #include "chrome/browser/api/infobars/confirm_infobar_delegate.h" |
10 #include "googleurl/src/gurl.h" | 10 #include "googleurl/src/gurl.h" |
11 | 11 |
12 #if defined(ENABLE_PLUGIN_INSTALLATION) | 12 #if defined(ENABLE_PLUGIN_INSTALLATION) |
13 #include "chrome/browser/plugin_installer_observer.h" | 13 #include "chrome/browser/plugin_installer_observer.h" |
14 #endif // defined(ENABLE_PLUGIN_INSTALLATION) | 14 #endif // defined(ENABLE_PLUGIN_INSTALLATION) |
15 | 15 |
| 16 class InfoBarTabService; |
16 class HostContentSettingsMap; | 17 class HostContentSettingsMap; |
17 class PluginObserver; | 18 class PluginObserver; |
18 | 19 |
19 // Base class for blocked plug-in infobars. | 20 // Base class for blocked plug-in infobars. |
20 class PluginInfoBarDelegate : public ConfirmInfoBarDelegate { | 21 class PluginInfoBarDelegate : public ConfirmInfoBarDelegate { |
21 public: | 22 public: |
22 PluginInfoBarDelegate(InfoBarTabHelper* infobar_helper, | 23 PluginInfoBarDelegate(InfoBarTabService* infobar_service, |
23 const string16& name, | 24 const string16& name, |
24 const std::string& identifier); | 25 const std::string& identifier); |
25 | 26 |
26 protected: | 27 protected: |
27 virtual ~PluginInfoBarDelegate(); | 28 virtual ~PluginInfoBarDelegate(); |
28 | 29 |
29 // ConfirmInfoBarDelegate: | 30 // ConfirmInfoBarDelegate: |
30 virtual bool LinkClicked(WindowOpenDisposition disposition) OVERRIDE; | 31 virtual bool LinkClicked(WindowOpenDisposition disposition) OVERRIDE; |
31 | 32 |
32 virtual std::string GetLearnMoreURL() const = 0; | 33 virtual std::string GetLearnMoreURL() const = 0; |
33 | 34 |
34 void LoadBlockedPlugins(); | 35 void LoadBlockedPlugins(); |
35 | 36 |
36 string16 name_; | 37 string16 name_; |
37 | 38 |
38 private: | 39 private: |
39 // ConfirmInfoBarDelegate: | 40 // ConfirmInfoBarDelegate: |
40 virtual gfx::Image* GetIcon() const OVERRIDE; | 41 virtual gfx::Image* GetIcon() const OVERRIDE; |
41 virtual string16 GetLinkText() const OVERRIDE; | 42 virtual string16 GetLinkText() const OVERRIDE; |
42 | 43 |
43 std::string identifier_; | 44 std::string identifier_; |
44 | 45 |
45 DISALLOW_COPY_AND_ASSIGN(PluginInfoBarDelegate); | 46 DISALLOW_COPY_AND_ASSIGN(PluginInfoBarDelegate); |
46 }; | 47 }; |
47 | 48 |
48 // Infobar that's shown when a plug-in requires user authorization to run. | 49 // Infobar that's shown when a plug-in requires user authorization to run. |
49 class UnauthorizedPluginInfoBarDelegate : public PluginInfoBarDelegate { | 50 class UnauthorizedPluginInfoBarDelegate : public PluginInfoBarDelegate { |
50 public: | 51 public: |
51 UnauthorizedPluginInfoBarDelegate(InfoBarTabHelper* infobar_helper, | 52 UnauthorizedPluginInfoBarDelegate(InfoBarTabService* infobar_service, |
52 HostContentSettingsMap* content_settings, | 53 HostContentSettingsMap* content_settings, |
53 const string16& name, | 54 const string16& name, |
54 const std::string& identifier); | 55 const std::string& identifier); |
55 | 56 |
56 private: | 57 private: |
57 virtual ~UnauthorizedPluginInfoBarDelegate(); | 58 virtual ~UnauthorizedPluginInfoBarDelegate(); |
58 | 59 |
59 // PluginInfoBarDelegate: | 60 // PluginInfoBarDelegate: |
60 virtual string16 GetMessageText() const OVERRIDE; | 61 virtual string16 GetMessageText() const OVERRIDE; |
61 virtual string16 GetButtonLabel(InfoBarButton button) const OVERRIDE; | 62 virtual string16 GetButtonLabel(InfoBarButton button) const OVERRIDE; |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
100 virtual void DownloadFinished() OVERRIDE; | 101 virtual void DownloadFinished() OVERRIDE; |
101 | 102 |
102 // WeakPluginInstallerObserver: | 103 // WeakPluginInstallerObserver: |
103 virtual void OnlyWeakObserversLeft() OVERRIDE; | 104 virtual void OnlyWeakObserversLeft() OVERRIDE; |
104 | 105 |
105 // Replaces this infobar with one showing |message|. The new infobar will | 106 // Replaces this infobar with one showing |message|. The new infobar will |
106 // not have any buttons (and not call the callback). | 107 // not have any buttons (and not call the callback). |
107 void ReplaceWithInfoBar(const string16& message); | 108 void ReplaceWithInfoBar(const string16& message); |
108 | 109 |
109 // Has the same lifetime as TabContents, which owns us | 110 // Has the same lifetime as TabContents, which owns us |
110 // (transitively via InfoBarTabHelper). | 111 // (transitively via InfoBarTabService). |
111 PluginObserver* observer_; | 112 PluginObserver* observer_; |
112 | 113 |
113 string16 message_; | 114 string16 message_; |
114 | 115 |
115 DISALLOW_COPY_AND_ASSIGN(OutdatedPluginInfoBarDelegate); | 116 DISALLOW_COPY_AND_ASSIGN(OutdatedPluginInfoBarDelegate); |
116 }; | 117 }; |
117 | 118 |
118 // The main purpose for this class is to popup/close the infobar when there is | 119 // The main purpose for this class is to popup/close the infobar when there is |
119 // a missing plugin. | 120 // a missing plugin. |
120 class PluginInstallerInfoBarDelegate : public ConfirmInfoBarDelegate, | 121 class PluginInstallerInfoBarDelegate : public ConfirmInfoBarDelegate, |
121 public WeakPluginInstallerObserver { | 122 public WeakPluginInstallerObserver { |
122 public: | 123 public: |
123 // Shows an infobar asking whether to install the plugin represented by | 124 // Shows an infobar asking whether to install the plugin represented by |
124 // |installer|. When the user accepts, |callback| is called. | 125 // |installer|. When the user accepts, |callback| is called. |
125 // During installation of the plug-in, the infobar will change to reflect the | 126 // During installation of the plug-in, the infobar will change to reflect the |
126 // installation state. | 127 // installation state. |
127 static InfoBarDelegate* Create(InfoBarTabHelper* infobar_helper, | 128 static InfoBarDelegate* Create(InfoBarTabService* infobar_service, |
128 PluginInstaller* installer, | 129 PluginInstaller* installer, |
129 const base::Closure& callback); | 130 const base::Closure& callback); |
130 | 131 |
131 private: | 132 private: |
132 friend class OutdatedPluginInfoBarDelegate; | 133 friend class OutdatedPluginInfoBarDelegate; |
133 | 134 |
134 PluginInstallerInfoBarDelegate(InfoBarTabHelper* infobar_helper, | 135 PluginInstallerInfoBarDelegate(InfoBarTabService* infobar_service, |
135 PluginInstaller* installer, | 136 PluginInstaller* installer, |
136 const base::Closure& callback, | 137 const base::Closure& callback, |
137 bool new_install, | 138 bool new_install, |
138 const string16& message); | 139 const string16& message); |
139 virtual ~PluginInstallerInfoBarDelegate(); | 140 virtual ~PluginInstallerInfoBarDelegate(); |
140 | 141 |
141 // ConfirmInfoBarDelegate: | 142 // ConfirmInfoBarDelegate: |
142 virtual gfx::Image* GetIcon() const OVERRIDE; | 143 virtual gfx::Image* GetIcon() const OVERRIDE; |
143 virtual string16 GetMessageText() const OVERRIDE; | 144 virtual string16 GetMessageText() const OVERRIDE; |
144 virtual int GetButtons() const OVERRIDE; | 145 virtual int GetButtons() const OVERRIDE; |
(...skipping 24 matching lines...) Expand all Loading... |
169 | 170 |
170 DISALLOW_COPY_AND_ASSIGN(PluginInstallerInfoBarDelegate); | 171 DISALLOW_COPY_AND_ASSIGN(PluginInstallerInfoBarDelegate); |
171 }; | 172 }; |
172 #endif // defined(ENABLE_PLUGIN_INSTALLATION) | 173 #endif // defined(ENABLE_PLUGIN_INSTALLATION) |
173 | 174 |
174 #if defined(OS_WIN) | 175 #if defined(OS_WIN) |
175 class PluginMetroModeInfoBarDelegate : public ConfirmInfoBarDelegate { | 176 class PluginMetroModeInfoBarDelegate : public ConfirmInfoBarDelegate { |
176 public: | 177 public: |
177 // Shows an infobar asking the user to switch to desktop chrome if they | 178 // Shows an infobar asking the user to switch to desktop chrome if they |
178 // want to use the plugin. | 179 // want to use the plugin. |
179 static InfoBarDelegate* Create(InfoBarTabHelper* infobar_helper, | 180 static InfoBarDelegate* Create(InfoBarTabService* infobar_service, |
180 const string16& plugin_name); | 181 const string16& plugin_name); |
181 private: | 182 private: |
182 PluginMetroModeInfoBarDelegate(InfoBarTabHelper* infobar_helper, | 183 PluginMetroModeInfoBarDelegate(InfoBarTabService* infobar_service, |
183 const string16& message); | 184 const string16& message); |
184 virtual ~PluginMetroModeInfoBarDelegate(); | 185 virtual ~PluginMetroModeInfoBarDelegate(); |
185 | 186 |
186 // ConfirmInfoBarDelegate: | 187 // ConfirmInfoBarDelegate: |
187 virtual gfx::Image* GetIcon() const OVERRIDE; | 188 virtual gfx::Image* GetIcon() const OVERRIDE; |
188 virtual string16 GetMessageText() const OVERRIDE; | 189 virtual string16 GetMessageText() const OVERRIDE; |
189 virtual int GetButtons() const OVERRIDE; | 190 virtual int GetButtons() const OVERRIDE; |
190 virtual string16 GetButtonLabel(InfoBarButton button) const OVERRIDE; | 191 virtual string16 GetButtonLabel(InfoBarButton button) const OVERRIDE; |
191 virtual bool Accept() OVERRIDE; | 192 virtual bool Accept() OVERRIDE; |
192 virtual string16 GetLinkText() const OVERRIDE; | 193 virtual string16 GetLinkText() const OVERRIDE; |
193 virtual bool LinkClicked(WindowOpenDisposition disposition) OVERRIDE; | 194 virtual bool LinkClicked(WindowOpenDisposition disposition) OVERRIDE; |
194 | 195 |
195 string16 message_; | 196 string16 message_; |
196 | 197 |
197 DISALLOW_COPY_AND_ASSIGN(PluginMetroModeInfoBarDelegate); | 198 DISALLOW_COPY_AND_ASSIGN(PluginMetroModeInfoBarDelegate); |
198 }; | 199 }; |
199 #endif // defined(OS_WIN) | 200 #endif // defined(OS_WIN) |
200 | 201 |
201 #endif // CHROME_BROWSER_PLUGIN_INFOBAR_DELEGATES_H_ | 202 #endif // CHROME_BROWSER_PLUGIN_INFOBAR_DELEGATES_H_ |
OLD | NEW |