Chromium Code Reviews| 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 #import "ios/web_view/internal/translate/web_view_translate_client.h" | 5 #import "ios/web_view/internal/translate/web_view_translate_client.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #import "base/mac/scoped_nsobject.h" | 10 #import "base/mac/scoped_nsobject.h" |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 27 #include "url/gurl.h" | 27 #include "url/gurl.h" |
| 28 | 28 |
| 29 #if !defined(__has_feature) || !__has_feature(objc_arc) | 29 #if !defined(__has_feature) || !__has_feature(objc_arc) |
| 30 #error "This file requires ARC support." | 30 #error "This file requires ARC support." |
| 31 #endif | 31 #endif |
| 32 | 32 |
| 33 DEFINE_WEB_STATE_USER_DATA_KEY(ios_web_view::WebViewTranslateClient); | 33 DEFINE_WEB_STATE_USER_DATA_KEY(ios_web_view::WebViewTranslateClient); |
| 34 | 34 |
| 35 namespace ios_web_view { | 35 namespace ios_web_view { |
| 36 | 36 |
| 37 // TODO(crbug.com/729859): Support logging histogram data on detected language | |
| 38 // page, by passing a valid language_model, when histogram logging is available | |
| 39 // on ios/web_view. | |
| 37 WebViewTranslateClient::WebViewTranslateClient(web::WebState* web_state) | 40 WebViewTranslateClient::WebViewTranslateClient(web::WebState* web_state) |
| 38 : web::WebStateObserver(web_state), | 41 : web::WebStateObserver(web_state), |
| 39 translate_manager_(base::MakeUnique<translate::TranslateManager>( | 42 translate_manager_(base::MakeUnique<translate::TranslateManager>( |
| 40 this, | 43 this, |
| 41 WebViewTranslateRankerFactory::GetForBrowserState( | 44 WebViewTranslateRankerFactory::GetForBrowserState( |
| 42 WebViewBrowserState::FromBrowserState( | 45 WebViewBrowserState::FromBrowserState( |
| 43 web_state->GetBrowserState())), | 46 web_state->GetBrowserState())), |
| 44 prefs::kAcceptLanguages)), | 47 prefs::kAcceptLanguages)), |
| 45 translate_driver_(web_state, | 48 translate_driver_(web_state, |
| 46 web_state->GetNavigationManager(), | 49 web_state->GetNavigationManager(), |
| 47 translate_manager_.get()) {} | 50 translate_manager_.get(), |
| 51 nil /* language_model */) {} | |
|
droger
2017/06/06 09:06:13
nullptr
ramyasharma
2017/06/07 01:58:15
Done.
| |
| 48 | 52 |
| 49 WebViewTranslateClient::~WebViewTranslateClient() = default; | 53 WebViewTranslateClient::~WebViewTranslateClient() = default; |
| 50 | 54 |
| 51 // TranslateClient implementation: | 55 // TranslateClient implementation: |
| 52 | 56 |
| 53 std::unique_ptr<infobars::InfoBar> WebViewTranslateClient::CreateInfoBar( | 57 std::unique_ptr<infobars::InfoBar> WebViewTranslateClient::CreateInfoBar( |
| 54 std::unique_ptr<translate::TranslateInfoBarDelegate> delegate) const { | 58 std::unique_ptr<translate::TranslateInfoBarDelegate> delegate) const { |
| 55 NOTREACHED(); | 59 NOTREACHED(); |
| 56 return nullptr; | 60 return nullptr; |
| 57 } | 61 } |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 118 } | 122 } |
| 119 | 123 |
| 120 void WebViewTranslateClient::WebStateDestroyed() { | 124 void WebViewTranslateClient::WebStateDestroyed() { |
| 121 // Translation process can be interrupted. | 125 // Translation process can be interrupted. |
| 122 // Destroying the TranslateManager now guarantees that it never has to deal | 126 // Destroying the TranslateManager now guarantees that it never has to deal |
| 123 // with nullptr WebState. | 127 // with nullptr WebState. |
| 124 translate_manager_.reset(); | 128 translate_manager_.reset(); |
| 125 } | 129 } |
| 126 | 130 |
| 127 } // namespace ios_web_view | 131 } // namespace ios_web_view |
| OLD | NEW |