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

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

Issue 2650323002: Cleanup ios/web_view. (Closed)
Patch Set: Respond to comments. Created 3 years, 11 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
Index: ios/web_view/internal/criwv_web_view_impl.mm
diff --git a/ios/web_view/internal/criwv_web_view_impl.mm b/ios/web_view/internal/criwv_web_view_impl.mm
index 84b29389f310fbc8a192efad394300b25a3dcaf3..76709d39a14adbbb71cd7ec7a4a12a70cc24dc76 100644
--- a/ios/web_view/internal/criwv_web_view_impl.mm
+++ b/ios/web_view/internal/criwv_web_view_impl.mm
@@ -8,6 +8,7 @@
#include <utility>
#import "base/ios/weak_nsobject.h"
+#include "base/memory/ptr_util.h"
#include "base/strings/sys_string_conversions.h"
#import "ios/web/navigation/crw_session_controller.h"
#include "ios/web/public/referrer.h"
@@ -34,9 +35,6 @@
CGFloat _loadProgress;
}
-// Returns the web state associated with this web view.
-- (web::WebState*)webState;
-
@end
@implementation CRIWVWebViewImpl
@@ -49,27 +47,21 @@
self = [super init];
if (self) {
_browserState = browserState;
- _webStateImpl.reset(new web::WebStateImpl(_browserState));
+ _webStateImpl = base::MakeUnique<web::WebStateImpl>(_browserState);
_webStateImpl->GetNavigationManagerImpl().InitializeSession(nil, nil, NO,
0);
- _webStateDelegate.reset(new web::WebStateDelegateBridge(self));
+ _webStateDelegate = base::MakeUnique<web::WebStateDelegateBridge>(self);
_webStateImpl->SetDelegate(_webStateDelegate.get());
_webController.reset(_webStateImpl->GetWebController());
[_webController setDelegate:self];
[_webController setWebUsageEnabled:YES];
// Initialize Translate.
- web::WebState* webState = [_webController webStateImpl];
- ios_web_view::CRIWVTranslateClient::CreateForWebState(webState);
+ ios_web_view::CRIWVTranslateClient::CreateForWebState(_webStateImpl.get());
}
return self;
}
-- (web::WebState*)webState {
- // TODO(crbug.com/679895): Stop using the private CRWWebController API.
- return [_webController webStateImpl];
-}
-
- (UIView*)view {
return [_webController view];
}
@@ -83,24 +75,24 @@
}
- (BOOL)isLoading {
- return [_webController webStateImpl]->IsLoading();
+ return _webStateImpl->IsLoading();
}
- (NSURL*)visibleURL {
- return net::NSURLWithGURL([self webState]->GetVisibleURL());
+ return net::NSURLWithGURL(_webStateImpl->GetVisibleURL());
}
- (NSString*)pageTitle {
- return base::SysUTF16ToNSString([_webController webStateImpl]->GetTitle());
+ return base::SysUTF16ToNSString(_webStateImpl->GetTitle());
}
- (void)goBack {
- if (_webStateImpl)
+ if (_webStateImpl->GetNavigationManager())
_webStateImpl->GetNavigationManager()->GoBack();
}
- (void)goForward {
- if (_webStateImpl)
+ if (_webStateImpl->GetNavigationManager())
_webStateImpl->GetNavigationManager()->GoForward();
}
@@ -120,9 +112,8 @@
- (void)evaluateJavaScript:(NSString*)javaScriptString
completionHandler:(void (^)(id, NSError*))completionHandler {
- [[self webState]->GetJSInjectionReceiver()
- executeJavaScript:javaScriptString
- completionHandler:completionHandler];
+ [_webStateImpl->GetJSInjectionReceiver() executeJavaScript:javaScriptString
+ completionHandler:completionHandler];
}
- (void)setDelegate:(id<CRIWVWebViewDelegate>)delegate {
@@ -130,7 +121,7 @@
// Set up the translate delegate.
ios_web_view::CRIWVTranslateClient* translateClient =
- ios_web_view::CRIWVTranslateClient::FromWebState([self webState]);
+ ios_web_view::CRIWVTranslateClient::FromWebState(_webStateImpl.get());
id<CRIWVTranslateDelegate> translateDelegate = nil;
if ([_delegate respondsToSelector:@selector(translateDelegate)])
translateDelegate = [_delegate translateDelegate];
« no previous file with comments | « ios/web_view/internal/criwv_web_view_impl.h ('k') | ios/web_view/internal/translate/criwv_translate_client.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698