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

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

Issue 1525203003: [Translate] Factor out access to Accept-Languages (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@translate-manager-unit
Patch Set: Fix CrOS build Created 5 years 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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_service.h" 5 #include "chrome/browser/translate/translate_service.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/metrics/field_trial.h" 9 #include "base/metrics/field_trial.h"
10 #include "base/prefs/pref_service.h" 10 #include "base/prefs/pref_service.h"
11 #include "base/strings/string_split.h" 11 #include "base/strings/string_split.h"
12 #include "base/strings/string_util.h" 12 #include "base/strings/string_util.h"
13 #include "chrome/browser/browser_process.h" 13 #include "chrome/browser/browser_process.h"
14 #include "chrome/browser/translate/chrome_translate_client.h"
14 #include "chrome/common/chrome_switches.h" 15 #include "chrome/common/chrome_switches.h"
15 #include "chrome/common/pref_names.h" 16 #include "chrome/common/pref_names.h"
16 #include "components/translate/core/browser/translate_download_manager.h" 17 #include "components/translate/core/browser/translate_download_manager.h"
17 #include "components/translate/core/browser/translate_manager.h" 18 #include "components/translate/core/browser/translate_manager.h"
18 #include "content/public/common/url_constants.h" 19 #include "content/public/common/url_constants.h"
19 #include "url/gurl.h" 20 #include "url/gurl.h"
20 21
21 #if defined(OS_CHROMEOS) 22 #if defined(OS_CHROMEOS)
22 #include "chrome/browser/chromeos/file_manager/app_id.h" 23 #include "chrome/browser/chromeos/file_manager/app_id.h"
23 #include "extensions/common/constants.h" 24 #include "extensions/common/constants.h"
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 return true; 109 return true;
109 return base::StartsWith(group_name, "Enabled", base::CompareCase::SENSITIVE); 110 return base::StartsWith(group_name, "Enabled", base::CompareCase::SENSITIVE);
110 #else 111 #else
111 // The bubble UX is not implemented on other platforms. 112 // The bubble UX is not implemented on other platforms.
112 return false; 113 return false;
113 #endif 114 #endif
114 } 115 }
115 116
116 // static 117 // static
117 std::string TranslateService::GetTargetLanguage(PrefService* prefs) { 118 std::string TranslateService::GetTargetLanguage(PrefService* prefs) {
118 std::vector<std::string> accept_languages_list = base::SplitString( 119 return translate::TranslateManager::GetTargetLanguage(
119 prefs->GetString(prefs::kAcceptLanguages), ",", 120 ChromeTranslateClient::CreateTranslatePrefs(prefs).get());
120 base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL);
121 return translate::TranslateManager::GetTargetLanguage(accept_languages_list);
122 } 121 }
123 122
124 // static 123 // static
125 bool TranslateService::IsTranslatableURL(const GURL& url) { 124 bool TranslateService::IsTranslatableURL(const GURL& url) {
126 // A URLs is translatable unless it is one of the following: 125 // A URLs is translatable unless it is one of the following:
127 // - empty (can happen for popups created with window.open("")) 126 // - empty (can happen for popups created with window.open(""))
128 // - an internal URL (chrome:// and others) 127 // - an internal URL (chrome:// and others)
129 // - the devtools (which is considered UI) 128 // - the devtools (which is considered UI)
130 // - Chrome OS file manager extension 129 // - Chrome OS file manager extension
131 // - an FTP page (as FTP pages tend to have long lists of filenames that may 130 // - an FTP page (as FTP pages tend to have long lists of filenames that may
132 // confuse the CLD) 131 // confuse the CLD)
133 return !url.is_empty() && !url.SchemeIs(content::kChromeUIScheme) && 132 return !url.is_empty() && !url.SchemeIs(content::kChromeUIScheme) &&
134 !url.SchemeIs(content::kChromeDevToolsScheme) && 133 !url.SchemeIs(content::kChromeDevToolsScheme) &&
135 #if defined(OS_CHROMEOS) 134 #if defined(OS_CHROMEOS)
136 !(url.SchemeIs(extensions::kExtensionScheme) && 135 !(url.SchemeIs(extensions::kExtensionScheme) &&
137 url.DomainIs(file_manager::kFileManagerAppId)) && 136 url.DomainIs(file_manager::kFileManagerAppId)) &&
138 #endif 137 #endif
139 !url.SchemeIs(url::kFtpScheme); 138 !url.SchemeIs(url::kFtpScheme);
140 } 139 }
OLDNEW
« no previous file with comments | « chrome/browser/translate/chrome_translate_client.cc ('k') | components/translate/core/browser/translate_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698