feat: redesign preload APIs (#45329)
* feat: redesign preload APIs Co-authored-by: Samuel Maddock <samuel.maddock@gmail.com> * docs: remove service-worker mentions for now Co-authored-by: Samuel Maddock <samuel.maddock@gmail.com> * fix lint Co-authored-by: Samuel Maddock <samuel.maddock@gmail.com> * remove service-worker ipc code Co-authored-by: Samuel Maddock <samuel.maddock@gmail.com> * add filename Co-authored-by: Samuel Maddock <samuel.maddock@gmail.com> * fix: web preferences preload not included Co-authored-by: Samuel Maddock <samuel.maddock@gmail.com> * fix: missing common init Co-authored-by: Samuel Maddock <samuel.maddock@gmail.com> * fix: preload bundle script error Co-authored-by: Samuel Maddock <samuel.maddock@gmail.com> --------- Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com> Co-authored-by: Samuel Maddock <samuel.maddock@gmail.com>
This commit is contained in:
parent
e9b3e4cc91
commit
9d696ceffe
19 changed files with 459 additions and 149 deletions
|
@ -3757,16 +3757,15 @@ void WebContents::DoGetZoomLevel(
|
|||
std::move(callback).Run(GetZoomLevel());
|
||||
}
|
||||
|
||||
std::vector<base::FilePath> WebContents::GetPreloadPaths() const {
|
||||
auto result = SessionPreferences::GetValidPreloads(GetBrowserContext());
|
||||
|
||||
std::optional<PreloadScript> WebContents::GetPreloadScript() const {
|
||||
if (auto* web_preferences = WebContentsPreferences::From(web_contents())) {
|
||||
if (auto preload = web_preferences->GetPreloadPath()) {
|
||||
result.emplace_back(*preload);
|
||||
auto preload_script = PreloadScript{
|
||||
"", PreloadScript::ScriptType::kWebFrame, preload.value()};
|
||||
return preload_script;
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
v8::Local<v8::Value> WebContents::GetLastWebPreferences(
|
||||
|
@ -4520,7 +4519,7 @@ void WebContents::FillObjectTemplate(v8::Isolate* isolate,
|
|||
.SetMethod("setZoomFactor", &WebContents::SetZoomFactor)
|
||||
.SetMethod("getZoomFactor", &WebContents::GetZoomFactor)
|
||||
.SetMethod("getType", &WebContents::type)
|
||||
.SetMethod("_getPreloadPaths", &WebContents::GetPreloadPaths)
|
||||
.SetMethod("_getPreloadScript", &WebContents::GetPreloadScript)
|
||||
.SetMethod("getLastWebPreferences", &WebContents::GetLastWebPreferences)
|
||||
.SetMethod("getOwnerBrowserWindow", &WebContents::GetOwnerBrowserWindow)
|
||||
.SetMethod("inspectServiceWorker", &WebContents::InspectServiceWorker)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue