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

Unified Diff: ios/web_view/internal/cwv_web_view.mm

Issue 2839093002: Implemented new Translate API for purely Objective-C clients. (Closed)
Patch Set: merge Created 3 years, 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ios/web_view/BUILD.gn ('k') | ios/web_view/internal/translate/cwv_language_detection_result.mm » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ios/web_view/internal/cwv_web_view.mm
diff --git a/ios/web_view/internal/cwv_web_view.mm b/ios/web_view/internal/cwv_web_view.mm
index 544a327639351c00888847a22c792175895515ac..c391d89c032fda8f0bc432b84b0ce879053882e1 100644
--- a/ios/web_view/internal/cwv_web_view.mm
+++ b/ios/web_view/internal/cwv_web_view.mm
@@ -26,6 +26,7 @@
#import "ios/web_view/internal/cwv_navigation_action_internal.h"
#import "ios/web_view/internal/cwv_scroll_view_internal.h"
#import "ios/web_view/internal/cwv_web_view_configuration_internal.h"
+#import "ios/web_view/internal/translate/cwv_translation_controller_internal.h"
#import "ios/web_view/internal/translate/web_view_translate_client.h"
#include "ios/web_view/internal/web_view_browser_state.h"
#import "ios/web_view/internal/web_view_java_script_dialog_presenter.h"
@@ -84,9 +85,9 @@ static NSString* gUserAgentProduct = nil;
@implementation CWVWebView
@synthesize configuration = _configuration;
-@synthesize navigationDelegate = _navigationDelegate;
-@synthesize translationDelegate = _translationDelegate;
@synthesize estimatedProgress = _estimatedProgress;
+@synthesize navigationDelegate = _navigationDelegate;
+@synthesize translationController = _translationController;
@synthesize UIDelegate = _UIDelegate;
@synthesize scrollView = _scrollView;
@@ -192,12 +193,6 @@ static NSString* gUserAgentProduct = nil;
_javaScriptDialogPresenter->SetUIDelegate(_UIDelegate);
}
-- (void)setTranslationDelegate:(id<CWVTranslateDelegate>)translationDelegate {
- _translationDelegate = translationDelegate;
- ios_web_view::WebViewTranslateClient::FromWebState(_webState.get())
- ->set_translate_delegate(translationDelegate);
-}
-
// -----------------------------------------------------------------------
// WebStateObserver implementation.
@@ -295,6 +290,16 @@ static NSString* gUserAgentProduct = nil;
return _javaScriptDialogPresenter.get();
}
+#pragma mark - Translation
+
+- (CWVTranslationController*)translationController {
+ if (!_translationController) {
+ _translationController = [[CWVTranslationController alloc] init];
+ _translationController.webState = _webState.get();
+ }
+ return _translationController;
+}
+
#pragma mark - Preserving and Restoring State
- (void)encodeRestorableStateWithCoder:(NSCoder*)coder {
@@ -348,8 +353,7 @@ static NSString* gUserAgentProduct = nil;
_scrollView.proxy = _webState.get()->GetWebViewProxy().scrollViewProxy;
- // Initialize Translate.
- ios_web_view::WebViewTranslateClient::CreateForWebState(_webState.get());
+ _translationController.webState = _webState.get();
[self addInternalWebViewAsSubview];
}
« no previous file with comments | « ios/web_view/BUILD.gn ('k') | ios/web_view/internal/translate/cwv_language_detection_result.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698