summaryrefslogtreecommitdiffstats
path: root/chrome/browser/extensions/crashed_extension_infobar.cc
diff options
context:
space:
mode:
authorphajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-08-11 00:27:14 +0000
committerphajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-08-11 00:27:14 +0000
commitdaba9ebc9d294a645e5569617628a73289755311 (patch)
tree8b7fb3ece5914eb11ad48226039271192c667d62 /chrome/browser/extensions/crashed_extension_infobar.cc
parentca7bf5806cf02793cbd756b7138cd766cc2caf28 (diff)
downloadchromium_src-daba9ebc9d294a645e5569617628a73289755311.zip
chromium_src-daba9ebc9d294a645e5569617628a73289755311.tar.gz
chromium_src-daba9ebc9d294a645e5569617628a73289755311.tar.bz2
Fix "crashed extension" infobar browser crashes.
This is a general rework of how "crashed extension" infobar works and how the extension is actually recovered after the crash. TEST=See bug. http://crbug.com/15888 Review URL: http://codereview.chromium.org/164151 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@22985 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/extensions/crashed_extension_infobar.cc')
-rw-r--r--chrome/browser/extensions/crashed_extension_infobar.cc56
1 files changed, 56 insertions, 0 deletions
diff --git a/chrome/browser/extensions/crashed_extension_infobar.cc b/chrome/browser/extensions/crashed_extension_infobar.cc
new file mode 100644
index 0000000..80ab865
--- /dev/null
+++ b/chrome/browser/extensions/crashed_extension_infobar.cc
@@ -0,0 +1,56 @@
+// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/extensions/crashed_extension_infobar.h"
+
+#include "app/l10n_util.h"
+#include "app/resource_bundle.h"
+#include "chrome/browser/extensions/extensions_service.h"
+#include "chrome/common/extensions/extension.h"
+#include "grit/browser_resources.h"
+#include "grit/generated_resources.h"
+#include "grit/theme_resources.h"
+
+CrashedExtensionInfoBarDelegate::CrashedExtensionInfoBarDelegate(
+ TabContents* tab_contents,
+ ExtensionsService* extensions_service,
+ const Extension* extension)
+ : ConfirmInfoBarDelegate(tab_contents),
+ extensions_service_(extensions_service),
+ extension_id_(extension->id()),
+ extension_name_(extension->name()) {
+ DCHECK(extensions_service_);
+ DCHECK(!extension_id_.empty());
+}
+
+std::wstring CrashedExtensionInfoBarDelegate::GetMessageText() const {
+ return l10n_util::GetStringF(IDS_EXTENSION_CRASHED_INFOBAR_MESSAGE,
+ UTF8ToWide(extension_name_));
+}
+
+void CrashedExtensionInfoBarDelegate::InfoBarClosed() {
+ delete this;
+}
+
+SkBitmap* CrashedExtensionInfoBarDelegate::GetIcon() const {
+ // TODO(erikkay): Create extension-specific icon. http://crbug.com/14591
+ return ResourceBundle::GetSharedInstance().GetBitmapNamed(
+ IDR_INFOBAR_PLUGIN_CRASHED);
+}
+
+int CrashedExtensionInfoBarDelegate::GetButtons() const {
+ return BUTTON_OK;
+}
+
+std::wstring CrashedExtensionInfoBarDelegate::GetButtonLabel(
+ ConfirmInfoBarDelegate::InfoBarButton button) const {
+ if (button == BUTTON_OK)
+ return l10n_util::GetString(IDS_EXTENSION_CRASHED_INFOBAR_RESTART_BUTTON);
+ return ConfirmInfoBarDelegate::GetButtonLabel(button);
+}
+
+bool CrashedExtensionInfoBarDelegate::Accept() {
+ extensions_service_->ReloadExtension(extension_id_);
+ return true;
+}