| OLD | NEW |
| 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 "components/translate/ios/browser/language_detection_controller.h" | 5 #include "components/translate/ios/browser/language_detection_controller.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 if (!translation_allowed) { | 80 if (!translation_allowed) { |
| 81 // Translation not allowed by the page. Done processing. | 81 // Translation not allowed by the page. Done processing. |
| 82 return true; | 82 return true; |
| 83 } | 83 } |
| 84 if (!command.HasKey("captureTextTime") || !command.HasKey("htmlLang") || | 84 if (!command.HasKey("captureTextTime") || !command.HasKey("htmlLang") || |
| 85 !command.HasKey("httpContentLanguage")) { | 85 !command.HasKey("httpContentLanguage")) { |
| 86 NOTREACHED(); | 86 NOTREACHED(); |
| 87 return false; | 87 return false; |
| 88 } | 88 } |
| 89 | 89 |
| 90 int capture_text_time = 0; | 90 double capture_text_time = 0; |
| 91 command.GetInteger("captureTextTime", &capture_text_time); | 91 command.GetDouble("captureTextTime", &capture_text_time); |
| 92 UMA_HISTOGRAM_TIMES(kTranslateCaptureText, | 92 UMA_HISTOGRAM_TIMES(kTranslateCaptureText, |
| 93 base::TimeDelta::FromMillisecondsD(capture_text_time)); | 93 base::TimeDelta::FromMillisecondsD(capture_text_time)); |
| 94 std::string html_lang; | 94 std::string html_lang; |
| 95 command.GetString("htmlLang", &html_lang); | 95 command.GetString("htmlLang", &html_lang); |
| 96 std::string http_content_language; | 96 std::string http_content_language; |
| 97 command.GetString("httpContentLanguage", &http_content_language); | 97 command.GetString("httpContentLanguage", &http_content_language); |
| 98 // If there is no language defined in httpEquiv, use the HTTP header. | 98 // If there is no language defined in httpEquiv, use the HTTP header. |
| 99 if (http_content_language.empty()) | 99 if (http_content_language.empty()) |
| 100 http_content_language = web_state()->GetContentLanguageHeader(); | 100 http_content_language = web_state()->GetContentLanguageHeader(); |
| 101 | 101 |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 139 | 139 |
| 140 void LanguageDetectionController::HistoryStateChanged() { | 140 void LanguageDetectionController::HistoryStateChanged() { |
| 141 StartLanguageDetection(); | 141 StartLanguageDetection(); |
| 142 } | 142 } |
| 143 | 143 |
| 144 void LanguageDetectionController::WebStateDestroyed() { | 144 void LanguageDetectionController::WebStateDestroyed() { |
| 145 web_state()->RemoveScriptCommandCallback(kCommandPrefix); | 145 web_state()->RemoveScriptCommandCallback(kCommandPrefix); |
| 146 } | 146 } |
| 147 | 147 |
| 148 } // namespace translate | 148 } // namespace translate |
| OLD | NEW |