refactor: rename managed_web_contents to inspectable_web_contents (#26525)
This commit is contained in:
parent
29211a51df
commit
b8372fdc29
7 changed files with 87 additions and 83 deletions
|
@ -87,7 +87,7 @@ BrowserView::BrowserView(gin::Arguments* args,
|
||||||
Observe(web_contents->web_contents());
|
Observe(web_contents->web_contents());
|
||||||
|
|
||||||
view_.reset(
|
view_.reset(
|
||||||
NativeBrowserView::Create(api_web_contents_->managed_web_contents()));
|
NativeBrowserView::Create(api_web_contents_->inspectable_web_contents()));
|
||||||
}
|
}
|
||||||
|
|
||||||
BrowserView::~BrowserView() {
|
BrowserView::~BrowserView() {
|
||||||
|
|
|
@ -95,7 +95,8 @@ BrowserWindow::BrowserWindow(gin::Arguments* args,
|
||||||
SetContentView(gin::CreateHandle<View>(isolate, web_contents_view.get()));
|
SetContentView(gin::CreateHandle<View>(isolate, web_contents_view.get()));
|
||||||
|
|
||||||
#if defined(OS_MAC)
|
#if defined(OS_MAC)
|
||||||
OverrideNSWindowContentView(web_contents->managed_web_contents());
|
OverrideNSWindowContentView(
|
||||||
|
web_contents->inspectable_web_contents()->GetView());
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Init window after everything has been setup.
|
// Init window after everything has been setup.
|
||||||
|
|
|
@ -97,7 +97,7 @@ class BrowserWindow : public BaseWindow,
|
||||||
|
|
||||||
private:
|
private:
|
||||||
#if defined(OS_MAC)
|
#if defined(OS_MAC)
|
||||||
void OverrideNSWindowContentView(InspectableWebContents* iwc);
|
void OverrideNSWindowContentView(InspectableWebContentsView* webView);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Helpers.
|
// Helpers.
|
||||||
|
|
|
@ -19,11 +19,12 @@ namespace electron {
|
||||||
|
|
||||||
namespace api {
|
namespace api {
|
||||||
|
|
||||||
void BrowserWindow::OverrideNSWindowContentView(InspectableWebContents* iwc) {
|
void BrowserWindow::OverrideNSWindowContentView(
|
||||||
|
InspectableWebContentsView* view) {
|
||||||
// Make NativeWindow use a NSView as content view.
|
// Make NativeWindow use a NSView as content view.
|
||||||
static_cast<NativeWindowMac*>(window())->OverrideNSWindowContentView();
|
static_cast<NativeWindowMac*>(window())->OverrideNSWindowContentView();
|
||||||
// Add webview to contentView.
|
// Add webview to contentView.
|
||||||
NSView* webView = iwc->GetView()->GetNativeView().GetNativeNSView();
|
NSView* webView = view->GetNativeView().GetNativeNSView();
|
||||||
NSView* contentView =
|
NSView* contentView =
|
||||||
[window()->GetNativeWindow().GetNativeNSWindow() contentView];
|
[window()->GetNativeWindow().GetNativeNSWindow() contentView];
|
||||||
[webView setFrame:[contentView bounds]];
|
[webView setFrame:[contentView bounds]];
|
||||||
|
|
|
@ -750,7 +750,7 @@ void WebContents::InitWithSessionAndOptions(
|
||||||
InitWithWebContents(owned_web_contents.release(), session->browser_context(),
|
InitWithWebContents(owned_web_contents.release(), session->browser_context(),
|
||||||
IsGuest());
|
IsGuest());
|
||||||
|
|
||||||
managed_web_contents()->GetView()->SetDelegate(this);
|
inspectable_web_contents_->GetView()->SetDelegate(this);
|
||||||
|
|
||||||
auto* prefs = web_contents()->GetMutableRendererPrefs();
|
auto* prefs = web_contents()->GetMutableRendererPrefs();
|
||||||
|
|
||||||
|
@ -843,7 +843,7 @@ void WebContents::InitWithExtensionView(v8::Isolate* isolate,
|
||||||
// Allow toggling DevTools for background pages
|
// Allow toggling DevTools for background pages
|
||||||
Observe(web_contents);
|
Observe(web_contents);
|
||||||
InitWithWebContents(web_contents, GetBrowserContext(), IsGuest());
|
InitWithWebContents(web_contents, GetBrowserContext(), IsGuest());
|
||||||
managed_web_contents()->GetView()->SetDelegate(this);
|
inspectable_web_contents_->GetView()->SetDelegate(this);
|
||||||
SecurityStateTabHelper::CreateForWebContents(web_contents);
|
SecurityStateTabHelper::CreateForWebContents(web_contents);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -872,23 +872,23 @@ void WebContents::InitWithWebContents(content::WebContents* web_contents,
|
||||||
web_preferences && web_preferences->IsEnabled(options::kOffscreen);
|
web_preferences && web_preferences->IsEnabled(options::kOffscreen);
|
||||||
|
|
||||||
// Create InspectableWebContents.
|
// Create InspectableWebContents.
|
||||||
web_contents_.reset(new InspectableWebContents(
|
inspectable_web_contents_.reset(new InspectableWebContents(
|
||||||
web_contents, browser_context->prefs(), is_guest));
|
web_contents, browser_context->prefs(), is_guest));
|
||||||
web_contents_->SetDelegate(this);
|
inspectable_web_contents_->SetDelegate(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
WebContents::~WebContents() {
|
WebContents::~WebContents() {
|
||||||
MarkDestroyed();
|
MarkDestroyed();
|
||||||
// The destroy() is called.
|
// The destroy() is called.
|
||||||
if (managed_web_contents()) {
|
if (inspectable_web_contents_) {
|
||||||
#if BUILDFLAG(ENABLE_ELECTRON_EXTENSIONS)
|
#if BUILDFLAG(ENABLE_ELECTRON_EXTENSIONS)
|
||||||
if (type_ == Type::kBackgroundPage) {
|
if (type_ == Type::kBackgroundPage) {
|
||||||
// Background pages are owned by extensions::ExtensionHost
|
// Background pages are owned by extensions::ExtensionHost
|
||||||
managed_web_contents()->ReleaseWebContents();
|
inspectable_web_contents_->ReleaseWebContents();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
managed_web_contents()->GetView()->SetDelegate(nullptr);
|
inspectable_web_contents_->GetView()->SetDelegate(nullptr);
|
||||||
|
|
||||||
if (web_contents()) {
|
if (web_contents()) {
|
||||||
RenderViewDeleted(web_contents()->GetRenderViewHost());
|
RenderViewDeleted(web_contents()->GetRenderViewHost());
|
||||||
|
@ -1102,8 +1102,8 @@ void WebContents::CloseContents(content::WebContents* source) {
|
||||||
autofill_driver_factory->CloseAllPopups();
|
autofill_driver_factory->CloseAllPopups();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (managed_web_contents())
|
if (inspectable_web_contents_)
|
||||||
managed_web_contents()->GetView()->SetDelegate(nullptr);
|
inspectable_web_contents_->GetView()->SetDelegate(nullptr);
|
||||||
for (ExtendedWebContentsObserver& observer : observers_)
|
for (ExtendedWebContentsObserver& observer : observers_)
|
||||||
observer.OnCloseContents();
|
observer.OnCloseContents();
|
||||||
}
|
}
|
||||||
|
@ -1729,18 +1729,18 @@ void WebContents::DevToolsOpened() {
|
||||||
v8::Isolate* isolate = JavascriptEnvironment::GetIsolate();
|
v8::Isolate* isolate = JavascriptEnvironment::GetIsolate();
|
||||||
v8::Locker locker(isolate);
|
v8::Locker locker(isolate);
|
||||||
v8::HandleScope handle_scope(isolate);
|
v8::HandleScope handle_scope(isolate);
|
||||||
DCHECK(managed_web_contents());
|
DCHECK(inspectable_web_contents_);
|
||||||
auto handle =
|
auto handle = FromOrCreate(
|
||||||
FromOrCreate(isolate, managed_web_contents()->GetDevToolsWebContents());
|
isolate, inspectable_web_contents_->GetDevToolsWebContents());
|
||||||
devtools_web_contents_.Reset(isolate, handle.ToV8());
|
devtools_web_contents_.Reset(isolate, handle.ToV8());
|
||||||
|
|
||||||
// Set inspected tabID.
|
// Set inspected tabID.
|
||||||
base::Value tab_id(ID());
|
base::Value tab_id(ID());
|
||||||
managed_web_contents()->CallClientFunction("DevToolsAPI.setInspectedTabId",
|
inspectable_web_contents_->CallClientFunction("DevToolsAPI.setInspectedTabId",
|
||||||
&tab_id, nullptr, nullptr);
|
&tab_id, nullptr, nullptr);
|
||||||
|
|
||||||
// Inherit owner window in devtools when it doesn't have one.
|
// Inherit owner window in devtools when it doesn't have one.
|
||||||
auto* devtools = managed_web_contents()->GetDevToolsWebContents();
|
auto* devtools = inspectable_web_contents_->GetDevToolsWebContents();
|
||||||
bool has_window = devtools->GetUserData(NativeWindowRelay::UserDataKey());
|
bool has_window = devtools->GetUserData(NativeWindowRelay::UserDataKey());
|
||||||
if (owner_window() && !has_window)
|
if (owner_window() && !has_window)
|
||||||
handle->SetOwnerWindow(devtools, owner_window());
|
handle->SetOwnerWindow(devtools, owner_window());
|
||||||
|
@ -1800,23 +1800,23 @@ void WebContents::ResetManagedWebContents(bool async) {
|
||||||
// is destroyed.
|
// is destroyed.
|
||||||
// //electron/patches/chromium/content_browser_main_loop.patch
|
// //electron/patches/chromium/content_browser_main_loop.patch
|
||||||
// is required to get the right quit closure for the main message loop.
|
// is required to get the right quit closure for the main message loop.
|
||||||
base::ThreadTaskRunnerHandle::Get()->DeleteSoon(FROM_HERE,
|
base::ThreadTaskRunnerHandle::Get()->DeleteSoon(
|
||||||
web_contents_.release());
|
FROM_HERE, inspectable_web_contents_.release());
|
||||||
} else {
|
} else {
|
||||||
web_contents_.reset();
|
inspectable_web_contents_.reset();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
content::WebContents* WebContents::GetWebContents() const {
|
content::WebContents* WebContents::GetWebContents() const {
|
||||||
if (!web_contents_)
|
if (!inspectable_web_contents_)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
return web_contents_->GetWebContents();
|
return inspectable_web_contents_->GetWebContents();
|
||||||
}
|
}
|
||||||
|
|
||||||
content::WebContents* WebContents::GetDevToolsWebContents() const {
|
content::WebContents* WebContents::GetDevToolsWebContents() const {
|
||||||
if (!web_contents_)
|
if (!inspectable_web_contents_)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
return web_contents_->GetDevToolsWebContents();
|
return inspectable_web_contents_->GetDevToolsWebContents();
|
||||||
}
|
}
|
||||||
|
|
||||||
void WebContents::MarkDestroyed() {
|
void WebContents::MarkDestroyed() {
|
||||||
|
@ -1860,8 +1860,8 @@ void WebContents::WebContentsDestroyed() {
|
||||||
|
|
||||||
// For guest view based on OOPIF, the WebContents is released by the embedder
|
// For guest view based on OOPIF, the WebContents is released by the embedder
|
||||||
// frame, and we need to clear the reference to the memory.
|
// frame, and we need to clear the reference to the memory.
|
||||||
if (IsGuest() && managed_web_contents()) {
|
if (IsGuest() && inspectable_web_contents_) {
|
||||||
managed_web_contents()->ReleaseWebContents();
|
inspectable_web_contents_->ReleaseWebContents();
|
||||||
ResetManagedWebContents(false);
|
ResetManagedWebContents(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2151,33 +2151,33 @@ void WebContents::OpenDevTools(gin::Arguments* args) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
DCHECK(managed_web_contents());
|
DCHECK(inspectable_web_contents_);
|
||||||
managed_web_contents()->SetDockState(state);
|
inspectable_web_contents_->SetDockState(state);
|
||||||
managed_web_contents()->ShowDevTools(activate);
|
inspectable_web_contents_->ShowDevTools(activate);
|
||||||
}
|
}
|
||||||
|
|
||||||
void WebContents::CloseDevTools() {
|
void WebContents::CloseDevTools() {
|
||||||
if (type_ == Type::kRemote)
|
if (type_ == Type::kRemote)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
DCHECK(managed_web_contents());
|
DCHECK(inspectable_web_contents_);
|
||||||
managed_web_contents()->CloseDevTools();
|
inspectable_web_contents_->CloseDevTools();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool WebContents::IsDevToolsOpened() {
|
bool WebContents::IsDevToolsOpened() {
|
||||||
if (type_ == Type::kRemote)
|
if (type_ == Type::kRemote)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
DCHECK(managed_web_contents());
|
DCHECK(inspectable_web_contents_);
|
||||||
return managed_web_contents()->IsDevToolsViewShowing();
|
return inspectable_web_contents_->IsDevToolsViewShowing();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool WebContents::IsDevToolsFocused() {
|
bool WebContents::IsDevToolsFocused() {
|
||||||
if (type_ == Type::kRemote)
|
if (type_ == Type::kRemote)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
DCHECK(managed_web_contents());
|
DCHECK(inspectable_web_contents_);
|
||||||
return managed_web_contents()->GetView()->IsDevToolsViewFocused();
|
return inspectable_web_contents_->GetView()->IsDevToolsViewFocused();
|
||||||
}
|
}
|
||||||
|
|
||||||
void WebContents::EnableDeviceEmulation(
|
void WebContents::EnableDeviceEmulation(
|
||||||
|
@ -2231,10 +2231,10 @@ void WebContents::InspectElement(int x, int y) {
|
||||||
if (!enable_devtools_)
|
if (!enable_devtools_)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
DCHECK(managed_web_contents());
|
DCHECK(inspectable_web_contents_);
|
||||||
if (!managed_web_contents()->GetDevToolsWebContents())
|
if (!inspectable_web_contents_->GetDevToolsWebContents())
|
||||||
OpenDevTools(nullptr);
|
OpenDevTools(nullptr);
|
||||||
managed_web_contents()->InspectElement(x, y);
|
inspectable_web_contents_->InspectElement(x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
void WebContents::InspectSharedWorkerById(const std::string& workerId) {
|
void WebContents::InspectSharedWorkerById(const std::string& workerId) {
|
||||||
|
@ -2249,7 +2249,7 @@ void WebContents::InspectSharedWorkerById(const std::string& workerId) {
|
||||||
content::DevToolsAgentHost::kTypeSharedWorker) {
|
content::DevToolsAgentHost::kTypeSharedWorker) {
|
||||||
if (agent_host->GetId() == workerId) {
|
if (agent_host->GetId() == workerId) {
|
||||||
OpenDevTools(nullptr);
|
OpenDevTools(nullptr);
|
||||||
managed_web_contents()->AttachTo(agent_host);
|
inspectable_web_contents_->AttachTo(agent_host);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2286,7 +2286,7 @@ void WebContents::InspectSharedWorker() {
|
||||||
if (agent_host->GetType() ==
|
if (agent_host->GetType() ==
|
||||||
content::DevToolsAgentHost::kTypeSharedWorker) {
|
content::DevToolsAgentHost::kTypeSharedWorker) {
|
||||||
OpenDevTools(nullptr);
|
OpenDevTools(nullptr);
|
||||||
managed_web_contents()->AttachTo(agent_host);
|
inspectable_web_contents_->AttachTo(agent_host);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2303,7 +2303,7 @@ void WebContents::InspectServiceWorker() {
|
||||||
if (agent_host->GetType() ==
|
if (agent_host->GetType() ==
|
||||||
content::DevToolsAgentHost::kTypeServiceWorker) {
|
content::DevToolsAgentHost::kTypeServiceWorker) {
|
||||||
OpenDevTools(nullptr);
|
OpenDevTools(nullptr);
|
||||||
managed_web_contents()->AttachTo(agent_host);
|
inspectable_web_contents_->AttachTo(agent_host);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3114,8 +3114,8 @@ void WebContents::SetEmbedder(const WebContents* embedder) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void WebContents::SetDevToolsWebContents(const WebContents* devtools) {
|
void WebContents::SetDevToolsWebContents(const WebContents* devtools) {
|
||||||
if (managed_web_contents())
|
if (inspectable_web_contents_)
|
||||||
managed_web_contents()->SetDevToolsWebContents(devtools->web_contents());
|
inspectable_web_contents_->SetDevToolsWebContents(devtools->web_contents());
|
||||||
}
|
}
|
||||||
|
|
||||||
v8::Local<v8::Value> WebContents::GetNativeView(v8::Isolate* isolate) const {
|
v8::Local<v8::Value> WebContents::GetNativeView(v8::Isolate* isolate) const {
|
||||||
|
@ -3311,8 +3311,8 @@ void WebContents::DevToolsSaveToFile(const std::string& url,
|
||||||
settings.default_path = base::FilePath::FromUTF8Unsafe(url);
|
settings.default_path = base::FilePath::FromUTF8Unsafe(url);
|
||||||
if (!file_dialog::ShowSaveDialogSync(settings, &path)) {
|
if (!file_dialog::ShowSaveDialogSync(settings, &path)) {
|
||||||
base::Value url_value(url);
|
base::Value url_value(url);
|
||||||
web_contents_->CallClientFunction("DevToolsAPI.canceledSaveURL",
|
inspectable_web_contents_->CallClientFunction(
|
||||||
&url_value, nullptr, nullptr);
|
"DevToolsAPI.canceledSaveURL", &url_value, nullptr, nullptr);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3321,8 +3321,8 @@ void WebContents::DevToolsSaveToFile(const std::string& url,
|
||||||
// Notify DevTools.
|
// Notify DevTools.
|
||||||
base::Value url_value(url);
|
base::Value url_value(url);
|
||||||
base::Value file_system_path_value(path.AsUTF8Unsafe());
|
base::Value file_system_path_value(path.AsUTF8Unsafe());
|
||||||
web_contents_->CallClientFunction("DevToolsAPI.savedURL", &url_value,
|
inspectable_web_contents_->CallClientFunction(
|
||||||
&file_system_path_value, nullptr);
|
"DevToolsAPI.savedURL", &url_value, &file_system_path_value, nullptr);
|
||||||
file_task_runner_->PostTask(FROM_HERE,
|
file_task_runner_->PostTask(FROM_HERE,
|
||||||
base::BindOnce(&WriteToFile, path, content));
|
base::BindOnce(&WriteToFile, path, content));
|
||||||
}
|
}
|
||||||
|
@ -3335,8 +3335,8 @@ void WebContents::DevToolsAppendToFile(const std::string& url,
|
||||||
|
|
||||||
// Notify DevTools.
|
// Notify DevTools.
|
||||||
base::Value url_value(url);
|
base::Value url_value(url);
|
||||||
web_contents_->CallClientFunction("DevToolsAPI.appendedToURL", &url_value,
|
inspectable_web_contents_->CallClientFunction("DevToolsAPI.appendedToURL",
|
||||||
nullptr, nullptr);
|
&url_value, nullptr, nullptr);
|
||||||
file_task_runner_->PostTask(
|
file_task_runner_->PostTask(
|
||||||
FROM_HERE, base::BindOnce(&AppendToFile, it->second, content));
|
FROM_HERE, base::BindOnce(&AppendToFile, it->second, content));
|
||||||
}
|
}
|
||||||
|
@ -3345,9 +3345,9 @@ void WebContents::DevToolsRequestFileSystems() {
|
||||||
auto file_system_paths = GetAddedFileSystemPaths(GetDevToolsWebContents());
|
auto file_system_paths = GetAddedFileSystemPaths(GetDevToolsWebContents());
|
||||||
if (file_system_paths.empty()) {
|
if (file_system_paths.empty()) {
|
||||||
base::ListValue empty_file_system_value;
|
base::ListValue empty_file_system_value;
|
||||||
web_contents_->CallClientFunction("DevToolsAPI.fileSystemsLoaded",
|
inspectable_web_contents_->CallClientFunction(
|
||||||
&empty_file_system_value, nullptr,
|
"DevToolsAPI.fileSystemsLoaded", &empty_file_system_value, nullptr,
|
||||||
nullptr);
|
nullptr);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3366,8 +3366,8 @@ void WebContents::DevToolsRequestFileSystems() {
|
||||||
base::ListValue file_system_value;
|
base::ListValue file_system_value;
|
||||||
for (const auto& file_system : file_systems)
|
for (const auto& file_system : file_systems)
|
||||||
file_system_value.Append(CreateFileSystemValue(file_system));
|
file_system_value.Append(CreateFileSystemValue(file_system));
|
||||||
web_contents_->CallClientFunction("DevToolsAPI.fileSystemsLoaded",
|
inspectable_web_contents_->CallClientFunction(
|
||||||
&file_system_value, nullptr, nullptr);
|
"DevToolsAPI.fileSystemsLoaded", &file_system_value, nullptr, nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
void WebContents::DevToolsAddFileSystem(
|
void WebContents::DevToolsAddFileSystem(
|
||||||
|
@ -3400,13 +3400,13 @@ void WebContents::DevToolsAddFileSystem(
|
||||||
DictionaryPrefUpdate update(pref_service, prefs::kDevToolsFileSystemPaths);
|
DictionaryPrefUpdate update(pref_service, prefs::kDevToolsFileSystemPaths);
|
||||||
update.Get()->SetWithoutPathExpansion(path.AsUTF8Unsafe(),
|
update.Get()->SetWithoutPathExpansion(path.AsUTF8Unsafe(),
|
||||||
std::make_unique<base::Value>(type));
|
std::make_unique<base::Value>(type));
|
||||||
web_contents_->CallClientFunction("DevToolsAPI.fileSystemAdded", nullptr,
|
inspectable_web_contents_->CallClientFunction(
|
||||||
file_system_value.get(), nullptr);
|
"DevToolsAPI.fileSystemAdded", nullptr, file_system_value.get(), nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
void WebContents::DevToolsRemoveFileSystem(
|
void WebContents::DevToolsRemoveFileSystem(
|
||||||
const base::FilePath& file_system_path) {
|
const base::FilePath& file_system_path) {
|
||||||
if (!web_contents_)
|
if (!inspectable_web_contents_)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
std::string path = file_system_path.AsUTF8Unsafe();
|
std::string path = file_system_path.AsUTF8Unsafe();
|
||||||
|
@ -3418,8 +3418,9 @@ void WebContents::DevToolsRemoveFileSystem(
|
||||||
update.Get()->RemoveWithoutPathExpansion(path, nullptr);
|
update.Get()->RemoveWithoutPathExpansion(path, nullptr);
|
||||||
|
|
||||||
base::Value file_system_path_value(path);
|
base::Value file_system_path_value(path);
|
||||||
web_contents_->CallClientFunction("DevToolsAPI.fileSystemRemoved",
|
inspectable_web_contents_->CallClientFunction("DevToolsAPI.fileSystemRemoved",
|
||||||
&file_system_path_value, nullptr, nullptr);
|
&file_system_path_value,
|
||||||
|
nullptr, nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
void WebContents::DevToolsIndexPath(
|
void WebContents::DevToolsIndexPath(
|
||||||
|
@ -3502,9 +3503,9 @@ void WebContents::OnDevToolsIndexingWorkCalculated(
|
||||||
base::Value request_id_value(request_id);
|
base::Value request_id_value(request_id);
|
||||||
base::Value file_system_path_value(file_system_path);
|
base::Value file_system_path_value(file_system_path);
|
||||||
base::Value total_work_value(total_work);
|
base::Value total_work_value(total_work);
|
||||||
web_contents_->CallClientFunction("DevToolsAPI.indexingTotalWorkCalculated",
|
inspectable_web_contents_->CallClientFunction(
|
||||||
&request_id_value, &file_system_path_value,
|
"DevToolsAPI.indexingTotalWorkCalculated", &request_id_value,
|
||||||
&total_work_value);
|
&file_system_path_value, &total_work_value);
|
||||||
}
|
}
|
||||||
|
|
||||||
void WebContents::OnDevToolsIndexingWorked(int request_id,
|
void WebContents::OnDevToolsIndexingWorked(int request_id,
|
||||||
|
@ -3513,9 +3514,9 @@ void WebContents::OnDevToolsIndexingWorked(int request_id,
|
||||||
base::Value request_id_value(request_id);
|
base::Value request_id_value(request_id);
|
||||||
base::Value file_system_path_value(file_system_path);
|
base::Value file_system_path_value(file_system_path);
|
||||||
base::Value worked_value(worked);
|
base::Value worked_value(worked);
|
||||||
web_contents_->CallClientFunction("DevToolsAPI.indexingWorked",
|
inspectable_web_contents_->CallClientFunction(
|
||||||
&request_id_value, &file_system_path_value,
|
"DevToolsAPI.indexingWorked", &request_id_value, &file_system_path_value,
|
||||||
&worked_value);
|
&worked_value);
|
||||||
}
|
}
|
||||||
|
|
||||||
void WebContents::OnDevToolsIndexingDone(int request_id,
|
void WebContents::OnDevToolsIndexingDone(int request_id,
|
||||||
|
@ -3523,9 +3524,9 @@ void WebContents::OnDevToolsIndexingDone(int request_id,
|
||||||
devtools_indexing_jobs_.erase(request_id);
|
devtools_indexing_jobs_.erase(request_id);
|
||||||
base::Value request_id_value(request_id);
|
base::Value request_id_value(request_id);
|
||||||
base::Value file_system_path_value(file_system_path);
|
base::Value file_system_path_value(file_system_path);
|
||||||
web_contents_->CallClientFunction("DevToolsAPI.indexingDone",
|
inspectable_web_contents_->CallClientFunction(
|
||||||
&request_id_value, &file_system_path_value,
|
"DevToolsAPI.indexingDone", &request_id_value, &file_system_path_value,
|
||||||
nullptr);
|
nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
void WebContents::OnDevToolsSearchCompleted(
|
void WebContents::OnDevToolsSearchCompleted(
|
||||||
|
@ -3538,9 +3539,9 @@ void WebContents::OnDevToolsSearchCompleted(
|
||||||
}
|
}
|
||||||
base::Value request_id_value(request_id);
|
base::Value request_id_value(request_id);
|
||||||
base::Value file_system_path_value(file_system_path);
|
base::Value file_system_path_value(file_system_path);
|
||||||
web_contents_->CallClientFunction("DevToolsAPI.searchCompleted",
|
inspectable_web_contents_->CallClientFunction(
|
||||||
&request_id_value, &file_system_path_value,
|
"DevToolsAPI.searchCompleted", &request_id_value, &file_system_path_value,
|
||||||
&file_paths_value);
|
&file_paths_value);
|
||||||
}
|
}
|
||||||
|
|
||||||
void WebContents::SetHtmlApiFullscreen(bool enter_fullscreen) {
|
void WebContents::SetHtmlApiFullscreen(bool enter_fullscreen) {
|
||||||
|
|
|
@ -403,8 +403,8 @@ class WebContents : public gin::Wrappable<WebContents>,
|
||||||
// Returns the WebContents of devtools.
|
// Returns the WebContents of devtools.
|
||||||
content::WebContents* GetDevToolsWebContents() const;
|
content::WebContents* GetDevToolsWebContents() const;
|
||||||
|
|
||||||
InspectableWebContents* managed_web_contents() const {
|
InspectableWebContents* inspectable_web_contents() const {
|
||||||
return web_contents_.get();
|
return inspectable_web_contents_.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
NativeWindow* owner_window() const { return owner_window_.get(); }
|
NativeWindow* owner_window() const { return owner_window_.get(); }
|
||||||
|
@ -767,10 +767,10 @@ class WebContents : public gin::Wrappable<WebContents>,
|
||||||
ElectronBrowserContext* browser_context_;
|
ElectronBrowserContext* browser_context_;
|
||||||
|
|
||||||
// The stored InspectableWebContents object.
|
// The stored InspectableWebContents object.
|
||||||
// Notice that web_contents_ must be placed after dialog_manager_, so we can
|
// Notice that inspectable_web_contents_ must be placed after
|
||||||
// make sure web_contents_ is destroyed before dialog_manager_, otherwise a
|
// dialog_manager_, so we can make sure inspectable_web_contents_ is
|
||||||
// crash would happen.
|
// destroyed before dialog_manager_, otherwise a crash would happen.
|
||||||
std::unique_ptr<InspectableWebContents> web_contents_;
|
std::unique_ptr<InspectableWebContents> inspectable_web_contents_;
|
||||||
|
|
||||||
// Maps url to file path, used by the file requests sent from devtools.
|
// Maps url to file path, used by the file requests sent from devtools.
|
||||||
typedef std::map<std::string, base::FilePath> PathsMap;
|
typedef std::map<std::string, base::FilePath> PathsMap;
|
||||||
|
|
|
@ -26,10 +26,11 @@ namespace api {
|
||||||
WebContentsView::WebContentsView(v8::Isolate* isolate,
|
WebContentsView::WebContentsView(v8::Isolate* isolate,
|
||||||
gin::Handle<WebContents> web_contents)
|
gin::Handle<WebContents> web_contents)
|
||||||
#if defined(OS_MAC)
|
#if defined(OS_MAC)
|
||||||
: View(new DelayedNativeViewHost(
|
: View(new DelayedNativeViewHost(web_contents->inspectable_web_contents()
|
||||||
web_contents->managed_web_contents()->GetView()->GetNativeView())),
|
->GetView()
|
||||||
|
->GetNativeView())),
|
||||||
#else
|
#else
|
||||||
: View(web_contents->managed_web_contents()->GetView()->GetView()),
|
: View(web_contents->inspectable_web_contents()->GetView()->GetView()),
|
||||||
#endif
|
#endif
|
||||||
web_contents_(isolate, web_contents.ToV8()),
|
web_contents_(isolate, web_contents.ToV8()),
|
||||||
api_web_contents_(web_contents.get()) {
|
api_web_contents_(web_contents.get()) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue