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

Unified Diff: chrome/browser/extensions/extension_host.cc

Issue 126289: Graceful handling of extension process crashes (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: '' Created 11 years, 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/extensions/extension_host.h ('k') | chrome/browser/extensions/extension_process_manager.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/extensions/extension_host.cc
===================================================================
--- chrome/browser/extensions/extension_host.cc (revision 18701)
+++ chrome/browser/extensions/extension_host.cc (working copy)
@@ -4,7 +4,9 @@
#include "chrome/browser/extensions/extension_host.h"
+#include "app/l10n_util.h"
#include "app/resource_bundle.h"
+#include "base/string_util.h"
#include "chrome/browser/browser.h"
#include "chrome/browser/browser_list.h"
#include "chrome/browser/browser_process.h"
@@ -16,6 +18,7 @@
#include "chrome/browser/renderer_host/render_process_host.h"
#include "chrome/browser/renderer_host/render_widget_host.h"
#include "chrome/browser/renderer_host/render_widget_host_view.h"
+#include "chrome/browser/tab_contents/infobar_delegate.h"
#include "chrome/browser/tab_contents/site_instance.h"
#include "chrome/browser/tab_contents/tab_contents.h"
#include "chrome/browser/tab_contents/tab_contents_view.h"
@@ -25,9 +28,55 @@
#include "grit/browser_resources.h"
#include "grit/generated_resources.h"
+#include "grit/theme_resources.h"
#include "webkit/glue/context_menu.h"
+namespace {
+
+class CrashedExtensionInfobarDelegate : public ConfirmInfoBarDelegate {
+ public:
+ CrashedExtensionInfobarDelegate(TabContents* tab_contents,
+ ExtensionHost* extension_host)
+ : ConfirmInfoBarDelegate(tab_contents),
+ extension_host_(extension_host) {
+ }
+
+ virtual std::wstring GetMessageText() const {
+ return l10n_util::GetStringF(IDS_EXTENSION_CRASHED_INFOBAR_MESSAGE,
+ UTF8ToWide(extension_host_->extension()->name()));
+ }
+
+ virtual SkBitmap* GetIcon() const {
+ // TODO(erikkay): Create extension-specific icon. http://crbug.com/14591
+ return ResourceBundle::GetSharedInstance().GetBitmapNamed(
+ IDR_INFOBAR_PLUGIN_CRASHED);
+ }
+
+ virtual int GetButtons() const {
+ return BUTTON_OK;
+ }
+
+ virtual std::wstring GetButtonLabel(
+ ConfirmInfoBarDelegate::InfoBarButton button) const {
+ if (button == BUTTON_OK)
+ return l10n_util::GetString(IDS_EXTENSION_CRASHED_INFOBAR_RESTART_BUTTON);
+ return ConfirmInfoBarDelegate::GetButtonLabel(button);
+ }
+
+ virtual bool Accept() {
+ extension_host_->RecoverCrashedExtension();
+ return true;
+ }
+
+ private:
+ ExtensionHost* extension_host_;
+
+ DISALLOW_COPY_AND_ASSIGN(CrashedExtensionInfobarDelegate);
+};
+
+} // namespace
+
ExtensionHost::ExtensionHost(Extension* extension, SiteInstance* site_instance,
const GURL& url, ExtensionProcessManager* manager)
: extension_(extension),
@@ -65,12 +114,25 @@
return render_view_host_->site_instance();
}
+bool ExtensionHost::IsRenderViewLive() const {
+ return render_view_host_->IsRenderViewLive();
+}
+
void ExtensionHost::CreateRenderView(RenderWidgetHostView* host_view) {
render_view_host_->set_view(host_view);
render_view_host_->CreateRenderView();
render_view_host_->NavigateToURL(url_);
}
+void ExtensionHost::RecoverCrashedExtension() {
+ DCHECK(!IsRenderViewLive());
+#if defined(TOOLKIT_VIEWS)
+ view_->RecoverCrashedExtension();
+#endif
+ if (IsRenderViewLive())
+ manager_->OnExtensionProcessRestored(this);
+}
+
void ExtensionHost::UpdatePreferredWidth(int pref_width) {
#if defined(OS_WIN)
if (view_.get())
@@ -78,6 +140,17 @@
#endif
}
+void ExtensionHost::RenderViewGone(RenderViewHost* render_view_host) {
+ DCHECK_EQ(render_view_host_, render_view_host);
+ TabContents* current_tab = GetBrowser()->GetSelectedTabContents();
+ DCHECK(current_tab);
+ if (current_tab) {
+ current_tab->AddInfoBar(
+ new CrashedExtensionInfobarDelegate(current_tab, this));
+ }
+ manager_->OnExtensionProcessCrashed(this);
+}
+
WebPreferences ExtensionHost::GetWebkitPrefs() {
PrefService* prefs = render_view_host()->process()->profile()->GetPrefs();
const bool kIsDomUI = true;
« no previous file with comments | « chrome/browser/extensions/extension_host.h ('k') | chrome/browser/extensions/extension_process_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698