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

Side by Side Diff: chrome/browser/plugin_observer.cc

Issue 6926001: Replace the virtual InfoBarDelegate::InfoBarClosed() function with a non-virtual one. This is a ... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 7 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 #include "chrome/browser/plugin_observer.h" 5 #include "chrome/browser/plugin_observer.h"
6 6
7 #include "base/utf_string_conversions.h" 7 #include "base/utf_string_conversions.h"
8 #include "chrome/browser/content_settings/host_content_settings_map.h" 8 #include "chrome/browser/content_settings/host_content_settings_map.h"
9 #include "chrome/browser/google/google_util.h" 9 #include "chrome/browser/google/google_util.h"
10 #include "chrome/browser/plugin_installer_infobar_delegate.h" 10 #include "chrome/browser/plugin_installer_infobar_delegate.h"
(...skipping 20 matching lines...) Expand all
31 // PluginInfoBarDelegate ------------------------------------------------------ 31 // PluginInfoBarDelegate ------------------------------------------------------
32 32
33 class PluginInfoBarDelegate : public ConfirmInfoBarDelegate { 33 class PluginInfoBarDelegate : public ConfirmInfoBarDelegate {
34 public: 34 public:
35 PluginInfoBarDelegate(TabContents* tab_contents, const string16& name); 35 PluginInfoBarDelegate(TabContents* tab_contents, const string16& name);
36 36
37 protected: 37 protected:
38 virtual ~PluginInfoBarDelegate(); 38 virtual ~PluginInfoBarDelegate();
39 39
40 // ConfirmInfoBarDelegate: 40 // ConfirmInfoBarDelegate:
41 virtual void InfoBarClosed(); 41 virtual bool Cancel() OVERRIDE;
42 virtual bool Cancel(); 42 virtual bool LinkClicked(WindowOpenDisposition disposition) OVERRIDE;
43 virtual bool LinkClicked(WindowOpenDisposition disposition);
44 43
45 virtual std::string GetLearnMoreURL() const = 0; 44 virtual std::string GetLearnMoreURL() const = 0;
46 45
47 string16 name_; 46 string16 name_;
48 TabContents* tab_contents_; 47 TabContents* tab_contents_;
49 48
50 private: 49 private:
51 // ConfirmInfoBarDelegate: 50 // ConfirmInfoBarDelegate:
52 virtual gfx::Image* GetIcon() const; 51 virtual gfx::Image* GetIcon() const;
53 virtual string16 GetLinkText(); 52 virtual string16 GetLinkText();
54 53
55 DISALLOW_COPY_AND_ASSIGN(PluginInfoBarDelegate); 54 DISALLOW_COPY_AND_ASSIGN(PluginInfoBarDelegate);
56 }; 55 };
57 56
58 PluginInfoBarDelegate::PluginInfoBarDelegate(TabContents* tab_contents, 57 PluginInfoBarDelegate::PluginInfoBarDelegate(TabContents* tab_contents,
59 const string16& name) 58 const string16& name)
60 : ConfirmInfoBarDelegate(tab_contents), 59 : ConfirmInfoBarDelegate(tab_contents),
61 name_(name), 60 name_(name),
62 tab_contents_(tab_contents) { 61 tab_contents_(tab_contents) {
63 } 62 }
64 63
65 PluginInfoBarDelegate::~PluginInfoBarDelegate() { 64 PluginInfoBarDelegate::~PluginInfoBarDelegate() {
66 } 65 }
67 66
68 void PluginInfoBarDelegate::InfoBarClosed() {
69 delete this;
70 }
71
72 bool PluginInfoBarDelegate::Cancel() { 67 bool PluginInfoBarDelegate::Cancel() {
73 tab_contents_->render_view_host()->Send(new ViewMsg_LoadBlockedPlugins( 68 tab_contents_->render_view_host()->Send(new ViewMsg_LoadBlockedPlugins(
74 tab_contents_->render_view_host()->routing_id())); 69 tab_contents_->render_view_host()->routing_id()));
75 return true; 70 return true;
76 } 71 }
77 72
78 bool PluginInfoBarDelegate::LinkClicked(WindowOpenDisposition disposition) { 73 bool PluginInfoBarDelegate::LinkClicked(WindowOpenDisposition disposition) {
79 GURL url = google_util::AppendGoogleLocaleParam(GURL(GetLearnMoreURL())); 74 GURL url = google_util::AppendGoogleLocaleParam(GURL(GetLearnMoreURL()));
80 tab_contents_->OpenURL(url, GURL(), NEW_FOREGROUND_TAB, PageTransition::LINK); 75 tab_contents_->OpenURL(url, GURL(), NEW_FOREGROUND_TAB, PageTransition::LINK);
81 return false; 76 return false;
(...skipping 13 matching lines...) Expand all
95 90
96 class BlockedPluginInfoBarDelegate : public PluginInfoBarDelegate { 91 class BlockedPluginInfoBarDelegate : public PluginInfoBarDelegate {
97 public: 92 public:
98 BlockedPluginInfoBarDelegate(TabContents* tab_contents, 93 BlockedPluginInfoBarDelegate(TabContents* tab_contents,
99 const string16& name); 94 const string16& name);
100 95
101 private: 96 private:
102 virtual ~BlockedPluginInfoBarDelegate(); 97 virtual ~BlockedPluginInfoBarDelegate();
103 98
104 // PluginInfoBarDelegate: 99 // PluginInfoBarDelegate:
105 virtual string16 GetMessageText() const; 100 virtual string16 GetMessageText() const OVERRIDE;
106 virtual string16 GetButtonLabel(InfoBarButton button) const; 101 virtual string16 GetButtonLabel(InfoBarButton button) const OVERRIDE;
107 virtual bool Accept(); 102 virtual bool Accept() OVERRIDE;
108 virtual bool Cancel(); 103 virtual bool Cancel() OVERRIDE;
109 virtual void InfoBarClosed(); 104 virtual void InfoBarDismissed() OVERRIDE;
110 virtual void InfoBarDismissed(); 105 virtual bool LinkClicked(WindowOpenDisposition disposition) OVERRIDE;
111 virtual bool LinkClicked(WindowOpenDisposition disposition); 106 virtual std::string GetLearnMoreURL() const OVERRIDE;
112 virtual std::string GetLearnMoreURL() const;
113 107
114 DISALLOW_COPY_AND_ASSIGN(BlockedPluginInfoBarDelegate); 108 DISALLOW_COPY_AND_ASSIGN(BlockedPluginInfoBarDelegate);
115 }; 109 };
116 110
117 BlockedPluginInfoBarDelegate::BlockedPluginInfoBarDelegate( 111 BlockedPluginInfoBarDelegate::BlockedPluginInfoBarDelegate(
118 TabContents* tab_contents, 112 TabContents* tab_contents,
119 const string16& utf16_name) 113 const string16& utf16_name)
120 : PluginInfoBarDelegate(tab_contents, utf16_name) { 114 : PluginInfoBarDelegate(tab_contents, utf16_name) {
121 UserMetrics::RecordAction(UserMetricsAction("BlockedPluginInfobar.Shown")); 115 UserMetrics::RecordAction(UserMetricsAction("BlockedPluginInfobar.Shown"));
122 std::string name = UTF16ToUTF8(utf16_name); 116 std::string name = UTF16ToUTF8(utf16_name);
123 if (name == webkit::npapi::PluginGroup::kJavaGroupName) 117 if (name == webkit::npapi::PluginGroup::kJavaGroupName)
124 UserMetrics::RecordAction( 118 UserMetrics::RecordAction(
125 UserMetricsAction("BlockedPluginInfobar.Shown.Java")); 119 UserMetricsAction("BlockedPluginInfobar.Shown.Java"));
126 else if (name == webkit::npapi::PluginGroup::kQuickTimeGroupName) 120 else if (name == webkit::npapi::PluginGroup::kQuickTimeGroupName)
127 UserMetrics::RecordAction( 121 UserMetrics::RecordAction(
128 UserMetricsAction("BlockedPluginInfobar.Shown.QuickTime")); 122 UserMetricsAction("BlockedPluginInfobar.Shown.QuickTime"));
129 else if (name == webkit::npapi::PluginGroup::kShockwaveGroupName) 123 else if (name == webkit::npapi::PluginGroup::kShockwaveGroupName)
130 UserMetrics::RecordAction( 124 UserMetrics::RecordAction(
131 UserMetricsAction("BlockedPluginInfobar.Shown.Shockwave")); 125 UserMetricsAction("BlockedPluginInfobar.Shown.Shockwave"));
132 else if (name == webkit::npapi::PluginGroup::kRealPlayerGroupName) 126 else if (name == webkit::npapi::PluginGroup::kRealPlayerGroupName)
133 UserMetrics::RecordAction( 127 UserMetrics::RecordAction(
134 UserMetricsAction("BlockedPluginInfobar.Shown.RealPlayer")); 128 UserMetricsAction("BlockedPluginInfobar.Shown.RealPlayer"));
135 } 129 }
136 130
137 BlockedPluginInfoBarDelegate::~BlockedPluginInfoBarDelegate() { 131 BlockedPluginInfoBarDelegate::~BlockedPluginInfoBarDelegate() {
132 UserMetrics::RecordAction(UserMetricsAction("BlockedPluginInfobar.Closed"));
138 } 133 }
139 134
140 std::string BlockedPluginInfoBarDelegate::GetLearnMoreURL() const { 135 std::string BlockedPluginInfoBarDelegate::GetLearnMoreURL() const {
141 return chrome::kBlockedPluginLearnMoreURL; 136 return chrome::kBlockedPluginLearnMoreURL;
142 } 137 }
143 138
144 string16 BlockedPluginInfoBarDelegate::GetMessageText() const { 139 string16 BlockedPluginInfoBarDelegate::GetMessageText() const {
145 return l10n_util::GetStringFUTF16(IDS_PLUGIN_NOT_AUTHORIZED, name_); 140 return l10n_util::GetStringFUTF16(IDS_PLUGIN_NOT_AUTHORIZED, name_);
146 } 141 }
147 142
(...skipping 16 matching lines...) Expand all
164 tab_contents_->GetURL(), CONTENT_SETTINGS_TYPE_PLUGINS, std::string(), 159 tab_contents_->GetURL(), CONTENT_SETTINGS_TYPE_PLUGINS, std::string(),
165 CONTENT_SETTING_ALLOW); 160 CONTENT_SETTING_ALLOW);
166 return PluginInfoBarDelegate::Cancel(); 161 return PluginInfoBarDelegate::Cancel();
167 } 162 }
168 163
169 void BlockedPluginInfoBarDelegate::InfoBarDismissed() { 164 void BlockedPluginInfoBarDelegate::InfoBarDismissed() {
170 UserMetrics::RecordAction( 165 UserMetrics::RecordAction(
171 UserMetricsAction("BlockedPluginInfobar.Dismissed")); 166 UserMetricsAction("BlockedPluginInfobar.Dismissed"));
172 } 167 }
173 168
174 void BlockedPluginInfoBarDelegate::InfoBarClosed() {
175 UserMetrics::RecordAction(UserMetricsAction("BlockedPluginInfobar.Closed"));
176 PluginInfoBarDelegate::InfoBarClosed();
177 }
178
179 bool BlockedPluginInfoBarDelegate::LinkClicked( 169 bool BlockedPluginInfoBarDelegate::LinkClicked(
180 WindowOpenDisposition disposition) { 170 WindowOpenDisposition disposition) {
181 UserMetrics::RecordAction( 171 UserMetrics::RecordAction(
182 UserMetricsAction("BlockedPluginInfobar.LearnMore")); 172 UserMetricsAction("BlockedPluginInfobar.LearnMore"));
183 return PluginInfoBarDelegate::LinkClicked(disposition); 173 return PluginInfoBarDelegate::LinkClicked(disposition);
184 } 174 }
185 175
186 // OutdatedPluginInfoBarDelegate ---------------------------------------------- 176 // OutdatedPluginInfoBarDelegate ----------------------------------------------
187 177
188 class OutdatedPluginInfoBarDelegate : public PluginInfoBarDelegate { 178 class OutdatedPluginInfoBarDelegate : public PluginInfoBarDelegate {
189 public: 179 public:
190 OutdatedPluginInfoBarDelegate(TabContents* tab_contents, 180 OutdatedPluginInfoBarDelegate(TabContents* tab_contents,
191 const string16& name, 181 const string16& name,
192 const GURL& update_url); 182 const GURL& update_url);
193 183
194 private: 184 private:
195 virtual ~OutdatedPluginInfoBarDelegate(); 185 virtual ~OutdatedPluginInfoBarDelegate();
196 186
197 // PluginInfoBarDelegate: 187 // PluginInfoBarDelegate:
198 virtual string16 GetMessageText() const; 188 virtual string16 GetMessageText() const OVERRIDE;
199 virtual string16 GetButtonLabel(InfoBarButton button) const; 189 virtual string16 GetButtonLabel(InfoBarButton button) const OVERRIDE;
200 virtual bool Accept(); 190 virtual bool Accept() OVERRIDE;
201 virtual bool Cancel(); 191 virtual bool Cancel() OVERRIDE;
202 virtual void InfoBarClosed(); 192 virtual void InfoBarDismissed() OVERRIDE;
203 virtual void InfoBarDismissed(); 193 virtual bool LinkClicked(WindowOpenDisposition disposition) OVERRIDE;
204 virtual bool LinkClicked(WindowOpenDisposition disposition); 194 virtual std::string GetLearnMoreURL() const OVERRIDE;
205 virtual std::string GetLearnMoreURL() const;
206 195
207 GURL update_url_; 196 GURL update_url_;
208 197
209 DISALLOW_COPY_AND_ASSIGN(OutdatedPluginInfoBarDelegate); 198 DISALLOW_COPY_AND_ASSIGN(OutdatedPluginInfoBarDelegate);
210 }; 199 };
211 200
212 OutdatedPluginInfoBarDelegate::OutdatedPluginInfoBarDelegate( 201 OutdatedPluginInfoBarDelegate::OutdatedPluginInfoBarDelegate(
213 TabContents* tab_contents, 202 TabContents* tab_contents,
214 const string16& utf16_name, 203 const string16& utf16_name,
215 const GURL& update_url) 204 const GURL& update_url)
(...skipping 15 matching lines...) Expand all
231 UserMetricsAction("OutdatedPluginInfobar.Shown.RealPlayer")); 220 UserMetricsAction("OutdatedPluginInfobar.Shown.RealPlayer"));
232 else if (name == webkit::npapi::PluginGroup::kSilverlightGroupName) 221 else if (name == webkit::npapi::PluginGroup::kSilverlightGroupName)
233 UserMetrics::RecordAction( 222 UserMetrics::RecordAction(
234 UserMetricsAction("OutdatedPluginInfobar.Shown.Silverlight")); 223 UserMetricsAction("OutdatedPluginInfobar.Shown.Silverlight"));
235 else if (name == webkit::npapi::PluginGroup::kAdobeReaderGroupName) 224 else if (name == webkit::npapi::PluginGroup::kAdobeReaderGroupName)
236 UserMetrics::RecordAction( 225 UserMetrics::RecordAction(
237 UserMetricsAction("OutdatedPluginInfobar.Shown.Reader")); 226 UserMetricsAction("OutdatedPluginInfobar.Shown.Reader"));
238 } 227 }
239 228
240 OutdatedPluginInfoBarDelegate::~OutdatedPluginInfoBarDelegate() { 229 OutdatedPluginInfoBarDelegate::~OutdatedPluginInfoBarDelegate() {
230 UserMetrics::RecordAction(UserMetricsAction("OutdatedPluginInfobar.Closed"));
241 } 231 }
242 232
243 std::string OutdatedPluginInfoBarDelegate::GetLearnMoreURL() const { 233 std::string OutdatedPluginInfoBarDelegate::GetLearnMoreURL() const {
244 return chrome::kOutdatedPluginLearnMoreURL; 234 return chrome::kOutdatedPluginLearnMoreURL;
245 } 235 }
246 236
247 string16 OutdatedPluginInfoBarDelegate::GetMessageText() const { 237 string16 OutdatedPluginInfoBarDelegate::GetMessageText() const {
248 return l10n_util::GetStringFUTF16(IDS_PLUGIN_OUTDATED_PROMPT, name_); 238 return l10n_util::GetStringFUTF16(IDS_PLUGIN_OUTDATED_PROMPT, name_);
249 } 239 }
250 240
(...skipping 14 matching lines...) Expand all
265 UserMetrics::RecordAction( 255 UserMetrics::RecordAction(
266 UserMetricsAction("OutdatedPluginInfobar.AllowThisTime")); 256 UserMetricsAction("OutdatedPluginInfobar.AllowThisTime"));
267 return PluginInfoBarDelegate::Cancel(); 257 return PluginInfoBarDelegate::Cancel();
268 } 258 }
269 259
270 void OutdatedPluginInfoBarDelegate::InfoBarDismissed() { 260 void OutdatedPluginInfoBarDelegate::InfoBarDismissed() {
271 UserMetrics::RecordAction( 261 UserMetrics::RecordAction(
272 UserMetricsAction("OutdatedPluginInfobar.Dismissed")); 262 UserMetricsAction("OutdatedPluginInfobar.Dismissed"));
273 } 263 }
274 264
275 void OutdatedPluginInfoBarDelegate::InfoBarClosed() {
276 UserMetrics::RecordAction(UserMetricsAction("OutdatedPluginInfobar.Closed"));
277 PluginInfoBarDelegate::InfoBarClosed();
278 }
279
280 bool OutdatedPluginInfoBarDelegate::LinkClicked( 265 bool OutdatedPluginInfoBarDelegate::LinkClicked(
281 WindowOpenDisposition disposition) { 266 WindowOpenDisposition disposition) {
282 UserMetrics::RecordAction( 267 UserMetrics::RecordAction(
283 UserMetricsAction("OutdatedPluginInfobar.LearnMore")); 268 UserMetricsAction("OutdatedPluginInfobar.LearnMore"));
284 return PluginInfoBarDelegate::LinkClicked(disposition); 269 return PluginInfoBarDelegate::LinkClicked(disposition);
285 } 270 }
286 271
287 } // namespace 272 } // namespace
288 273
289 274
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
360 true)); 345 true));
361 } 346 }
362 347
363 void PluginObserver::OnBlockedOutdatedPlugin(const string16& name, 348 void PluginObserver::OnBlockedOutdatedPlugin(const string16& name,
364 const GURL& update_url) { 349 const GURL& update_url) {
365 tab_contents()->AddInfoBar(update_url.is_empty() ? 350 tab_contents()->AddInfoBar(update_url.is_empty() ?
366 static_cast<InfoBarDelegate*>(new BlockedPluginInfoBarDelegate( 351 static_cast<InfoBarDelegate*>(new BlockedPluginInfoBarDelegate(
367 tab_contents(), name)) : 352 tab_contents(), name)) :
368 new OutdatedPluginInfoBarDelegate(tab_contents(), name, update_url)); 353 new OutdatedPluginInfoBarDelegate(tab_contents(), name, update_url));
369 } 354 }
OLDNEW
« no previous file with comments | « chrome/browser/plugin_installer_infobar_delegate.h ('k') | chrome/browser/tab_contents/infobar_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698