Index: chrome/browser/translate/chrome_translate_client.cc |
diff --git a/chrome/browser/translate/chrome_translate_client.cc b/chrome/browser/translate/chrome_translate_client.cc |
index 7d3459c02fe388db68202f138fa8176ad123d0e5..7886fdcdd5897897f83406b965284501d59fa981 100644 |
--- a/chrome/browser/translate/chrome_translate_client.cc |
+++ b/chrome/browser/translate/chrome_translate_client.cc |
@@ -84,9 +84,10 @@ ChromeTranslateClient::ChromeTranslateClient(content::WebContents* web_contents) |
: content::WebContentsObserver(web_contents), |
max_reload_check_attempts_(kMaxTranslateLoadCheckAttempts), |
translate_driver_(&web_contents->GetController()), |
- translate_manager_(new TranslateManager(this, prefs::kAcceptLanguages)), |
- cld_data_provider_(translate::CreateBrowserCldDataProviderFor( |
- web_contents)), |
+ translate_manager_( |
+ new translate::TranslateManager(this, prefs::kAcceptLanguages)), |
+ cld_data_provider_( |
+ translate::CreateBrowserCldDataProviderFor(web_contents)), |
weak_pointer_factory_(this) { |
#if defined(CLD_DATA_FROM_STANDALONE) |
if (!g_cld_file_path_initialized_) |
@@ -97,30 +98,31 @@ ChromeTranslateClient::ChromeTranslateClient(content::WebContents* web_contents) |
ChromeTranslateClient::~ChromeTranslateClient() { |
} |
-LanguageState& ChromeTranslateClient::GetLanguageState() { |
+translate::LanguageState& ChromeTranslateClient::GetLanguageState() { |
return translate_manager_->GetLanguageState(); |
} |
// static |
-scoped_ptr<TranslatePrefs> ChromeTranslateClient::CreateTranslatePrefs( |
- PrefService* prefs) { |
+scoped_ptr<translate::TranslatePrefs> |
+ChromeTranslateClient::CreateTranslatePrefs(PrefService* prefs) { |
#if defined(OS_CHROMEOS) |
const char* preferred_languages_prefs = prefs::kLanguagePreferredLanguages; |
#else |
const char* preferred_languages_prefs = NULL; |
#endif |
- return scoped_ptr<TranslatePrefs>(new TranslatePrefs( |
+ return scoped_ptr<translate::TranslatePrefs>(new translate::TranslatePrefs( |
prefs, prefs::kAcceptLanguages, preferred_languages_prefs)); |
} |
// static |
-TranslateAcceptLanguages* ChromeTranslateClient::GetTranslateAcceptLanguages( |
+translate::TranslateAcceptLanguages* |
+ChromeTranslateClient::GetTranslateAcceptLanguages( |
content::BrowserContext* browser_context) { |
return TranslateAcceptLanguagesFactory::GetForBrowserContext(browser_context); |
} |
// static |
-TranslateManager* ChromeTranslateClient::GetManagerFromWebContents( |
+translate::TranslateManager* ChromeTranslateClient::GetManagerFromWebContents( |
content::WebContents* web_contents) { |
ChromeTranslateClient* chrome_translate_client = |
FromWebContents(web_contents); |
@@ -142,17 +144,19 @@ void ChromeTranslateClient::GetTranslateLanguages( |
if (!chrome_translate_client) |
return; |
- *source = TranslateDownloadManager::GetLanguageCode( |
+ *source = translate::TranslateDownloadManager::GetLanguageCode( |
chrome_translate_client->GetLanguageState().original_language()); |
Profile* profile = |
Profile::FromBrowserContext(web_contents->GetBrowserContext()); |
Profile* original_profile = profile->GetOriginalProfile(); |
PrefService* prefs = original_profile->GetPrefs(); |
- scoped_ptr<TranslatePrefs> translate_prefs = CreateTranslatePrefs(prefs); |
+ scoped_ptr<translate::TranslatePrefs> translate_prefs = |
+ CreateTranslatePrefs(prefs); |
if (!web_contents->GetBrowserContext()->IsOffTheRecord()) { |
std::string auto_translate_language = |
- TranslateManager::GetAutoTargetLanguage(*source, translate_prefs.get()); |
+ translate::TranslateManager::GetAutoTargetLanguage( |
+ *source, translate_prefs.get()); |
if (!auto_translate_language.empty()) { |
*target = auto_translate_language; |
return; |
@@ -162,10 +166,11 @@ void ChromeTranslateClient::GetTranslateLanguages( |
std::string accept_languages_str = prefs->GetString(prefs::kAcceptLanguages); |
std::vector<std::string> accept_languages_list; |
base::SplitString(accept_languages_str, ',', &accept_languages_list); |
- *target = TranslateManager::GetTargetLanguage(accept_languages_list); |
+ *target = |
+ translate::TranslateManager::GetTargetLanguage(accept_languages_list); |
} |
-TranslateManager* ChromeTranslateClient::GetTranslateManager() { |
+translate::TranslateManager* ChromeTranslateClient::GetTranslateManager() { |
return translate_manager_.get(); |
} |
@@ -173,13 +178,14 @@ content::WebContents* ChromeTranslateClient::GetWebContents() { |
return web_contents(); |
} |
-void ChromeTranslateClient::ShowTranslateUI(translate::TranslateStep step, |
- const std::string source_language, |
- const std::string target_language, |
- TranslateErrors::Type error_type, |
- bool triggered_from_menu) { |
+void ChromeTranslateClient::ShowTranslateUI( |
+ translate::TranslateStep step, |
+ const std::string source_language, |
+ const std::string target_language, |
+ translate::TranslateErrors::Type error_type, |
+ bool triggered_from_menu) { |
DCHECK(web_contents()); |
- if (error_type != TranslateErrors::NONE) |
+ if (error_type != translate::TranslateErrors::NONE) |
step = translate::TRANSLATE_STEP_TRANSLATE_ERROR; |
if (TranslateService::IsTranslateBubbleEnabled()) { |
@@ -202,7 +208,7 @@ void ChromeTranslateClient::ShowTranslateUI(translate::TranslateStep step, |
} |
// Infobar UI. |
- TranslateInfoBarDelegate::Create( |
+ translate::TranslateInfoBarDelegate::Create( |
step != translate::TRANSLATE_STEP_BEFORE_TRANSLATE, |
translate_manager_->GetWeakPtr(), |
InfoBarService::FromWebContents(web_contents()), |
@@ -214,7 +220,7 @@ void ChromeTranslateClient::ShowTranslateUI(translate::TranslateStep step, |
triggered_from_menu); |
} |
-TranslateDriver* ChromeTranslateClient::GetTranslateDriver() { |
+translate::TranslateDriver* ChromeTranslateClient::GetTranslateDriver() { |
return &translate_driver_; |
} |
@@ -225,14 +231,16 @@ PrefService* ChromeTranslateClient::GetPrefs() { |
return profile->GetOriginalProfile()->GetPrefs(); |
} |
-scoped_ptr<TranslatePrefs> ChromeTranslateClient::GetTranslatePrefs() { |
+scoped_ptr<translate::TranslatePrefs> |
+ChromeTranslateClient::GetTranslatePrefs() { |
DCHECK(web_contents()); |
Profile* profile = |
Profile::FromBrowserContext(web_contents()->GetBrowserContext()); |
return CreateTranslatePrefs(profile->GetPrefs()); |
} |
-TranslateAcceptLanguages* ChromeTranslateClient::GetTranslateAcceptLanguages() { |
+translate::TranslateAcceptLanguages* |
+ChromeTranslateClient::GetTranslateAcceptLanguages() { |
DCHECK(web_contents()); |
return GetTranslateAcceptLanguages(web_contents()->GetBrowserContext()); |
} |
@@ -245,7 +253,7 @@ int ChromeTranslateClient::GetInfobarIconID() const { |
// files, except the TOOLKIT_VIEWS implementation, which has been removed. |
#if defined(TOOLKIT_VIEWS) |
scoped_ptr<infobars::InfoBar> ChromeTranslateClient::CreateInfoBar( |
- scoped_ptr<TranslateInfoBarDelegate> delegate) const { |
+ scoped_ptr<translate::TranslateInfoBarDelegate> delegate) const { |
return scoped_ptr<infobars::InfoBar>(); |
} |
#endif |
@@ -378,7 +386,7 @@ void ChromeTranslateClient::InitiateTranslation(const std::string& page_lang, |
} |
translate_manager_->InitiateTranslation( |
- TranslateDownloadManager::GetLanguageCode(page_lang)); |
+ translate::TranslateDownloadManager::GetLanguageCode(page_lang)); |
} |
void ChromeTranslateClient::OnTranslateAssignedSequenceNumber(int page_seq_no) { |
@@ -386,7 +394,7 @@ void ChromeTranslateClient::OnTranslateAssignedSequenceNumber(int page_seq_no) { |
} |
void ChromeTranslateClient::OnLanguageDetermined( |
- const LanguageDetectionDetails& details, |
+ const translate::LanguageDetectionDetails& details, |
bool page_needs_translation) { |
GetLanguageState().LanguageDetermined(details.adopted_language, |
page_needs_translation); |
@@ -397,28 +405,30 @@ void ChromeTranslateClient::OnLanguageDetermined( |
content::NotificationService::current()->Notify( |
chrome::NOTIFICATION_TAB_LANGUAGE_DETERMINED, |
content::Source<content::WebContents>(web_contents()), |
- content::Details<const LanguageDetectionDetails>(&details)); |
+ content::Details<const translate::LanguageDetectionDetails>(&details)); |
} |
-void ChromeTranslateClient::OnPageTranslated(const std::string& original_lang, |
- const std::string& translated_lang, |
- TranslateErrors::Type error_type) { |
+void ChromeTranslateClient::OnPageTranslated( |
+ const std::string& original_lang, |
+ const std::string& translated_lang, |
+ translate::TranslateErrors::Type error_type) { |
DCHECK(web_contents()); |
translate_manager_->PageTranslated( |
original_lang, translated_lang, error_type); |
- PageTranslatedDetails details; |
+ translate::PageTranslatedDetails details; |
details.source_language = original_lang; |
details.target_language = translated_lang; |
details.error_type = error_type; |
content::NotificationService::current()->Notify( |
chrome::NOTIFICATION_PAGE_TRANSLATED, |
content::Source<content::WebContents>(web_contents()), |
- content::Details<PageTranslatedDetails>(&details)); |
+ content::Details<translate::PageTranslatedDetails>(&details)); |
} |
-void ChromeTranslateClient::ShowBubble(translate::TranslateStep step, |
- TranslateErrors::Type error_type) { |
+void ChromeTranslateClient::ShowBubble( |
+ translate::TranslateStep step, |
+ translate::TranslateErrors::Type error_type) { |
// The bubble is implemented only on the desktop platforms. |
#if !defined(OS_ANDROID) && !defined(OS_IOS) |
Browser* browser = chrome::FindBrowserWithWebContents(web_contents()); |