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 3 // found in the LICENSE file. 4 5 #include "components/translate/core/common/translate_util.h" 6 7 #include <string> 8 9 #include "base/command_line.h" 10 #include "base/metrics/field_trial_params.h" 11 #include "components/translate/core/common/translate_switches.h" 12 13 namespace translate { 14 15 namespace { 16 17 // Parameter for TranslateSubFrames feature to determine whether language 18 // detection should include the sub frames (or just the main frame). 19 const char kDetectLanguageInSubFrames[] = "detect_language_in_sub_frames"; 20 21 } // namespace 22 23 const char kSecurityOrigin[] = "https://translate.googleapis.com/"; 24 25 const base::Feature kTranslateSubFrames{"TranslateSubFrames", 26 base::FEATURE_DISABLED_BY_DEFAULT}; 27 GetTranslateSecurityOrigin()28GURL GetTranslateSecurityOrigin() { 29 std::string security_origin(kSecurityOrigin); 30 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); 31 if (command_line->HasSwitch(switches::kTranslateSecurityOrigin)) { 32 security_origin = 33 command_line->GetSwitchValueASCII(switches::kTranslateSecurityOrigin); 34 } 35 return GURL(security_origin); 36 } 37 IsSubFrameTranslationEnabled()38bool IsSubFrameTranslationEnabled() { 39 return base::FeatureList::IsEnabled(kTranslateSubFrames); 40 } 41 IsSubFrameLanguageDetectionEnabled()42bool IsSubFrameLanguageDetectionEnabled() { 43 return base::FeatureList::IsEnabled(kTranslateSubFrames) && 44 base::GetFieldTrialParamByFeatureAsBool( 45 kTranslateSubFrames, kDetectLanguageInSubFrames, true); 46 } 47 48 } // namespace translate 49