Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(760)

Side by Side Diff: chrome/browser/plugins/plugin_infobar_delegates.h

Issue 11644059: Change infobar creation to use a public static Create() method on the infobar delegate classes. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 7 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/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"
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 virtual string16 GetLinkText() const OVERRIDE; 46 virtual string16 GetLinkText() const OVERRIDE;
47 47
48 std::string identifier_; 48 std::string identifier_;
49 49
50 DISALLOW_COPY_AND_ASSIGN(PluginInfoBarDelegate); 50 DISALLOW_COPY_AND_ASSIGN(PluginInfoBarDelegate);
51 }; 51 };
52 52
53 // Infobar that's shown when a plug-in requires user authorization to run. 53 // Infobar that's shown when a plug-in requires user authorization to run.
54 class UnauthorizedPluginInfoBarDelegate : public PluginInfoBarDelegate { 54 class UnauthorizedPluginInfoBarDelegate : public PluginInfoBarDelegate {
55 public: 55 public:
56 // Creates an unauthorized plugin delegate and adds it to |infobar_service|.
57 static void Create(InfoBarService* infobar_service,
58 HostContentSettingsMap* content_settings,
59 const string16& name,
60 const std::string& identifier);
61
62 private:
56 UnauthorizedPluginInfoBarDelegate(InfoBarService* infobar_service, 63 UnauthorizedPluginInfoBarDelegate(InfoBarService* infobar_service,
57 HostContentSettingsMap* content_settings, 64 HostContentSettingsMap* content_settings,
58 const string16& name, 65 const string16& name,
59 const std::string& identifier); 66 const std::string& identifier);
60
61 private:
62 virtual ~UnauthorizedPluginInfoBarDelegate(); 67 virtual ~UnauthorizedPluginInfoBarDelegate();
63 68
64 // PluginInfoBarDelegate: 69 // PluginInfoBarDelegate:
65 virtual string16 GetMessageText() const OVERRIDE; 70 virtual string16 GetMessageText() const OVERRIDE;
66 virtual string16 GetButtonLabel(InfoBarButton button) const OVERRIDE; 71 virtual string16 GetButtonLabel(InfoBarButton button) const OVERRIDE;
67 virtual bool Accept() OVERRIDE; 72 virtual bool Accept() OVERRIDE;
68 virtual bool Cancel() OVERRIDE; 73 virtual bool Cancel() OVERRIDE;
69 virtual void InfoBarDismissed() OVERRIDE; 74 virtual void InfoBarDismissed() OVERRIDE;
70 virtual bool LinkClicked(WindowOpenDisposition disposition) OVERRIDE; 75 virtual bool LinkClicked(WindowOpenDisposition disposition) OVERRIDE;
71 virtual std::string GetLearnMoreURL() const OVERRIDE; 76 virtual std::string GetLearnMoreURL() const OVERRIDE;
72 77
73 HostContentSettingsMap* content_settings_; 78 HostContentSettingsMap* content_settings_;
74 79
75 DISALLOW_COPY_AND_ASSIGN(UnauthorizedPluginInfoBarDelegate); 80 DISALLOW_COPY_AND_ASSIGN(UnauthorizedPluginInfoBarDelegate);
76 }; 81 };
77 82
78 #if defined(ENABLE_PLUGIN_INSTALLATION) 83 #if defined(ENABLE_PLUGIN_INSTALLATION)
79 // Infobar that's shown when a plug-in is out of date. 84 // Infobar that's shown when a plug-in is out of date.
80 class OutdatedPluginInfoBarDelegate : public PluginInfoBarDelegate, 85 class OutdatedPluginInfoBarDelegate : public PluginInfoBarDelegate,
81 public WeakPluginInstallerObserver { 86 public WeakPluginInstallerObserver {
82 public: 87 public:
83 static InfoBarDelegate* Create(content::WebContents* web_contents, 88 // Creates an outdated plugin delegate and adds it to |infobar_service|.
84 PluginInstaller* installer, 89 static void Create(InfoBarService* infobar_service,
85 scoped_ptr<PluginMetadata> metadata); 90 PluginInstaller* installer,
91 scoped_ptr<PluginMetadata> metadata);
86 92
87 private: 93 private:
88 OutdatedPluginInfoBarDelegate(content::WebContents* web_contents, 94 OutdatedPluginInfoBarDelegate(InfoBarService* infobar_service,
89 PluginInstaller* installer, 95 PluginInstaller* installer,
90 scoped_ptr<PluginMetadata> metadata, 96 scoped_ptr<PluginMetadata> metadata,
91 const string16& message); 97 const string16& message);
92 virtual ~OutdatedPluginInfoBarDelegate(); 98 virtual ~OutdatedPluginInfoBarDelegate();
93 99
94 // PluginInfoBarDelegate: 100 // PluginInfoBarDelegate:
95 virtual string16 GetMessageText() const OVERRIDE; 101 virtual string16 GetMessageText() const OVERRIDE;
96 virtual string16 GetButtonLabel(InfoBarButton button) const OVERRIDE; 102 virtual string16 GetButtonLabel(InfoBarButton button) const OVERRIDE;
97 virtual bool Accept() OVERRIDE; 103 virtual bool Accept() OVERRIDE;
98 virtual bool Cancel() OVERRIDE; 104 virtual bool Cancel() OVERRIDE;
(...skipping 25 matching lines...) Expand all
124 // a missing plugin. 130 // a missing plugin.
125 class PluginInstallerInfoBarDelegate : public ConfirmInfoBarDelegate, 131 class PluginInstallerInfoBarDelegate : public ConfirmInfoBarDelegate,
126 public WeakPluginInstallerObserver { 132 public WeakPluginInstallerObserver {
127 public: 133 public:
128 typedef base::Callback<void(const PluginMetadata*)> InstallCallback; 134 typedef base::Callback<void(const PluginMetadata*)> InstallCallback;
129 135
130 // Shows an infobar asking whether to install the plugin represented by 136 // Shows an infobar asking whether to install the plugin represented by
131 // |installer|. When the user accepts, |callback| is called. 137 // |installer|. When the user accepts, |callback| is called.
132 // During installation of the plug-in, the infobar will change to reflect the 138 // During installation of the plug-in, the infobar will change to reflect the
133 // installation state. 139 // installation state.
134 static InfoBarDelegate* Create(InfoBarService* infobar_service, 140 static void Create(InfoBarService* infobar_service,
135 PluginInstaller* installer, 141 PluginInstaller* installer,
136 scoped_ptr<PluginMetadata> plugin_metadata, 142 scoped_ptr<PluginMetadata> plugin_metadata,
137 const InstallCallback& callback); 143 const InstallCallback& callback);
144
145 // Replaces |infobar|, which must currently be owned, with an infobar asking
146 // the user to install or update a particular plugin.
147 static void Replace(InfoBarDelegate* infobar,
148 PluginInstaller* installer,
149 scoped_ptr<PluginMetadata> metadata,
150 bool new_install,
151 const string16& message);
138 152
139 private: 153 private:
140 friend class OutdatedPluginInfoBarDelegate;
141
142 PluginInstallerInfoBarDelegate(InfoBarService* infobar_service, 154 PluginInstallerInfoBarDelegate(InfoBarService* infobar_service,
143 PluginInstaller* installer, 155 PluginInstaller* installer,
144 scoped_ptr<PluginMetadata> plugin_metadata, 156 scoped_ptr<PluginMetadata> plugin_metadata,
145 const InstallCallback& callback, 157 const InstallCallback& callback,
146 bool new_install, 158 bool new_install,
147 const string16& message); 159 const string16& message);
148 virtual ~PluginInstallerInfoBarDelegate(); 160 virtual ~PluginInstallerInfoBarDelegate();
149 161
150 // ConfirmInfoBarDelegate: 162 // ConfirmInfoBarDelegate:
151 virtual gfx::Image* GetIcon() const OVERRIDE; 163 virtual gfx::Image* GetIcon() const OVERRIDE;
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
186 class PluginMetroModeInfoBarDelegate : public ConfirmInfoBarDelegate { 198 class PluginMetroModeInfoBarDelegate : public ConfirmInfoBarDelegate {
187 public: 199 public:
188 // The infobar can be used for two purposes: to inform the user about a 200 // The infobar can be used for two purposes: to inform the user about a
189 // missing plugin or to note that a plugin only works in desktop mode. These 201 // missing plugin or to note that a plugin only works in desktop mode. These
190 // purposes require different messages, buttons, etc. 202 // purposes require different messages, buttons, etc.
191 enum Mode { 203 enum Mode {
192 MISSING_PLUGIN, 204 MISSING_PLUGIN,
193 DESKTOP_MODE_REQUIRED, 205 DESKTOP_MODE_REQUIRED,
194 }; 206 };
195 207
208 // Creates a metro mode infobar and delegate and adds the infobar to
209 // |infobar_service|.
210 static void Create(InfoBarService* infobar_service,
211 Mode mode,
212 const string16& name);
213
214 private:
196 PluginMetroModeInfoBarDelegate(InfoBarService* infobar_service, 215 PluginMetroModeInfoBarDelegate(InfoBarService* infobar_service,
197 Mode mode, 216 Mode mode,
198 const string16& name); 217 const string16& name);
199
200 private:
201 virtual ~PluginMetroModeInfoBarDelegate(); 218 virtual ~PluginMetroModeInfoBarDelegate();
202 219
203 // ConfirmInfoBarDelegate: 220 // ConfirmInfoBarDelegate:
204 virtual gfx::Image* GetIcon() const OVERRIDE; 221 virtual gfx::Image* GetIcon() const OVERRIDE;
205 virtual string16 GetMessageText() const OVERRIDE; 222 virtual string16 GetMessageText() const OVERRIDE;
206 virtual int GetButtons() const OVERRIDE; 223 virtual int GetButtons() const OVERRIDE;
207 virtual string16 GetButtonLabel(InfoBarButton button) const OVERRIDE; 224 virtual string16 GetButtonLabel(InfoBarButton button) const OVERRIDE;
208 virtual bool Accept() OVERRIDE; 225 virtual bool Accept() OVERRIDE;
209 virtual bool Cancel() OVERRIDE; 226 virtual bool Cancel() OVERRIDE;
210 virtual string16 GetLinkText() const OVERRIDE; 227 virtual string16 GetLinkText() const OVERRIDE;
211 virtual bool LinkClicked(WindowOpenDisposition disposition) OVERRIDE; 228 virtual bool LinkClicked(WindowOpenDisposition disposition) OVERRIDE;
212 229
213 const Mode mode_; 230 const Mode mode_;
214 const string16 name_; 231 const string16 name_;
215 232
216 DISALLOW_COPY_AND_ASSIGN(PluginMetroModeInfoBarDelegate); 233 DISALLOW_COPY_AND_ASSIGN(PluginMetroModeInfoBarDelegate);
217 }; 234 };
218 #endif // defined(OS_WIN) 235 #endif // defined(OS_WIN)
219 236
220 #endif // CHROME_BROWSER_PLUGINS_PLUGIN_INFOBAR_DELEGATES_H_ 237 #endif // CHROME_BROWSER_PLUGINS_PLUGIN_INFOBAR_DELEGATES_H_
OLDNEW
« no previous file with comments | « chrome/browser/pepper_broker_infobar_delegate.cc ('k') | chrome/browser/plugins/plugin_infobar_delegates.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698