| 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/content_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 ContentConfirmInfoBarDelegate { |
| 26 protected: | 26 protected: |
| 27 explicit PluginInfoBarDelegate(const std::string& identifier); | 27 explicit PluginInfoBarDelegate(content::WebContents* web_contents, |
| 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: |
| (...skipping 10 matching lines...) Expand all Loading... |
| 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 and delegate and adds the infobar 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 base::string16& name, | 55 const base::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(content::WebContents* web_contents, |
| 60 HostContentSettingsMap* content_settings, |
| 59 const base::string16& name, | 61 const base::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 base::string16 GetMessageText() const OVERRIDE; | 66 virtual base::string16 GetMessageText() const OVERRIDE; |
| 65 virtual base::string16 GetButtonLabel(InfoBarButton button) const OVERRIDE; | 67 virtual base::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; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 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 and delegate and adds the infobar 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(content::WebContents* web_contents, |
| 93 PluginInstaller* installer, |
| 91 scoped_ptr<PluginMetadata> metadata, | 94 scoped_ptr<PluginMetadata> metadata, |
| 92 const base::string16& message); | 95 const base::string16& message); |
| 93 virtual ~OutdatedPluginInfoBarDelegate(); | 96 virtual ~OutdatedPluginInfoBarDelegate(); |
| 94 | 97 |
| 95 // PluginInfoBarDelegate: | 98 // PluginInfoBarDelegate: |
| 96 virtual base::string16 GetMessageText() const OVERRIDE; | 99 virtual base::string16 GetMessageText() const OVERRIDE; |
| 97 virtual base::string16 GetButtonLabel(InfoBarButton button) const OVERRIDE; | 100 virtual base::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 15 matching lines...) Expand all Loading... |
| 116 | 119 |
| 117 scoped_ptr<PluginMetadata> plugin_metadata_; | 120 scoped_ptr<PluginMetadata> plugin_metadata_; |
| 118 | 121 |
| 119 base::string16 message_; | 122 base::string16 message_; |
| 120 | 123 |
| 121 DISALLOW_COPY_AND_ASSIGN(OutdatedPluginInfoBarDelegate); | 124 DISALLOW_COPY_AND_ASSIGN(OutdatedPluginInfoBarDelegate); |
| 122 }; | 125 }; |
| 123 | 126 |
| 124 // The main purpose for this class is to popup/close the infobar when there is | 127 // The main purpose for this class is to popup/close the infobar when there is |
| 125 // a missing plugin. | 128 // a missing plugin. |
| 126 class PluginInstallerInfoBarDelegate : public ConfirmInfoBarDelegate, | 129 class PluginInstallerInfoBarDelegate : public ContentConfirmInfoBarDelegate, |
| 127 public WeakPluginInstallerObserver { | 130 public WeakPluginInstallerObserver { |
| 128 public: | 131 public: |
| 129 typedef base::Callback<void(const PluginMetadata*)> InstallCallback; | 132 typedef base::Callback<void(const PluginMetadata*)> InstallCallback; |
| 130 | 133 |
| 131 // Shows an infobar asking whether to install the plugin represented by | 134 // Shows an infobar asking whether to install the plugin represented by |
| 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(content::WebContents* web_contents, |
| 146 InfoBar* infobar, |
| 143 PluginInstaller* installer, | 147 PluginInstaller* installer, |
| 144 scoped_ptr<PluginMetadata> plugin_metadata, | 148 scoped_ptr<PluginMetadata> plugin_metadata, |
| 145 bool new_install, | 149 bool new_install, |
| 146 const base::string16& message); | 150 const base::string16& message); |
| 147 | 151 |
| 148 private: | 152 private: |
| 149 PluginInstallerInfoBarDelegate(PluginInstaller* installer, | 153 PluginInstallerInfoBarDelegate(content::WebContents* web_contents, |
| 154 PluginInstaller* installer, |
| 150 scoped_ptr<PluginMetadata> metadata, | 155 scoped_ptr<PluginMetadata> metadata, |
| 151 const InstallCallback& callback, | 156 const InstallCallback& callback, |
| 152 bool new_install, | 157 bool new_install, |
| 153 const base::string16& message); | 158 const base::string16& message); |
| 154 virtual ~PluginInstallerInfoBarDelegate(); | 159 virtual ~PluginInstallerInfoBarDelegate(); |
| 155 | 160 |
| 156 // ConfirmInfoBarDelegate: | 161 // ConfirmInfoBarDelegate: |
| 157 virtual int GetIconID() const OVERRIDE; | 162 virtual int GetIconID() const OVERRIDE; |
| 158 virtual base::string16 GetMessageText() const OVERRIDE; | 163 virtual base::string16 GetMessageText() const OVERRIDE; |
| 159 virtual int GetButtons() const OVERRIDE; | 164 virtual int GetButtons() const OVERRIDE; |
| (...skipping 22 matching lines...) Expand all Loading... |
| 182 // True iff the plug-in isn't installed yet. | 187 // True iff the plug-in isn't installed yet. |
| 183 bool new_install_; | 188 bool new_install_; |
| 184 | 189 |
| 185 base::string16 message_; | 190 base::string16 message_; |
| 186 | 191 |
| 187 DISALLOW_COPY_AND_ASSIGN(PluginInstallerInfoBarDelegate); | 192 DISALLOW_COPY_AND_ASSIGN(PluginInstallerInfoBarDelegate); |
| 188 }; | 193 }; |
| 189 #endif // defined(ENABLE_PLUGIN_INSTALLATION) | 194 #endif // defined(ENABLE_PLUGIN_INSTALLATION) |
| 190 | 195 |
| 191 #if defined(OS_WIN) | 196 #if defined(OS_WIN) |
| 192 class PluginMetroModeInfoBarDelegate : public ConfirmInfoBarDelegate { | 197 class PluginMetroModeInfoBarDelegate : public ContentConfirmInfoBarDelegate { |
| 193 public: | 198 public: |
| 194 // The infobar can be used for two purposes: to inform the user about a | 199 // The infobar can be used for two purposes: to inform the user about a |
| 195 // missing plugin or to note that a plugin only works in desktop mode. These | 200 // missing plugin or to note that a plugin only works in desktop mode. These |
| 196 // purposes require different messages, buttons, etc. | 201 // purposes require different messages, buttons, etc. |
| 197 enum Mode { | 202 enum Mode { |
| 198 MISSING_PLUGIN, | 203 MISSING_PLUGIN, |
| 199 DESKTOP_MODE_REQUIRED, | 204 DESKTOP_MODE_REQUIRED, |
| 200 }; | 205 }; |
| 201 | 206 |
| 202 // Creates a metro mode infobar and delegate and adds the infobar to | 207 // Creates a metro mode infobar and delegate and adds the infobar to |
| 203 // |infobar_service|. | 208 // |infobar_service|. |
| 204 static void Create(InfoBarService* infobar_service, | 209 static void Create(InfoBarService* infobar_service, |
| 205 Mode mode, | 210 Mode mode, |
| 206 const base::string16& name); | 211 const base::string16& name); |
| 207 | 212 |
| 208 private: | 213 private: |
| 209 PluginMetroModeInfoBarDelegate(Mode mode, const base::string16& name); | 214 PluginMetroModeInfoBarDelegate(content::WebContents* web_contents, |
| 215 Mode mode, |
| 216 const base::string16& name); |
| 210 virtual ~PluginMetroModeInfoBarDelegate(); | 217 virtual ~PluginMetroModeInfoBarDelegate(); |
| 211 | 218 |
| 212 // ConfirmInfoBarDelegate: | 219 // ConfirmInfoBarDelegate: |
| 213 virtual int GetIconID() const OVERRIDE; | 220 virtual int GetIconID() const OVERRIDE; |
| 214 virtual base::string16 GetMessageText() const OVERRIDE; | 221 virtual base::string16 GetMessageText() const OVERRIDE; |
| 215 virtual int GetButtons() const OVERRIDE; | 222 virtual int GetButtons() const OVERRIDE; |
| 216 virtual base::string16 GetButtonLabel(InfoBarButton button) const OVERRIDE; | 223 virtual base::string16 GetButtonLabel(InfoBarButton button) const OVERRIDE; |
| 217 virtual bool Accept() OVERRIDE; | 224 virtual bool Accept() OVERRIDE; |
| 218 virtual base::string16 GetLinkText() const OVERRIDE; | 225 virtual base::string16 GetLinkText() const OVERRIDE; |
| 219 virtual bool LinkClicked(WindowOpenDisposition disposition) OVERRIDE; | 226 virtual bool LinkClicked(WindowOpenDisposition disposition) OVERRIDE; |
| 220 | 227 |
| 221 const Mode mode_; | 228 const Mode mode_; |
| 222 const base::string16 name_; | 229 const base::string16 name_; |
| 223 | 230 |
| 224 DISALLOW_COPY_AND_ASSIGN(PluginMetroModeInfoBarDelegate); | 231 DISALLOW_COPY_AND_ASSIGN(PluginMetroModeInfoBarDelegate); |
| 225 }; | 232 }; |
| 226 #endif // defined(OS_WIN) | 233 #endif // defined(OS_WIN) |
| 227 | 234 |
| 228 #endif // CHROME_BROWSER_PLUGINS_PLUGIN_INFOBAR_DELEGATES_H_ | 235 #endif // CHROME_BROWSER_PLUGINS_PLUGIN_INFOBAR_DELEGATES_H_ |
| OLD | NEW |