Commit fcc9f661 authored by jzw's avatar jzw Committed by Commit Bot

Use dummy class to locate NSBundle.

This is the safest way to avoid potential dead lock issues with
dispatch_once and ios_web_view::InitializeGlobalState().

BUG=

Review-Url: https://codereview.chromium.org/2980983002
Cr-Commit-Position: refs/heads/master@{#486867}
parent ba483a6f
...@@ -5,12 +5,18 @@ ...@@ -5,12 +5,18 @@
#import "ios/web_view/internal/web_view_web_main_delegate.h" #import "ios/web_view/internal/web_view_web_main_delegate.h"
#import "base/mac/bundle_locations.h" #import "base/mac/bundle_locations.h"
#import "ios/web_view/public/cwv_html_element.h"
#if !defined(__has_feature) || !__has_feature(objc_arc) #if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support." #error "This file requires ARC support."
#endif #endif
// Dummy class used to locate the containing NSBundle.
@interface CWVBundleLocator : NSObject
@end
@implementation CWVBundleLocator
@end
namespace ios_web_view { namespace ios_web_view {
WebViewWebMainDelegate::WebViewWebMainDelegate() {} WebViewWebMainDelegate::WebViewWebMainDelegate() {}
...@@ -18,11 +24,8 @@ WebViewWebMainDelegate::WebViewWebMainDelegate() {} ...@@ -18,11 +24,8 @@ WebViewWebMainDelegate::WebViewWebMainDelegate() {}
WebViewWebMainDelegate::~WebViewWebMainDelegate() = default; WebViewWebMainDelegate::~WebViewWebMainDelegate() = default;
void WebViewWebMainDelegate::BasicStartupComplete() { void WebViewWebMainDelegate::BasicStartupComplete() {
// Use CWVHTMLElement instead of CWVWebView and CWVWebViewConfiguration
// because the latter two classes' +intialize calls in to this method and may
// cause a deadlock.
base::mac::SetOverrideFrameworkBundle( base::mac::SetOverrideFrameworkBundle(
[NSBundle bundleForClass:[CWVHTMLElement class]]); [NSBundle bundleForClass:[CWVBundleLocator class]]);
} }
} // namespace ios_web_view } // namespace ios_web_view
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment