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

Unified Diff: ios/web/web_state/ui/crw_wk_web_view_web_controller.mm

Issue 1137143004: WebUI for WKWebView (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Responses to Eugene Created 5 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
Index: ios/web/web_state/ui/crw_wk_web_view_web_controller.mm
diff --git a/ios/web/web_state/ui/crw_wk_web_view_web_controller.mm b/ios/web/web_state/ui/crw_wk_web_view_web_controller.mm
index 54effb602f3920e2bca3b44cff0bf8af576017c7..1c1003b1a81078f54714e01d8bebb5514bfc8526 100644
--- a/ios/web/web_state/ui/crw_wk_web_view_web_controller.mm
+++ b/ios/web/web_state/ui/crw_wk_web_view_web_controller.mm
@@ -14,7 +14,9 @@
#include "base/values.h"
#import "ios/web/crw_network_activity_indicator_manager.h"
#import "ios/web/navigation/crw_session_controller.h"
+#include "ios/web/navigation/web_load_params.h"
#include "ios/web/public/web_client.h"
+#import "ios/web/public/web_state/crw_native_content_provider.h"
#import "ios/web/public/web_state/js/crw_js_injection_manager.h"
#import "ios/web/ui_web_view_util.h"
#include "ios/web/web_state/blocked_popup_info.h"
@@ -26,6 +28,7 @@
#import "ios/web/web_state/ui/wk_web_view_configuration_provider.h"
#import "ios/web/web_state/web_state_impl.h"
#import "ios/web/web_state/web_view_creation_utils.h"
+#import "ios/web/webui/crw_web_ui_manager.h"
#import "net/base/mac/url_conversions.h"
#if !defined(ENABLE_CHROME_NET_STACK_FOR_WKWEBVIEW)
@@ -89,6 +92,9 @@ NSString* const kScriptImmediateName = @"crwebinvokeimmediate";
// Set to YES on window.history.willChangeState message. To NO on
// window.history.didPushState or window.history.didReplaceState.
BOOL _changingHistoryState;
+
+ // CRWWebUIManager object for loading WebUI pages.
+ base::scoped_nsobject<CRWWebUIManager> web_ui_manager_;
}
// Response's MIME type of the last known navigation.
@@ -341,7 +347,7 @@ NSString* const kScriptImmediateName = @"crwebinvokeimmediate";
return web::WEB_VIEW_DOCUMENT_TYPE_GENERIC;
}
-- (void)loadWebRequest:(NSURLRequest*)request {
+- (void)loadRequest:(NSMutableURLRequest*)request {
[_wkWebView loadRequest:request];
}
@@ -793,6 +799,20 @@ NSString* const kScriptImmediateName = @"crwebinvokeimmediate";
}
#pragma mark -
+#pragma mark WebUI
+
+- (void)createWebUIForURL:(const GURL&)URL {
+ [super createWebUIForURL:URL];
+ web_ui_manager_.reset(
+ [[CRWWebUIManager alloc] initWithWebState:self.webStateImpl]);
+}
+
+- (void)clearWebUI {
+ [super clearWebUI];
+ web_ui_manager_.reset();
+}
+
+#pragma mark -
#pragma mark KVO Observation
- (void)observeValueForKeyPath:(NSString*)keyPath
@@ -939,9 +959,22 @@ NSString* const kScriptImmediateName = @"crwebinvokeimmediate";
// If this navigation has not yet been registered, do so. loadPhase check is
// necessary because lastRegisteredRequestURL may be the same as the
// webViewURL on a new tab created by window.open (default is about::blank).
+ // TODO(jyquinn): Audit [CRWWebController loadCurrentURL] for other tasks that
+ // should be performed here.
if (self.lastRegisteredRequestURL != webViewURL ||
self.loadPhase != web::LOAD_REQUESTED) {
- [self registerLoadRequest:webViewURL];
+ // Reset current WebUI if one exists.
+ [self clearWebUI];
+ // If webViewURL is a chrome URL, abort the current load and initialize the
+ // load from the web controller.
+ if (web::GetWebClient()->IsAppSpecificURL(webViewURL)) {
+ [self abortWebLoad];
+ web::WebLoadParams params(webViewURL);
+ [self loadWithParams:params];
+ return;
+ } else {
+ [self registerLoadRequest:webViewURL];
+ }
}
// Ensure the URL is registered and loadPhase is as expected.
DCHECK(self.lastRegisteredRequestURL == webViewURL);

Powered by Google App Engine
This is Rietveld 408576698