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" |
11 #include "base/metrics/histogram_macros.h" | 11 #include "base/metrics/histogram_macros.h" |
12 #include "base/time/time.h" | 12 #include "base/time/time.h" |
13 #include "components/prefs/pref_member.h" | 13 #include "components/prefs/pref_member.h" |
14 #include "components/translate/core/common/translate_pref_names.h" | 14 #include "components/translate/core/common/translate_pref_names.h" |
15 #include "components/translate/core/language_detection/language_detection_util.h
" | 15 #include "components/translate/core/language_detection/language_detection_util.h
" |
16 #import "components/translate/ios/browser/js_language_detection_manager.h" | 16 #import "components/translate/ios/browser/js_language_detection_manager.h" |
17 #include "components/translate/ios/browser/string_clipping_util.h" | 17 #include "components/translate/ios/browser/string_clipping_util.h" |
18 #import "ios/web/public/url_scheme_util.h" | 18 #import "ios/web/public/url_scheme_util.h" |
| 19 #include "ios/web/public/web_state/navigation_context.h" |
19 #include "ios/web/public/web_state/web_state.h" | 20 #include "ios/web/public/web_state/web_state.h" |
20 | 21 |
21 #if !defined(__has_feature) || !__has_feature(objc_arc) | 22 #if !defined(__has_feature) || !__has_feature(objc_arc) |
22 #error "This file requires ARC support." | 23 #error "This file requires ARC support." |
23 #endif | 24 #endif |
24 | 25 |
25 namespace translate { | 26 namespace translate { |
26 | 27 |
27 namespace { | 28 namespace { |
28 // Name for the UMA metric used to track text extraction time. | 29 // Name for the UMA metric used to track text extraction time. |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
130 } | 131 } |
131 | 132 |
132 // web::WebStateObserver implementation: | 133 // web::WebStateObserver implementation: |
133 | 134 |
134 void LanguageDetectionController::PageLoaded( | 135 void LanguageDetectionController::PageLoaded( |
135 web::PageLoadCompletionStatus load_completion_status) { | 136 web::PageLoadCompletionStatus load_completion_status) { |
136 if (load_completion_status == web::PageLoadCompletionStatus::SUCCESS) | 137 if (load_completion_status == web::PageLoadCompletionStatus::SUCCESS) |
137 StartLanguageDetection(); | 138 StartLanguageDetection(); |
138 } | 139 } |
139 | 140 |
140 void LanguageDetectionController::UrlHashChanged() { | 141 void LanguageDetectionController::DidFinishNavigation( |
141 StartLanguageDetection(); | 142 web::NavigationContext* navigation_context) { |
142 } | 143 if (navigation_context->IsSamePage()) |
143 | 144 StartLanguageDetection(); |
144 void LanguageDetectionController::HistoryStateChanged() { | |
145 StartLanguageDetection(); | |
146 } | 145 } |
147 | 146 |
148 void LanguageDetectionController::WebStateDestroyed() { | 147 void LanguageDetectionController::WebStateDestroyed() { |
149 web_state()->RemoveScriptCommandCallback(kCommandPrefix); | 148 web_state()->RemoveScriptCommandCallback(kCommandPrefix); |
150 } | 149 } |
151 | 150 |
152 } // namespace translate | 151 } // namespace translate |
OLD | NEW |