Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Moving WebView into UI Module (#216)
- Loading branch information
Showing
23 changed files
with
50 additions
and
105 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
add_platform_library(NAME applecommon SOURCE_FOLDER ${CMAKE_CURRENT_LIST_DIR} COMPONENT_NAME IOS-MAC PARENT_LIBRARY ui DONT_LINK_PARENT_LIBRARY) | ||
target_link_libraries(ui_applecommon PRIVATE ui) |
10 changes: 10 additions & 0 deletions
10
framework/ui/platforms/applecommon/include/bdn/applecommon/WebViewNavigationController.hh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#pragma once | ||
|
||
#import <WebKit/WebKit.h> | ||
|
||
#include "../../../include/bdn/WebView.h" | ||
|
||
@interface WebViewNavigationController : NSObject <WKNavigationDelegate> | ||
@property std::function<bool(bdn::WebView::RedirectRequest)> redirectHandler; | ||
//- initWithCore:(std::shared_ptr<bdn::mac::WebViewCore>)core; | ||
@end |
32 changes: 32 additions & 0 deletions
32
framework/ui/platforms/applecommon/src/WebViewNavigationController.mm
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#import <bdn/applecommon/WebViewNavigationController.hh> | ||
|
||
#include <bdn/foundationkit/stringUtil.hh> | ||
#include <bdn/log.h> | ||
|
||
@implementation WebViewNavigationController | ||
|
||
- (void)webView:(WKWebView *)webView didFailNavigation:(WKNavigation *)navigation withError:(NSError *)error | ||
{ | ||
bdn::logstream() << "Navigation failed: " << bdn::fk::nsStringToString(error.localizedDescription); | ||
} | ||
|
||
- (void)webView:(WKWebView *)webView didFailProvisionalNavigation:(WKNavigation *)navigation withError:(NSError *)error | ||
{ | ||
bdn::logstream() << "Provisional navigation failed: " << bdn::fk::nsStringToString(error.localizedDescription); | ||
} | ||
|
||
- (void)webView:(WKWebView *)webView | ||
decidePolicyForNavigationAction:(WKNavigationAction *)navigationAction | ||
decisionHandler:(void (^)(WKNavigationActionPolicy))decisionHandler | ||
{ | ||
bdn::WebView::RedirectRequest request; | ||
request.url = bdn::fk::nsStringToString(navigationAction.request.URL.absoluteString); | ||
|
||
if (!self.redirectHandler || self.redirectHandler(request)) { | ||
decisionHandler(WKNavigationActionPolicyAllow); | ||
} else { | ||
decisionHandler(WKNavigationActionPolicyCancel); | ||
} | ||
} | ||
|
||
@end |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.