Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(221)

Side by Side Diff: ios/web_view/internal/translate/web_view_translate_client.mm

Issue 2913573002: Updates language model on iOS. (Closed)
Patch Set: Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ios/chrome/browser/translate/language_model_factory_unittest.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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(ramyasharma): Investigate if language_model needs to be passed here
rohitrao (ping after 24h) 2017/06/05 13:37:43 Please file a bug for this and use TODO(crbug.com/
michaeldo 2017/06/05 15:03:43 Agreed, we always use bug number references in ios
ramyasharma 2017/06/06 04:22:27 Done.
ramyasharma 2017/06/06 04:22:27 Done.
38 // so that the language model histogram is updated from webview.
37 WebViewTranslateClient::WebViewTranslateClient(web::WebState* web_state) 39 WebViewTranslateClient::WebViewTranslateClient(web::WebState* web_state)
38 : web::WebStateObserver(web_state), 40 : web::WebStateObserver(web_state),
39 translate_manager_(base::MakeUnique<translate::TranslateManager>( 41 translate_manager_(base::MakeUnique<translate::TranslateManager>(
40 this, 42 this,
41 WebViewTranslateRankerFactory::GetForBrowserState( 43 WebViewTranslateRankerFactory::GetForBrowserState(
42 WebViewBrowserState::FromBrowserState( 44 WebViewBrowserState::FromBrowserState(
43 web_state->GetBrowserState())), 45 web_state->GetBrowserState())),
44 prefs::kAcceptLanguages)), 46 prefs::kAcceptLanguages)),
45 translate_driver_(web_state, 47 translate_driver_(web_state,
46 web_state->GetNavigationManager(), 48 web_state->GetNavigationManager(),
47 translate_manager_.get()) {} 49 translate_manager_.get(),
50 nil /*language_model*/) {}
48 51
49 WebViewTranslateClient::~WebViewTranslateClient() = default; 52 WebViewTranslateClient::~WebViewTranslateClient() = default;
50 53
51 // TranslateClient implementation: 54 // TranslateClient implementation:
52 55
53 std::unique_ptr<infobars::InfoBar> WebViewTranslateClient::CreateInfoBar( 56 std::unique_ptr<infobars::InfoBar> WebViewTranslateClient::CreateInfoBar(
54 std::unique_ptr<translate::TranslateInfoBarDelegate> delegate) const { 57 std::unique_ptr<translate::TranslateInfoBarDelegate> delegate) const {
55 NOTREACHED(); 58 NOTREACHED();
56 return nullptr; 59 return nullptr;
57 } 60 }
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 } 121 }
119 122
120 void WebViewTranslateClient::WebStateDestroyed() { 123 void WebViewTranslateClient::WebStateDestroyed() {
121 // Translation process can be interrupted. 124 // Translation process can be interrupted.
122 // Destroying the TranslateManager now guarantees that it never has to deal 125 // Destroying the TranslateManager now guarantees that it never has to deal
123 // with nullptr WebState. 126 // with nullptr WebState.
124 translate_manager_.reset(); 127 translate_manager_.reset();
125 } 128 }
126 129
127 } // namespace ios_web_view 130 } // namespace ios_web_view
OLDNEW
« no previous file with comments | « ios/chrome/browser/translate/language_model_factory_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698