OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/renderer/translate_helper.h" | 5 #include "chrome/renderer/translate_helper.h" |
6 | 6 |
7 #include "base/compiler_specific.h" | 7 #include "base/compiler_specific.h" |
8 #include "chrome/renderer/render_view.h" | 8 #include "chrome/renderer/render_view.h" |
9 #include "third_party/WebKit/WebKit/chromium/public/WebFrame.h" | 9 #include "third_party/WebKit/WebKit/chromium/public/WebFrame.h" |
10 #include "third_party/WebKit/WebKit/chromium/public/WebScriptSource.h" | 10 #include "third_party/WebKit/WebKit/chromium/public/WebScriptSource.h" |
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
189 actual_source_lang = source_lang_; | 189 actual_source_lang = source_lang_; |
190 } | 190 } |
191 | 191 |
192 if (!translation_pending_) { | 192 if (!translation_pending_) { |
193 NOTREACHED(); | 193 NOTREACHED(); |
194 return; | 194 return; |
195 } | 195 } |
196 | 196 |
197 translation_pending_ = false; | 197 translation_pending_ = false; |
198 | 198 |
| 199 // Notify the renderer we are done. |
| 200 render_view_->OnPageTranslated(); |
| 201 |
199 // Notify the browser we are done. | 202 // Notify the browser we are done. |
200 render_view_->Send(new ViewHostMsg_PageTranslated( | 203 render_view_->Send(new ViewHostMsg_PageTranslated( |
201 render_view_->routing_id(), render_view_->page_id(), | 204 render_view_->routing_id(), render_view_->page_id(), |
202 actual_source_lang, target_lang_, TranslateErrors::NONE)); | 205 actual_source_lang, target_lang_, TranslateErrors::NONE)); |
203 return; | 206 return; |
204 } | 207 } |
205 | 208 |
206 // The translation is still pending, check again later. | 209 // The translation is still pending, check again later. |
207 MessageLoop::current()->PostDelayedTask(FROM_HERE, | 210 MessageLoop::current()->PostDelayedTask(FROM_HERE, |
208 method_factory_.NewRunnableMethod(&TranslateHelper::CheckTranslateStatus), | 211 method_factory_.NewRunnableMethod(&TranslateHelper::CheckTranslateStatus), |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
282 DontDelayTasks() ? 0 : kTranslateStatusCheckDelayMs); | 285 DontDelayTasks() ? 0 : kTranslateStatusCheckDelayMs); |
283 } | 286 } |
284 | 287 |
285 void TranslateHelper::NotifyBrowserTranslationFailed( | 288 void TranslateHelper::NotifyBrowserTranslationFailed( |
286 TranslateErrors::Type error) { | 289 TranslateErrors::Type error) { |
287 translation_pending_ = false; | 290 translation_pending_ = false; |
288 // Notify the browser there was an error. | 291 // Notify the browser there was an error. |
289 render_view_->Send(new ViewHostMsg_PageTranslated( | 292 render_view_->Send(new ViewHostMsg_PageTranslated( |
290 render_view_->routing_id(), page_id_, source_lang_, target_lang_, error)); | 293 render_view_->routing_id(), page_id_, source_lang_, target_lang_, error)); |
291 } | 294 } |
OLD | NEW |