Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(153)

Side by Side Diff: chrome/browser/translate/translate_manager.cc

Issue 203223002: Translate bubble for Mac OS X (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: groby's review Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/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/metrics/field_trial.h" 9 #include "base/metrics/field_trial.h"
10 #include "base/metrics/histogram.h" 10 #include "base/metrics/histogram.h"
(...skipping 569 matching lines...) Expand 10 before | Expand all | Expand 10 after
580 &auto_target_lang)) { 580 &auto_target_lang)) {
581 // We need to confirm that the saved target language is still supported. 581 // We need to confirm that the saved target language is still supported.
582 // Also, GetLanguageCode will take care of removing country code if any. 582 // Also, GetLanguageCode will take care of removing country code if any.
583 auto_target_lang = 583 auto_target_lang =
584 TranslateDownloadManager::GetLanguageCode(auto_target_lang); 584 TranslateDownloadManager::GetLanguageCode(auto_target_lang);
585 if (TranslateDownloadManager::IsSupportedLanguage(auto_target_lang)) 585 if (TranslateDownloadManager::IsSupportedLanguage(auto_target_lang))
586 return auto_target_lang; 586 return auto_target_lang;
587 } 587 }
588 return std::string(); 588 return std::string();
589 } 589 }
590
591 // static
592 void TranslateManager::GetTranslateLanguages(content::WebContents* web_contents,
593 std::string* source,
594 std::string* target) {
595 DCHECK(source != NULL);
596 DCHECK(target != NULL);
597
598 TranslateTabHelper* translate_tab_helper =
599 TranslateTabHelper::FromWebContents(web_contents);
600 *source = translate_tab_helper->GetLanguageState().original_language();
601
602 Profile* profile =
603 Profile::FromBrowserContext(web_contents->GetBrowserContext());
604 Profile* original_profile = profile->GetOriginalProfile();
605 PrefService* prefs = original_profile->GetPrefs();
606 if (!web_contents->GetBrowserContext()->IsOffTheRecord()) {
607 std::string auto_translate_language =
608 TranslateManager::GetAutoTargetLanguage(*source, prefs);
609 if (!auto_translate_language.empty()) {
610 *target = auto_translate_language;
611 return;
612 }
613 }
614 *target = TranslateManager::GetTargetLanguage(prefs);
615 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698