summaryrefslogtreecommitdiffstats
path: root/chrome/renderer/translate_helper.cc
diff options
context:
space:
mode:
authorjcivelli@chromium.org <jcivelli@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-06-16 00:09:13 +0000
committerjcivelli@chromium.org <jcivelli@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-06-16 00:09:13 +0000
commit7faa5386330c0de8fbd5cde8e0daea2e810ec0a6 (patch)
tree997132106b735c53f79ad225fb30b76b9e5f4c27 /chrome/renderer/translate_helper.cc
parent5c1304300d3cdeecb75aa85f0c207d65e0cbf6cf (diff)
downloadchromium_src-7faa5386330c0de8fbd5cde8e0daea2e810ec0a6.zip
chromium_src-7faa5386330c0de8fbd5cde8e0daea2e810ec0a6.tar.gz
chromium_src-7faa5386330c0de8fbd5cde8e0daea2e810ec0a6.tar.bz2
Fix for a translate related crasher.
When a page was closed, a pending task on the TranslationHelper was accessing the WebView that would be NULL. BUG=46584 TEST=None Review URL: http://codereview.chromium.org/2852005 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@49863 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/renderer/translate_helper.cc')
-rw-r--r--chrome/renderer/translate_helper.cc20
1 files changed, 16 insertions, 4 deletions
diff --git a/chrome/renderer/translate_helper.cc b/chrome/renderer/translate_helper.cc
index 1fea5b7..7caeec4 100644
--- a/chrome/renderer/translate_helper.cc
+++ b/chrome/renderer/translate_helper.cc
@@ -81,7 +81,7 @@ void TranslateHelper::RevertTranslation(int page_id) {
return;
}
- WebFrame* main_frame = render_view_->webview()->mainFrame();
+ WebFrame* main_frame = GetMainFrame();
if (!main_frame)
return;
@@ -213,7 +213,7 @@ void TranslateHelper::CheckTranslateStatus() {
}
bool TranslateHelper::ExecuteScript(const std::string& script) {
- WebFrame* main_frame = render_view_->webview()->mainFrame();
+ WebFrame* main_frame = GetMainFrame();
if (!main_frame)
return false;
main_frame->executeScript(WebScriptSource(ASCIIToUTF16(script)));
@@ -223,7 +223,7 @@ bool TranslateHelper::ExecuteScript(const std::string& script) {
bool TranslateHelper::ExecuteScriptAndGetBoolResult(const std::string& script,
bool* value) {
DCHECK(value);
- WebFrame* main_frame = render_view_->webview()->mainFrame();
+ WebFrame* main_frame = GetMainFrame();
if (!main_frame)
return false;
@@ -239,7 +239,7 @@ bool TranslateHelper::ExecuteScriptAndGetBoolResult(const std::string& script,
bool TranslateHelper::ExecuteScriptAndGetStringResult(const std::string& script,
std::string* value) {
DCHECK(value);
- WebFrame* main_frame = render_view_->webview()->mainFrame();
+ WebFrame* main_frame = GetMainFrame();
if (!main_frame)
return false;
@@ -292,3 +292,15 @@ void TranslateHelper::NotifyBrowserTranslationFailed(
render_view_->Send(new ViewHostMsg_PageTranslated(
render_view_->routing_id(), page_id_, source_lang_, target_lang_, error));
}
+
+WebFrame* TranslateHelper::GetMainFrame() {
+ WebKit::WebView* web_view = render_view_->webview();
+ if (!web_view) {
+ // When the WebView is going away, the render view should have called
+ // CancelPendingTranslation() which should have stopped any pending work, so
+ // that case should not happen.
+ NOTREACHED();
+ return NULL;
+ }
+ return web_view->mainFrame();
+}