| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/browser/translate/translate_manager.h" | 5 #include "chrome/browser/translate/translate_manager.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
| 9 #include "base/json/json_reader.h" | 9 #include "base/json/json_reader.h" |
| 10 #include "base/memory/singleton.h" | 10 #include "base/memory/singleton.h" |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 52 // For information, here is the list of languages that Chrome can be run in | 52 // For information, here is the list of languages that Chrome can be run in |
| 53 // but that the translation server does not support: | 53 // but that the translation server does not support: |
| 54 // am Amharic | 54 // am Amharic |
| 55 // bn Bengali | 55 // bn Bengali |
| 56 // gu Gujarati | 56 // gu Gujarati |
| 57 // kn Kannada | 57 // kn Kannada |
| 58 // ml Malayalam | 58 // ml Malayalam |
| 59 // mr Marathi | 59 // mr Marathi |
| 60 // ta Tamil | 60 // ta Tamil |
| 61 // te Telugu | 61 // te Telugu |
| 62 const char* kSupportedLanguages[] = { | 62 const char* const kSupportedLanguages[] = { |
| 63 "af", // Afrikaans | 63 "af", // Afrikaans |
| 64 "az", // Azerbaijani | 64 "az", // Azerbaijani |
| 65 "sq", // Albanian | 65 "sq", // Albanian |
| 66 "ar", // Arabic | 66 "ar", // Arabic |
| 67 "hy", // Armenian | 67 "hy", // Armenian |
| 68 "eu", // Basque | 68 "eu", // Basque |
| 69 "be", // Belarusian | 69 "be", // Belarusian |
| 70 "bg", // Bulgarian | 70 "bg", // Bulgarian |
| 71 "ca", // Catalan | 71 "ca", // Catalan |
| 72 "zh-CN", // Chinese (Simplified) | 72 "zh-CN", // Chinese (Simplified) |
| (...skipping 641 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 714 DCHECK(prefs != NULL); | 714 DCHECK(prefs != NULL); |
| 715 if (CommandLine::ForCurrentProcess()->HasSwitch( | 715 if (CommandLine::ForCurrentProcess()->HasSwitch( |
| 716 switches::kDisableTranslate) || | 716 switches::kDisableTranslate) || |
| 717 (prefs != NULL && !prefs->GetBoolean(prefs::kEnableTranslate))) { | 717 (prefs != NULL && !prefs->GetBoolean(prefs::kEnableTranslate))) { |
| 718 return; | 718 return; |
| 719 } | 719 } |
| 720 | 720 |
| 721 language_list_request_pending_.reset(URLFetcher::Create( | 721 language_list_request_pending_.reset(URLFetcher::Create( |
| 722 1, GURL(kLanguageListFetchURL), URLFetcher::GET, this)); | 722 1, GURL(kLanguageListFetchURL), URLFetcher::GET, this)); |
| 723 language_list_request_pending_->set_request_context( | 723 language_list_request_pending_->set_request_context( |
| 724 Profile::GetDefaultRequestContext()); | 724 Profile::Deprecated::GetDefaultRequestContext()); |
| 725 language_list_request_pending_->set_max_retries(kMaxRetryLanguageListFetch); | 725 language_list_request_pending_->set_max_retries(kMaxRetryLanguageListFetch); |
| 726 language_list_request_pending_->Start(); | 726 language_list_request_pending_->Start(); |
| 727 } | 727 } |
| 728 | 728 |
| 729 void TranslateManager::CleanupPendingUlrFetcher() { | 729 void TranslateManager::CleanupPendingUlrFetcher() { |
| 730 language_list_request_pending_.reset(); | 730 language_list_request_pending_.reset(); |
| 731 translate_script_request_pending_.reset(); | 731 translate_script_request_pending_.reset(); |
| 732 } | 732 } |
| 733 | 733 |
| 734 void TranslateManager::RequestTranslateScript() { | 734 void TranslateManager::RequestTranslateScript() { |
| 735 if (translate_script_request_pending_.get() != NULL) | 735 if (translate_script_request_pending_.get() != NULL) |
| 736 return; | 736 return; |
| 737 | 737 |
| 738 translate_script_request_pending_.reset(URLFetcher::Create( | 738 translate_script_request_pending_.reset(URLFetcher::Create( |
| 739 0, GURL(kTranslateScriptURL), URLFetcher::GET, this)); | 739 0, GURL(kTranslateScriptURL), URLFetcher::GET, this)); |
| 740 translate_script_request_pending_->set_request_context( | 740 translate_script_request_pending_->set_request_context( |
| 741 Profile::GetDefaultRequestContext()); | 741 Profile::Deprecated::GetDefaultRequestContext()); |
| 742 translate_script_request_pending_->set_extra_request_headers( | 742 translate_script_request_pending_->set_extra_request_headers( |
| 743 kTranslateScriptHeader); | 743 kTranslateScriptHeader); |
| 744 translate_script_request_pending_->Start(); | 744 translate_script_request_pending_->Start(); |
| 745 } | 745 } |
| 746 | 746 |
| 747 void TranslateManager::ShowInfoBar(TabContents* tab, | 747 void TranslateManager::ShowInfoBar(TabContents* tab, |
| 748 TranslateInfoBarDelegate* infobar) { | 748 TranslateInfoBarDelegate* infobar) { |
| 749 TranslateInfoBarDelegate* old_infobar = GetTranslateInfoBarDelegate(tab); | 749 TranslateInfoBarDelegate* old_infobar = GetTranslateInfoBarDelegate(tab); |
| 750 infobar->UpdateBackgroundAnimation(old_infobar); | 750 infobar->UpdateBackgroundAnimation(old_infobar); |
| 751 TabContentsWrapper* wrapper = | 751 TabContentsWrapper* wrapper = |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 793 return NULL; | 793 return NULL; |
| 794 | 794 |
| 795 for (size_t i = 0; i < wrapper->infobar_count(); ++i) { | 795 for (size_t i = 0; i < wrapper->infobar_count(); ++i) { |
| 796 TranslateInfoBarDelegate* delegate = | 796 TranslateInfoBarDelegate* delegate = |
| 797 wrapper->GetInfoBarDelegateAt(i)->AsTranslateInfoBarDelegate(); | 797 wrapper->GetInfoBarDelegateAt(i)->AsTranslateInfoBarDelegate(); |
| 798 if (delegate) | 798 if (delegate) |
| 799 return delegate; | 799 return delegate; |
| 800 } | 800 } |
| 801 return NULL; | 801 return NULL; |
| 802 } | 802 } |
| OLD | NEW |