| 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 "ios/chrome/browser/translate/chrome_ios_translate_client.h" | 5 #include "ios/chrome/browser/translate/chrome_ios_translate_client.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| 11 #include "components/infobars/core/infobar.h" | 11 #include "components/infobars/core/infobar.h" |
| 12 #include "components/prefs/pref_service.h" | 12 #include "components/prefs/pref_service.h" |
| 13 #include "components/translate/core/browser/page_translated_details.h" | 13 #include "components/translate/core/browser/page_translated_details.h" |
| 14 #include "components/translate/core/browser/translate_accept_languages.h" | 14 #include "components/translate/core/browser/translate_accept_languages.h" |
| 15 #include "components/translate/core/browser/translate_infobar_delegate.h" | 15 #include "components/translate/core/browser/translate_infobar_delegate.h" |
| 16 #include "components/translate/core/browser/translate_manager.h" | 16 #include "components/translate/core/browser/translate_manager.h" |
| 17 #include "components/translate/core/browser/translate_prefs.h" | 17 #include "components/translate/core/browser/translate_prefs.h" |
| 18 #include "components/translate/core/browser/translate_step.h" | 18 #include "components/translate/core/browser/translate_step.h" |
| 19 #include "ios/chrome/browser/browser_state/chrome_browser_state.h" |
| 19 #include "ios/chrome/browser/infobars/infobar.h" | 20 #include "ios/chrome/browser/infobars/infobar.h" |
| 20 #include "ios/chrome/browser/infobars/infobar_controller.h" | 21 #include "ios/chrome/browser/infobars/infobar_controller.h" |
| 21 #include "ios/chrome/browser/infobars/infobar_manager_impl.h" | 22 #include "ios/chrome/browser/infobars/infobar_manager_impl.h" |
| 22 #include "ios/chrome/browser/pref_names.h" | 23 #include "ios/chrome/browser/pref_names.h" |
| 23 #import "ios/chrome/browser/translate/after_translate_infobar_controller.h" | 24 #import "ios/chrome/browser/translate/after_translate_infobar_controller.h" |
| 24 #import "ios/chrome/browser/translate/before_translate_infobar_controller.h" | 25 #import "ios/chrome/browser/translate/before_translate_infobar_controller.h" |
| 25 #import "ios/chrome/browser/translate/never_translate_infobar_controller.h" | 26 #import "ios/chrome/browser/translate/never_translate_infobar_controller.h" |
| 26 #include "ios/chrome/browser/translate/translate_accept_languages_factory.h" | 27 #include "ios/chrome/browser/translate/translate_accept_languages_factory.h" |
| 27 #import "ios/chrome/browser/translate/translate_message_infobar_controller.h" | 28 #import "ios/chrome/browser/translate/translate_message_infobar_controller.h" |
| 28 #include "ios/chrome/browser/translate/translate_service_ios.h" | 29 #include "ios/chrome/browser/translate/translate_service_ios.h" |
| 29 #include "ios/chrome/grit/ios_theme_resources.h" | 30 #include "ios/chrome/grit/ios_theme_resources.h" |
| 30 #include "ios/public/provider/chrome/browser/browser_state/chrome_browser_state.
h" | |
| 31 #include "ios/web/public/browser_state.h" | 31 #include "ios/web/public/browser_state.h" |
| 32 #include "ios/web/public/web_state/web_state.h" | 32 #include "ios/web/public/web_state/web_state.h" |
| 33 #include "url/gurl.h" | 33 #include "url/gurl.h" |
| 34 | 34 |
| 35 DEFINE_WEB_STATE_USER_DATA_KEY(ChromeIOSTranslateClient); | 35 DEFINE_WEB_STATE_USER_DATA_KEY(ChromeIOSTranslateClient); |
| 36 | 36 |
| 37 ChromeIOSTranslateClient::ChromeIOSTranslateClient(web::WebState* web_state) | 37 ChromeIOSTranslateClient::ChromeIOSTranslateClient(web::WebState* web_state) |
| 38 : web::WebStateObserver(web_state), | 38 : web::WebStateObserver(web_state), |
| 39 translate_manager_( | 39 translate_manager_( |
| 40 new translate::TranslateManager(this, prefs::kAcceptLanguages)), | 40 new translate::TranslateManager(this, prefs::kAcceptLanguages)), |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 147 const GURL& report_url) { | 147 const GURL& report_url) { |
| 148 NOTREACHED(); | 148 NOTREACHED(); |
| 149 } | 149 } |
| 150 | 150 |
| 151 void ChromeIOSTranslateClient::WebStateDestroyed() { | 151 void ChromeIOSTranslateClient::WebStateDestroyed() { |
| 152 // Translation process can be interrupted. | 152 // Translation process can be interrupted. |
| 153 // Destroying the TranslateManager now guarantees that it never has to deal | 153 // Destroying the TranslateManager now guarantees that it never has to deal |
| 154 // with nullptr WebState. | 154 // with nullptr WebState. |
| 155 translate_manager_.reset(); | 155 translate_manager_.reset(); |
| 156 } | 156 } |
| OLD | NEW |