OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/translate_helper.h" | 5 #include "chrome/renderer/translate/translate_helper.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
(...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
384 } | 384 } |
385 | 385 |
386 void TranslateHelper::CheckTranslateStatus() { | 386 void TranslateHelper::CheckTranslateStatus() { |
387 // If this is not the same page, the translation has been canceled. If the | 387 // If this is not the same page, the translation has been canceled. If the |
388 // view is gone, the page is closing. | 388 // view is gone, the page is closing. |
389 if (page_id_ != render_view()->GetPageId() || !render_view()->GetWebView()) | 389 if (page_id_ != render_view()->GetPageId() || !render_view()->GetWebView()) |
390 return; | 390 return; |
391 | 391 |
392 // First check if there was an error. | 392 // First check if there was an error. |
393 if (HasTranslationFailed()) { | 393 if (HasTranslationFailed()) { |
| 394 // TODO(toyoshim): Check |errorCode| of translate.js and notify it here. |
394 NotifyBrowserTranslationFailed(TranslateErrors::TRANSLATION_ERROR); | 395 NotifyBrowserTranslationFailed(TranslateErrors::TRANSLATION_ERROR); |
395 return; // There was an error. | 396 return; // There was an error. |
396 } | 397 } |
397 | 398 |
398 if (HasTranslationFinished()) { | 399 if (HasTranslationFinished()) { |
399 std::string actual_source_lang; | 400 std::string actual_source_lang; |
400 // Translation was successfull, if it was auto, retrieve the source | 401 // Translation was successfull, if it was auto, retrieve the source |
401 // language the Translate Element detected. | 402 // language the Translate Element detected. |
402 if (source_lang_ == kAutoDetectionLanguage) { | 403 if (source_lang_ == kAutoDetectionLanguage) { |
403 actual_source_lang = GetOriginalPageLanguage(); | 404 actual_source_lang = GetOriginalPageLanguage(); |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
489 | 490 |
490 WebFrame* TranslateHelper::GetMainFrame() { | 491 WebFrame* TranslateHelper::GetMainFrame() { |
491 WebView* web_view = render_view()->GetWebView(); | 492 WebView* web_view = render_view()->GetWebView(); |
492 | 493 |
493 // When the tab is going to be closed, the web_view can be NULL. | 494 // When the tab is going to be closed, the web_view can be NULL. |
494 if (!web_view) | 495 if (!web_view) |
495 return NULL; | 496 return NULL; |
496 | 497 |
497 return web_view->mainFrame(); | 498 return web_view->mainFrame(); |
498 } | 499 } |
OLD | NEW |