| 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 #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/files/file_path.h" | 8 #include "base/files/file_path.h" |
| 9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "base/process.h" | 10 #include "base/process.h" |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 141 const string16& plugin_name); | 141 const string16& plugin_name); |
| 142 | 142 |
| 143 private: | 143 private: |
| 144 HungPluginInfoBarDelegate(HungPluginTabHelper* helper, | 144 HungPluginInfoBarDelegate(HungPluginTabHelper* helper, |
| 145 InfoBarService* infobar_service, | 145 InfoBarService* infobar_service, |
| 146 int plugin_child_id, | 146 int plugin_child_id, |
| 147 const string16& plugin_name); | 147 const string16& plugin_name); |
| 148 virtual ~HungPluginInfoBarDelegate(); | 148 virtual ~HungPluginInfoBarDelegate(); |
| 149 | 149 |
| 150 // ConfirmInfoBarDelegate: | 150 // ConfirmInfoBarDelegate: |
| 151 virtual gfx::Image* GetIcon() const OVERRIDE; | 151 virtual int GetIconID() const OVERRIDE; |
| 152 virtual string16 GetMessageText() const OVERRIDE; | 152 virtual string16 GetMessageText() const OVERRIDE; |
| 153 virtual int GetButtons() const OVERRIDE; | 153 virtual int GetButtons() const OVERRIDE; |
| 154 virtual string16 GetButtonLabel(InfoBarButton button) const OVERRIDE; | 154 virtual string16 GetButtonLabel(InfoBarButton button) const OVERRIDE; |
| 155 virtual bool Accept() OVERRIDE; | 155 virtual bool Accept() OVERRIDE; |
| 156 | 156 |
| 157 HungPluginTabHelper* helper_; | 157 HungPluginTabHelper* helper_; |
| 158 int plugin_child_id_; | 158 int plugin_child_id_; |
| 159 | 159 |
| 160 string16 message_; | 160 string16 message_; |
| 161 string16 button_text_; | 161 string16 button_text_; |
| 162 gfx::Image* icon_; | |
| 163 }; | 162 }; |
| 164 | 163 |
| 165 // static | 164 // static |
| 166 HungPluginInfoBarDelegate* HungPluginInfoBarDelegate::Create( | 165 HungPluginInfoBarDelegate* HungPluginInfoBarDelegate::Create( |
| 167 InfoBarService* infobar_service, | 166 InfoBarService* infobar_service, |
| 168 HungPluginTabHelper* helper, | 167 HungPluginTabHelper* helper, |
| 169 int plugin_child_id, | 168 int plugin_child_id, |
| 170 const string16& plugin_name) { | 169 const string16& plugin_name) { |
| 171 return static_cast<HungPluginInfoBarDelegate*>(infobar_service->AddInfoBar( | 170 return static_cast<HungPluginInfoBarDelegate*>(infobar_service->AddInfoBar( |
| 172 scoped_ptr<InfoBarDelegate>(new HungPluginInfoBarDelegate( | 171 scoped_ptr<InfoBarDelegate>(new HungPluginInfoBarDelegate( |
| 173 helper, infobar_service, plugin_child_id, plugin_name)))); | 172 helper, infobar_service, plugin_child_id, plugin_name)))); |
| 174 } | 173 } |
| 175 | 174 |
| 176 HungPluginInfoBarDelegate::HungPluginInfoBarDelegate( | 175 HungPluginInfoBarDelegate::HungPluginInfoBarDelegate( |
| 177 HungPluginTabHelper* helper, | 176 HungPluginTabHelper* helper, |
| 178 InfoBarService* infobar_service, | 177 InfoBarService* infobar_service, |
| 179 int plugin_child_id, | 178 int plugin_child_id, |
| 180 const string16& plugin_name) | 179 const string16& plugin_name) |
| 181 : ConfirmInfoBarDelegate(infobar_service), | 180 : ConfirmInfoBarDelegate(infobar_service), |
| 182 helper_(helper), | 181 helper_(helper), |
| 183 plugin_child_id_(plugin_child_id) { | 182 plugin_child_id_(plugin_child_id) { |
| 184 message_ = l10n_util::GetStringFUTF16(IDS_BROWSER_HANGMONITOR_PLUGIN_INFOBAR, | 183 message_ = l10n_util::GetStringFUTF16(IDS_BROWSER_HANGMONITOR_PLUGIN_INFOBAR, |
| 185 plugin_name); | 184 plugin_name); |
| 186 button_text_ = l10n_util::GetStringUTF16( | 185 button_text_ = l10n_util::GetStringUTF16( |
| 187 IDS_BROWSER_HANGMONITOR_PLUGIN_INFOBAR_KILLBUTTON); | 186 IDS_BROWSER_HANGMONITOR_PLUGIN_INFOBAR_KILLBUTTON); |
| 188 icon_ = &ResourceBundle::GetSharedInstance().GetNativeImageNamed( | |
| 189 IDR_INFOBAR_PLUGIN_CRASHED); | |
| 190 } | 187 } |
| 191 | 188 |
| 192 HungPluginInfoBarDelegate::~HungPluginInfoBarDelegate() { | 189 HungPluginInfoBarDelegate::~HungPluginInfoBarDelegate() { |
| 193 } | 190 } |
| 194 | 191 |
| 195 gfx::Image* HungPluginInfoBarDelegate::GetIcon() const { | 192 int HungPluginInfoBarDelegate::GetIconID() const { |
| 196 return icon_; | 193 return IDR_INFOBAR_PLUGIN_CRASHED; |
| 197 } | 194 } |
| 198 | 195 |
| 199 string16 HungPluginInfoBarDelegate::GetMessageText() const { | 196 string16 HungPluginInfoBarDelegate::GetMessageText() const { |
| 200 return message_; | 197 return message_; |
| 201 } | 198 } |
| 202 | 199 |
| 203 int HungPluginInfoBarDelegate::GetButtons() const { | 200 int HungPluginInfoBarDelegate::GetButtons() const { |
| 204 return BUTTON_OK; | 201 return BUTTON_OK; |
| 205 } | 202 } |
| 206 | 203 |
| (...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 439 InfoBarService* infobar_service = | 436 InfoBarService* infobar_service = |
| 440 InfoBarService::FromWebContents(web_contents()); | 437 InfoBarService::FromWebContents(web_contents()); |
| 441 if (!infobar_service) | 438 if (!infobar_service) |
| 442 return; | 439 return; |
| 443 | 440 |
| 444 if (state->info_bar) { | 441 if (state->info_bar) { |
| 445 infobar_service->RemoveInfoBar(state->info_bar); | 442 infobar_service->RemoveInfoBar(state->info_bar); |
| 446 state->info_bar = NULL; | 443 state->info_bar = NULL; |
| 447 } | 444 } |
| 448 } | 445 } |
| OLD | NEW |