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