| 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/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
| 10 #include "base/json/json_reader.h" | 10 #include "base/json/json_reader.h" |
| (...skipping 735 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 746 DCHECK(prefs != NULL); | 746 DCHECK(prefs != NULL); |
| 747 if (CommandLine::ForCurrentProcess()->HasSwitch( | 747 if (CommandLine::ForCurrentProcess()->HasSwitch( |
| 748 switches::kDisableTranslate) || | 748 switches::kDisableTranslate) || |
| 749 (prefs != NULL && !prefs->GetBoolean(prefs::kEnableTranslate))) { | 749 (prefs != NULL && !prefs->GetBoolean(prefs::kEnableTranslate))) { |
| 750 return; | 750 return; |
| 751 } | 751 } |
| 752 | 752 |
| 753 language_list_request_pending_.reset(content::URLFetcher::Create( | 753 language_list_request_pending_.reset(content::URLFetcher::Create( |
| 754 1, GURL(kLanguageListFetchURL), content::URLFetcher::GET, this)); | 754 1, GURL(kLanguageListFetchURL), content::URLFetcher::GET, this)); |
| 755 language_list_request_pending_->SetRequestContext( | 755 language_list_request_pending_->SetRequestContext( |
| 756 Profile::Deprecated::GetDefaultRequestContext()); | 756 g_browser_process->system_request_context()); |
| 757 language_list_request_pending_->SetMaxRetries(kMaxRetryLanguageListFetch); | 757 language_list_request_pending_->SetMaxRetries(kMaxRetryLanguageListFetch); |
| 758 language_list_request_pending_->Start(); | 758 language_list_request_pending_->Start(); |
| 759 } | 759 } |
| 760 | 760 |
| 761 void TranslateManager::CleanupPendingUlrFetcher() { | 761 void TranslateManager::CleanupPendingUlrFetcher() { |
| 762 language_list_request_pending_.reset(); | 762 language_list_request_pending_.reset(); |
| 763 translate_script_request_pending_.reset(); | 763 translate_script_request_pending_.reset(); |
| 764 } | 764 } |
| 765 | 765 |
| 766 void TranslateManager::RequestTranslateScript() { | 766 void TranslateManager::RequestTranslateScript() { |
| 767 if (translate_script_request_pending_.get() != NULL) | 767 if (translate_script_request_pending_.get() != NULL) |
| 768 return; | 768 return; |
| 769 | 769 |
| 770 translate_script_request_pending_.reset(content::URLFetcher::Create( | 770 translate_script_request_pending_.reset(content::URLFetcher::Create( |
| 771 0, GURL(kTranslateScriptURL), content::URLFetcher::GET, this)); | 771 0, GURL(kTranslateScriptURL), content::URLFetcher::GET, this)); |
| 772 translate_script_request_pending_->SetRequestContext( | 772 translate_script_request_pending_->SetRequestContext( |
| 773 Profile::Deprecated::GetDefaultRequestContext()); | 773 g_browser_process->system_request_context()); |
| 774 translate_script_request_pending_->SetExtraRequestHeaders( | 774 translate_script_request_pending_->SetExtraRequestHeaders( |
| 775 kTranslateScriptHeader); | 775 kTranslateScriptHeader); |
| 776 translate_script_request_pending_->Start(); | 776 translate_script_request_pending_->Start(); |
| 777 } | 777 } |
| 778 | 778 |
| 779 void TranslateManager::ShowInfoBar(TabContents* tab, | 779 void TranslateManager::ShowInfoBar(TabContents* tab, |
| 780 TranslateInfoBarDelegate* infobar) { | 780 TranslateInfoBarDelegate* infobar) { |
| 781 DCHECK(infobar != NULL); | 781 DCHECK(infobar != NULL); |
| 782 TranslateInfoBarDelegate* old_infobar = GetTranslateInfoBarDelegate(tab); | 782 TranslateInfoBarDelegate* old_infobar = GetTranslateInfoBarDelegate(tab); |
| 783 infobar->UpdateBackgroundAnimation(old_infobar); | 783 infobar->UpdateBackgroundAnimation(old_infobar); |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 829 InfoBarTabHelper* infobar_helper = wrapper->infobar_tab_helper(); | 829 InfoBarTabHelper* infobar_helper = wrapper->infobar_tab_helper(); |
| 830 | 830 |
| 831 for (size_t i = 0; i < infobar_helper->infobar_count(); ++i) { | 831 for (size_t i = 0; i < infobar_helper->infobar_count(); ++i) { |
| 832 TranslateInfoBarDelegate* delegate = | 832 TranslateInfoBarDelegate* delegate = |
| 833 infobar_helper->GetInfoBarDelegateAt(i)->AsTranslateInfoBarDelegate(); | 833 infobar_helper->GetInfoBarDelegateAt(i)->AsTranslateInfoBarDelegate(); |
| 834 if (delegate) | 834 if (delegate) |
| 835 return delegate; | 835 return delegate; |
| 836 } | 836 } |
| 837 return NULL; | 837 return NULL; |
| 838 } | 838 } |
| OLD | NEW |