Merge pull request #29180 from brave/szilard/46270-adds-createandadd-to-bravewebuiiosdatasource
Adds `BraveWebUIIOSDataSource::CreateAndAdd()`
This commit is contained in:
@@ -14,9 +14,16 @@
|
||||
#include "ios/web/webui/web_ui_ios_data_source_impl.h"
|
||||
#include "services/network/public/mojom/content_security_policy.mojom.h"
|
||||
|
||||
namespace web {
|
||||
class BrowserState;
|
||||
}
|
||||
|
||||
class BraveWebUIIOSDataSource : public web::WebUIIOSDataSourceImpl {
|
||||
public:
|
||||
static web::WebUIIOSDataSource* Create(const std::string& source_name);
|
||||
static BraveWebUIIOSDataSource* Create(const std::string& source_name);
|
||||
|
||||
static BraveWebUIIOSDataSource* CreateAndAdd(web::BrowserState* browser_state,
|
||||
const std::string& source_name);
|
||||
|
||||
BraveWebUIIOSDataSource(const BraveWebUIIOSDataSource&) = delete;
|
||||
BraveWebUIIOSDataSource& operator=(const BraveWebUIIOSDataSource&) = delete;
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
#include "brave/ios/browser/ui/webui/brave_url_data_source_ios.h"
|
||||
#include "ios/chrome/browser/shared/model/url/chrome_url_constants.h"
|
||||
#include "ios/components/webui/web_ui_url_constants.h"
|
||||
#include "ios/web/public/browser_state.h"
|
||||
#include "ios/web/public/web_client.h"
|
||||
#include "ios/web/public/webui/url_data_source_ios.h"
|
||||
#include "ios/web/public/webui/web_ui_ios_data_source.h"
|
||||
@@ -23,11 +24,20 @@
|
||||
#include "ui/base/webui/web_ui_util.h"
|
||||
|
||||
// static
|
||||
web::WebUIIOSDataSource* BraveWebUIIOSDataSource::Create(
|
||||
BraveWebUIIOSDataSource* BraveWebUIIOSDataSource::Create(
|
||||
const std::string& source_name) {
|
||||
return new BraveWebUIIOSDataSource(source_name);
|
||||
}
|
||||
|
||||
// static
|
||||
BraveWebUIIOSDataSource* BraveWebUIIOSDataSource::CreateAndAdd(
|
||||
web::BrowserState* browser_state,
|
||||
const std::string& source_name) {
|
||||
auto* data_source = Create(source_name);
|
||||
web::WebUIIOSDataSource::Add(browser_state, data_source);
|
||||
return data_source;
|
||||
}
|
||||
|
||||
class BraveWebUIIOSDataSource::BraveInternalDataSource
|
||||
: public BraveURLDataSourceIOS {
|
||||
public:
|
||||
|
||||
@@ -36,8 +36,8 @@ web::WebUIIOSDataSource* CreateWebUIDataSource(
|
||||
base::span<const webui::ResourcePath> resource_paths,
|
||||
int html_resource_id,
|
||||
bool disable_trusted_types_csp) {
|
||||
web::WebUIIOSDataSource* source = BraveWebUIIOSDataSource::Create(name);
|
||||
web::WebUIIOSDataSource::Add(ProfileIOS::FromWebUIIOS(web_ui), source);
|
||||
web::WebUIIOSDataSource* source = BraveWebUIIOSDataSource::CreateAndAdd(
|
||||
ProfileIOS::FromWebUIIOS(web_ui), name);
|
||||
|
||||
source->UseStringsJs();
|
||||
source->AddResourcePaths(resource_paths);
|
||||
|
||||
Reference in New Issue
Block a user