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

Side by Side Diff: chrome/browser/ui/hung_plugin_tab_helper.cc

Issue 11748027: Rename HungPluginTabHelper::InfoBarDelegate to HungPluginInfoBarDelegate for consistency with other… (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
« no previous file with comments | « chrome/browser/ui/hung_plugin_tab_helper.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #include "chrome/browser/ui/hung_plugin_tab_helper.h" 5 #include "chrome/browser/ui/hung_plugin_tab_helper.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "base/process.h" 9 #include "base/process.h"
10 #include "base/process_util.h" 10 #include "base/process_util.h"
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 break; 115 break;
116 } 116 }
117 ++iter; 117 ++iter;
118 } 118 }
119 // Ignore the case where we didn't find the plugin, it may have terminated 119 // Ignore the case where we didn't find the plugin, it may have terminated
120 // before this function could run. 120 // before this function could run.
121 } 121 }
122 122
123 } // namespace 123 } // namespace
124 124
125 class HungPluginTabHelper::InfoBarDelegate : public ConfirmInfoBarDelegate { 125 class HungPluginInfoBarDelegate : public ConfirmInfoBarDelegate {
126 public: 126 public:
127 InfoBarDelegate(HungPluginTabHelper* helper, 127 HungPluginInfoBarDelegate(HungPluginTabHelper* helper,
128 InfoBarService* infobar_service, 128 InfoBarService* infobar_service,
129 int plugin_child_id, 129 int plugin_child_id,
130 const string16& plugin_name); 130 const string16& plugin_name);
131 virtual ~InfoBarDelegate(); 131 virtual ~HungPluginInfoBarDelegate();
132 132
133 // ConfirmInfoBarDelegate: 133 // ConfirmInfoBarDelegate:
134 virtual gfx::Image* GetIcon() const OVERRIDE; 134 virtual gfx::Image* GetIcon() const OVERRIDE;
135 virtual string16 GetMessageText() const OVERRIDE; 135 virtual string16 GetMessageText() const OVERRIDE;
136 virtual int GetButtons() const OVERRIDE; 136 virtual int GetButtons() const OVERRIDE;
137 virtual string16 GetButtonLabel(InfoBarButton button) const OVERRIDE; 137 virtual string16 GetButtonLabel(InfoBarButton button) const OVERRIDE;
138 virtual bool Accept() OVERRIDE; 138 virtual bool Accept() OVERRIDE;
139 139
140 private: 140 private:
141 HungPluginTabHelper* helper_; 141 HungPluginTabHelper* helper_;
142 int plugin_child_id_; 142 int plugin_child_id_;
143 143
144 string16 message_; 144 string16 message_;
145 string16 button_text_; 145 string16 button_text_;
146 gfx::Image* icon_; 146 gfx::Image* icon_;
147 }; 147 };
148 148
149 HungPluginTabHelper::InfoBarDelegate::InfoBarDelegate( 149 HungPluginInfoBarDelegate::HungPluginInfoBarDelegate(
150 HungPluginTabHelper* helper, 150 HungPluginTabHelper* helper,
151 InfoBarService* infobar_service, 151 InfoBarService* infobar_service,
152 int plugin_child_id, 152 int plugin_child_id,
153 const string16& plugin_name) 153 const string16& plugin_name)
154 : ConfirmInfoBarDelegate(infobar_service), 154 : ConfirmInfoBarDelegate(infobar_service),
155 helper_(helper), 155 helper_(helper),
156 plugin_child_id_(plugin_child_id) { 156 plugin_child_id_(plugin_child_id) {
157 message_ = l10n_util::GetStringFUTF16(IDS_BROWSER_HANGMONITOR_PLUGIN_INFOBAR, 157 message_ = l10n_util::GetStringFUTF16(IDS_BROWSER_HANGMONITOR_PLUGIN_INFOBAR,
158 plugin_name); 158 plugin_name);
159 button_text_ = l10n_util::GetStringUTF16( 159 button_text_ = l10n_util::GetStringUTF16(
160 IDS_BROWSER_HANGMONITOR_PLUGIN_INFOBAR_KILLBUTTON); 160 IDS_BROWSER_HANGMONITOR_PLUGIN_INFOBAR_KILLBUTTON);
161 icon_ = &ResourceBundle::GetSharedInstance().GetNativeImageNamed( 161 icon_ = &ResourceBundle::GetSharedInstance().GetNativeImageNamed(
162 IDR_INFOBAR_PLUGIN_CRASHED); 162 IDR_INFOBAR_PLUGIN_CRASHED);
163 } 163 }
164 164
165 HungPluginTabHelper::InfoBarDelegate::~InfoBarDelegate() { 165 HungPluginInfoBarDelegate::~HungPluginInfoBarDelegate() {
166 } 166 }
167 167
168 gfx::Image* HungPluginTabHelper::InfoBarDelegate::GetIcon() const { 168 gfx::Image* HungPluginInfoBarDelegate::GetIcon() const {
169 return icon_; 169 return icon_;
170 } 170 }
171 171
172 string16 HungPluginTabHelper::InfoBarDelegate::GetMessageText() const { 172 string16 HungPluginInfoBarDelegate::GetMessageText() const {
173 return message_; 173 return message_;
174 } 174 }
175 175
176 int HungPluginTabHelper::InfoBarDelegate::GetButtons() const { 176 int HungPluginInfoBarDelegate::GetButtons() const {
177 return BUTTON_OK; 177 return BUTTON_OK;
178 } 178 }
179 179
180 string16 HungPluginTabHelper::InfoBarDelegate::GetButtonLabel( 180 string16 HungPluginInfoBarDelegate::GetButtonLabel(InfoBarButton button) const {
181 InfoBarButton button) const {
182 return button_text_; 181 return button_text_;
183 } 182 }
184 183
185 bool HungPluginTabHelper::InfoBarDelegate::Accept() { 184 bool HungPluginInfoBarDelegate::Accept() {
186 helper_->KillPlugin(plugin_child_id_); 185 helper_->KillPlugin(plugin_child_id_);
187 return true; 186 return true;
188 } 187 }
189 188
190 // ----------------------------------------------------------------------------- 189 // -----------------------------------------------------------------------------
191 190
192 HungPluginTabHelper::PluginState::PluginState(const FilePath& p, 191 HungPluginTabHelper::PluginState::PluginState(const FilePath& p,
193 const string16& n) 192 const string16& n)
194 : path(p), 193 : path(p),
195 name(n), 194 name(n),
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
267 const content::NotificationSource& source, 266 const content::NotificationSource& source,
268 const content::NotificationDetails& details) { 267 const content::NotificationDetails& details) {
269 DCHECK_EQ(chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_REMOVED, type); 268 DCHECK_EQ(chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_REMOVED, type);
270 269
271 // Note: do not dereference. The InfoBarContainer will delete the object when 270 // Note: do not dereference. The InfoBarContainer will delete the object when
272 // it gets this notification, we only remove our tracking info, if we have 271 // it gets this notification, we only remove our tracking info, if we have
273 // any. 272 // any.
274 // 273 //
275 // TODO(pkasting): This comment will be incorrect and should be removed once 274 // TODO(pkasting): This comment will be incorrect and should be removed once
276 // InfoBars own their delegates. 275 // InfoBars own their delegates.
277 ::InfoBarDelegate* delegate = 276 InfoBarDelegate* delegate =
278 content::Details<InfoBarRemovedDetails>(details)->first; 277 content::Details<InfoBarRemovedDetails>(details)->first;
279 278
280 for (PluginStateMap::iterator i = hung_plugins_.begin(); 279 for (PluginStateMap::iterator i = hung_plugins_.begin();
281 i != hung_plugins_.end(); ++i) { 280 i != hung_plugins_.end(); ++i) {
282 PluginState* state = i->second.get(); 281 PluginState* state = i->second.get();
283 if (state->info_bar == delegate) { 282 if (state->info_bar == delegate) {
284 state->info_bar = NULL; 283 state->info_bar = NULL;
285 284
286 // Schedule the timer to re-show the infobar if the plugin continues to be 285 // Schedule the timer to re-show the infobar if the plugin continues to be
287 // hung. 286 // hung.
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
356 ShowBar(child_id, found->second.get()); 355 ShowBar(child_id, found->second.get());
357 } 356 }
358 357
359 void HungPluginTabHelper::ShowBar(int child_id, PluginState* state) { 358 void HungPluginTabHelper::ShowBar(int child_id, PluginState* state) {
360 InfoBarService* infobar_service = 359 InfoBarService* infobar_service =
361 InfoBarService::FromWebContents(web_contents()); 360 InfoBarService::FromWebContents(web_contents());
362 if (!infobar_service) 361 if (!infobar_service)
363 return; 362 return;
364 363
365 DCHECK(!state->info_bar); 364 DCHECK(!state->info_bar);
366 state->info_bar = new InfoBarDelegate(this, infobar_service, 365 state->info_bar = new HungPluginInfoBarDelegate(this, infobar_service,
367 child_id, state->name); 366 child_id, state->name);
368 infobar_service->AddInfoBar(state->info_bar); 367 infobar_service->AddInfoBar(state->info_bar);
369 } 368 }
370 369
371 void HungPluginTabHelper::CloseBar(PluginState* state) { 370 void HungPluginTabHelper::CloseBar(PluginState* state) {
372 InfoBarService* infobar_service = 371 InfoBarService* infobar_service =
373 InfoBarService::FromWebContents(web_contents()); 372 InfoBarService::FromWebContents(web_contents());
374 if (!infobar_service) 373 if (!infobar_service)
375 return; 374 return;
376 375
377 if (state->info_bar) { 376 if (state->info_bar) {
378 infobar_service->RemoveInfoBar(state->info_bar); 377 infobar_service->RemoveInfoBar(state->info_bar);
379 state->info_bar = NULL; 378 state->info_bar = NULL;
380 } 379 }
381 } 380 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/hung_plugin_tab_helper.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698