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 "base/memory/ptr_util.h" | 11 #include "base/memory/ptr_util.h" |
12 #include "components/infobars/core/infobar.h" | 12 #include "components/infobars/core/infobar.h" |
| 13 #include "components/metrics/proto/translate_event.pb.h" |
13 #include "components/prefs/pref_service.h" | 14 #include "components/prefs/pref_service.h" |
14 #include "components/translate/core/browser/page_translated_details.h" | 15 #include "components/translate/core/browser/page_translated_details.h" |
15 #include "components/translate/core/browser/translate_accept_languages.h" | 16 #include "components/translate/core/browser/translate_accept_languages.h" |
16 #include "components/translate/core/browser/translate_infobar_delegate.h" | 17 #include "components/translate/core/browser/translate_infobar_delegate.h" |
17 #include "components/translate/core/browser/translate_manager.h" | 18 #include "components/translate/core/browser/translate_manager.h" |
18 #include "components/translate/core/browser/translate_prefs.h" | 19 #include "components/translate/core/browser/translate_prefs.h" |
19 #include "components/translate/core/browser/translate_step.h" | 20 #include "components/translate/core/browser/translate_step.h" |
20 #include "ios/chrome/browser/browser_state/chrome_browser_state.h" | 21 #include "ios/chrome/browser/browser_state/chrome_browser_state.h" |
21 #include "ios/chrome/browser/infobars/infobar.h" | 22 #include "ios/chrome/browser/infobars/infobar.h" |
22 #include "ios/chrome/browser/infobars/infobar_controller.h" | 23 #include "ios/chrome/browser/infobars/infobar_controller.h" |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 initWithDelegate:infobar.get()]); | 90 initWithDelegate:infobar.get()]); |
90 break; | 91 break; |
91 default: | 92 default: |
92 NOTREACHED(); | 93 NOTREACHED(); |
93 } | 94 } |
94 infobar->SetController(controller); | 95 infobar->SetController(controller); |
95 // TODO(crbug.com/703565): remove std::move() once Xcode 9.0+ is required. | 96 // TODO(crbug.com/703565): remove std::move() once Xcode 9.0+ is required. |
96 return std::move(infobar); | 97 return std::move(infobar); |
97 } | 98 } |
98 | 99 |
| 100 void ChromeIOSTranslateClient::RecordTranslateEvent( |
| 101 const metrics::TranslateEventProto&) { |
| 102 // TODO(renjieliu): Implementing gaia-keyed logging. |
| 103 } |
| 104 |
99 void ChromeIOSTranslateClient::ShowTranslateUI( | 105 void ChromeIOSTranslateClient::ShowTranslateUI( |
100 translate::TranslateStep step, | 106 translate::TranslateStep step, |
101 const std::string& source_language, | 107 const std::string& source_language, |
102 const std::string& target_language, | 108 const std::string& target_language, |
103 translate::TranslateErrors::Type error_type, | 109 translate::TranslateErrors::Type error_type, |
104 bool triggered_from_menu) { | 110 bool triggered_from_menu) { |
105 DCHECK(web_state()); | 111 DCHECK(web_state()); |
106 if (error_type != translate::TranslateErrors::NONE) | 112 if (error_type != translate::TranslateErrors::NONE) |
107 step = translate::TRANSLATE_STEP_TRANSLATE_ERROR; | 113 step = translate::TRANSLATE_STEP_TRANSLATE_ERROR; |
108 | 114 |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
154 const GURL& report_url) { | 160 const GURL& report_url) { |
155 NOTREACHED(); | 161 NOTREACHED(); |
156 } | 162 } |
157 | 163 |
158 void ChromeIOSTranslateClient::WebStateDestroyed() { | 164 void ChromeIOSTranslateClient::WebStateDestroyed() { |
159 // Translation process can be interrupted. | 165 // Translation process can be interrupted. |
160 // Destroying the TranslateManager now guarantees that it never has to deal | 166 // Destroying the TranslateManager now guarantees that it never has to deal |
161 // with nullptr WebState. | 167 // with nullptr WebState. |
162 translate_manager_.reset(); | 168 translate_manager_.reset(); |
163 } | 169 } |
OLD | NEW |