summaryrefslogtreecommitdiffstats
path: root/chrome/renderer/extensions
diff options
context:
space:
mode:
authoraa@chromium.org <aa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-11-25 02:03:22 +0000
committeraa@chromium.org <aa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-11-25 02:03:22 +0000
commit6776c72f56c29972bfd47efc1a1cf1629e3c7da2 (patch)
tree3d3fe194ce17e16ae5c5a971892505e8d42b918a /chrome/renderer/extensions
parent4a2029f4f6998d628a98070ee7e2c1f14230eb82 (diff)
downloadchromium_src-6776c72f56c29972bfd47efc1a1cf1629e3c7da2.zip
chromium_src-6776c72f56c29972bfd47efc1a1cf1629e3c7da2.tar.gz
chromium_src-6776c72f56c29972bfd47efc1a1cf1629e3c7da2.tar.bz2
Stab-in-the-dark at fixing a top crasher.
GetCurrentRenderView() can actually return NULL, which means that GetExtensionIdForCurrentContext() can also return empty string. Hillarity ensues. BUG=28487 Review URL: http://codereview.chromium.org/441005 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@33034 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/renderer/extensions')
-rw-r--r--chrome/renderer/extensions/extension_process_bindings.cc32
1 files changed, 23 insertions, 9 deletions
diff --git a/chrome/renderer/extensions/extension_process_bindings.cc b/chrome/renderer/extensions/extension_process_bindings.cc
index e3cfe0a..98b45f1 100644
--- a/chrome/renderer/extensions/extension_process_bindings.cc
+++ b/chrome/renderer/extensions/extension_process_bindings.cc
@@ -204,11 +204,14 @@ class ExtensionImpl : public ExtensionBase {
// be an extension URL.
static std::string ExtensionIdForCurrentContext() {
RenderView* renderview = bindings_utils::GetRenderViewForCurrentContext();
- DCHECK(renderview);
+ if (!renderview)
+ return std::string(); // this can happen as a tab is closing.
+
GURL url = renderview->webview()->mainFrame()->url();
- if (url.SchemeIs(chrome::kExtensionScheme))
- return url.host();
- return std::string();
+ if (!url.SchemeIs(chrome::kExtensionScheme))
+ return std::string();
+
+ return url.host();
}
virtual v8::Handle<v8::FunctionTemplate> GetNativeFunction(
@@ -272,7 +275,11 @@ class ExtensionImpl : public ExtensionBase {
}
int browser_window_id = render_view->browser_window_id();
- ExtensionViewAccumulator popup_matcher(ExtensionIdForCurrentContext(),
+ std::string extension_id = ExtensionIdForCurrentContext();
+ if (extension_id.empty())
+ return v8::Undefined();
+
+ ExtensionViewAccumulator popup_matcher(extension_id,
browser_window_id,
viewtype_to_find);
RenderView::ForEach(&popup_matcher);
@@ -321,8 +328,12 @@ class ExtensionImpl : public ExtensionBase {
return v8::Undefined();
}
- ExtensionViewAccumulator accumulator(
- ExtensionIdForCurrentContext(), browser_window_id, view_type);
+ std::string extension_id = ExtensionIdForCurrentContext();
+ if (extension_id.empty())
+ return v8::Undefined();
+
+ ExtensionViewAccumulator accumulator(extension_id, browser_window_id,
+ view_type);
RenderView::ForEach(&accumulator);
return accumulator.views();
}
@@ -383,8 +394,11 @@ class ExtensionImpl : public ExtensionBase {
return v8::Undefined();
}
- L10nMessagesMap* l10n_messages =
- GetL10nMessagesMap(ExtensionIdForCurrentContext());
+ std::string extension_id = ExtensionIdForCurrentContext();
+ if (extension_id.empty())
+ return v8::Undefined();
+
+ L10nMessagesMap* l10n_messages = GetL10nMessagesMap(extension_id);
if (!l10n_messages)
return v8::Undefined();