| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #import "ios/web_view/internal/translate/cwv_translate_manager_impl.h" | |
| 6 | |
| 7 #include "base/logging.h" | |
| 8 #include "base/memory/ptr_util.h" | |
| 9 #include "components/translate/core/browser/translate_manager.h" | |
| 10 #include "components/translate/core/browser/translate_ui_delegate.h" | |
| 11 | |
| 12 #if !defined(__has_feature) || !__has_feature(objc_arc) | |
| 13 #error "This file requires ARC support." | |
| 14 #endif | |
| 15 | |
| 16 @implementation CWVTranslateManagerImpl { | |
| 17 std::unique_ptr<translate::TranslateUIDelegate> _translateUIDelegate; | |
| 18 } | |
| 19 | |
| 20 - (instancetype)initWithTranslateManager:(translate::TranslateManager*)manager | |
| 21 sourceLanguage:(const std::string&)source | |
| 22 targetLanguage:(const std::string&)target { | |
| 23 if ((self = [super init])) { | |
| 24 DCHECK(manager); | |
| 25 _translateUIDelegate = base::MakeUnique<translate::TranslateUIDelegate>( | |
| 26 manager->GetWeakPtr(), source, target); | |
| 27 } | |
| 28 return self; | |
| 29 } | |
| 30 | |
| 31 #pragma mark CWVTranslateManager methods | |
| 32 | |
| 33 - (void)translate { | |
| 34 _translateUIDelegate->Translate(); | |
| 35 } | |
| 36 | |
| 37 - (void)revertTranslation { | |
| 38 _translateUIDelegate->RevertTranslation(); | |
| 39 } | |
| 40 | |
| 41 @end | |
| OLD | NEW |