Skip to content

Commit

Permalink
Backup
Browse files Browse the repository at this point in the history
  • Loading branch information
Brandon-T committed Jan 15, 2025
1 parent 9f95b5f commit 6a0aa48
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 27 deletions.
46 changes: 19 additions & 27 deletions chromium_src/ios/web/public/web_state.h
Original file line number Diff line number Diff line change
@@ -1,31 +1,23 @@

#define callbacks_ \
callbacks_; \
\
public: \
template <typename Interface> \
void AddUntrustedInterface( \
std::string_view interface_name, \
base::RepeatingCallback<void(mojo::PendingReceiver<Interface>)> \
callback) { \
if (auto it = untrusted_callbacks_.find(std::string(interface_name)); \
it != untrusted_callbacks_.end()) { \
it->second.emplace( \
base::BindRepeating(&WrapCallback<Interface>, std::move(callback))); \
} else { \
untrusted_callbacks_.emplace( \
std::string(interface_name), \
{base::BindRepeating(&WrapCallback<Interface>, \
std::move(callback))}); \
} \
} \
bool GetUntrustedInterfaces(std::string_view interface_name) const { \
return untrusted_callbacks_.find(std::string(interface_name)) != \
untrusted_callbacks_.end(); \
} \
\
private: \
std::map<std::string, std::vector<Callback>> untrusted_callbacks_
#define callbacks_ \
callbacks_; \
\
public: \
template <typename Interface> \
void AddUntrustedInterface( \
const GURL& url, \
base::RepeatingCallback<void(mojo::PendingReceiver<Interface>)> \
callback) { \
CHECK(!url.is_empty()); \
untrusted_callbacks_[url].emplace( \
std::string(Interface::Name_), \
base::BindRepeating(&WrapCallback<Interface>, std::move(callback))); \
} \
void BindUntrustedInterface(const GURL& url, \
mojo::GenericPendingReceiver receiver); \
\
private: \
std::map<GURL, std::map<std::string, Callback>> untrusted_callbacks_

#include "src/ios/web/public/web_state.h"

Expand Down
17 changes: 17 additions & 0 deletions chromium_src/ios/web/web_state/web_state.mm
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@

#include "src/ios/web/web_state/web_state.mm"

namespace web {
void WebState::InterfaceBinder::BindUntrustedInterface(const GURL& url, mojo::GenericPendingReceiver receiver) {
DCHECK(!url.is_empty());
DCHECK(receiver.is_valid());
if (auto it = untrusted_callbacks_.find(url); it != untrusted_callbacks_.end()) {
if (auto jt = it->second.find(*receiver.interface_name()); jt != it->second.end()) {
jt->second.Run(&receiver);

GetWebClient()->BindInterfaceReceiverFromMainFrame(web_state_,
std::move(receiver));
}
}
}
} // namespace web

0 comments on commit 6a0aa48

Please sign in to comment.