| 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 #ifndef COMPONENTS_TRANSLATE_IOS_BROWSER_LANGUAGE_DETECTION_CONTROLLER_H_ | 5 #ifndef COMPONENTS_TRANSLATE_IOS_BROWSER_LANGUAGE_DETECTION_CONTROLLER_H_ |
| 6 #define COMPONENTS_TRANSLATE_IOS_BROWSER_LANGUAGE_DETECTION_CONTROLLER_H_ | 6 #define COMPONENTS_TRANSLATE_IOS_BROWSER_LANGUAGE_DETECTION_CONTROLLER_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| 11 #include "base/callback_list.h" | 11 #include "base/callback_list.h" |
| 12 #include "base/gtest_prod_util.h" | 12 #include "base/gtest_prod_util.h" |
| 13 #include "base/macros.h" | 13 #include "base/macros.h" |
| 14 #include "base/memory/weak_ptr.h" | 14 #include "base/memory/weak_ptr.h" |
| 15 #include "base/strings/string16.h" | 15 #include "base/strings/string16.h" |
| 16 #include "components/prefs/pref_member.h" | 16 #include "components/prefs/pref_member.h" |
| 17 #include "ios/web/public/web_state/web_state_observer.h" | 17 #include "ios/web/public/web_state/web_state_observer.h" |
| 18 | 18 |
| 19 class GURL; | 19 class GURL; |
| 20 @class JsLanguageDetectionManager; | 20 @class JsLanguageDetectionManager; |
| 21 class PrefService; | 21 class PrefService; |
| 22 | 22 |
| 23 namespace base { | 23 namespace base { |
| 24 class DictionaryValue; | 24 class DictionaryValue; |
| 25 } | 25 } |
| 26 | 26 |
| 27 namespace web { | 27 namespace web { |
| 28 class NavigationContext; |
| 28 class WebState; | 29 class WebState; |
| 29 } | 30 } |
| 30 | 31 |
| 31 namespace translate { | 32 namespace translate { |
| 32 | 33 |
| 33 class LanguageDetectionController : public web::WebStateObserver { | 34 class LanguageDetectionController : public web::WebStateObserver { |
| 34 public: | 35 public: |
| 35 // Language detection details, passed to language detection callbacks. | 36 // Language detection details, passed to language detection callbacks. |
| 36 struct DetectionDetails { | 37 struct DetectionDetails { |
| 37 // The language detected by the content (Content-Language). | 38 // The language detected by the content (Content-Language). |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 71 | 72 |
| 72 // Completion handler used to retrieve the text buffered by the | 73 // Completion handler used to retrieve the text buffered by the |
| 73 // JsLanguageDetectionManager. | 74 // JsLanguageDetectionManager. |
| 74 void OnTextRetrieved(const std::string& http_content_language, | 75 void OnTextRetrieved(const std::string& http_content_language, |
| 75 const std::string& html_lang, | 76 const std::string& html_lang, |
| 76 const base::string16& text); | 77 const base::string16& text); |
| 77 | 78 |
| 78 // web::WebStateObserver implementation: | 79 // web::WebStateObserver implementation: |
| 79 void PageLoaded( | 80 void PageLoaded( |
| 80 web::PageLoadCompletionStatus load_completion_status) override; | 81 web::PageLoadCompletionStatus load_completion_status) override; |
| 81 void UrlHashChanged() override; | 82 void DidFinishNavigation(web::NavigationContext* navigation_context) override; |
| 82 void HistoryStateChanged() override; | |
| 83 void WebStateDestroyed() override; | 83 void WebStateDestroyed() override; |
| 84 | 84 |
| 85 CallbackList language_detection_callbacks_; | 85 CallbackList language_detection_callbacks_; |
| 86 JsLanguageDetectionManager* js_manager_; | 86 JsLanguageDetectionManager* js_manager_; |
| 87 BooleanPrefMember translate_enabled_; | 87 BooleanPrefMember translate_enabled_; |
| 88 base::WeakPtrFactory<LanguageDetectionController> weak_method_factory_; | 88 base::WeakPtrFactory<LanguageDetectionController> weak_method_factory_; |
| 89 | 89 |
| 90 DISALLOW_COPY_AND_ASSIGN(LanguageDetectionController); | 90 DISALLOW_COPY_AND_ASSIGN(LanguageDetectionController); |
| 91 }; | 91 }; |
| 92 | 92 |
| 93 } // namespace translate | 93 } // namespace translate |
| 94 | 94 |
| 95 #endif // COMPONENTS_TRANSLATE_IOS_BROWSER_LANGUAGE_DETECTION_CONTROLLER_H_ | 95 #endif // COMPONENTS_TRANSLATE_IOS_BROWSER_LANGUAGE_DETECTION_CONTROLLER_H_ |
| OLD | NEW |