mirror of
https://github.com/electron/electron.git
synced 2026-02-26 03:01:17 -05:00
* fix: prevent destroyed view references from causing crashes * Remove extraneous comments * Relocate crash test to proper location * Add WebContentsObserver * Add nullptr check and inspectable observer * Remote initial test file * Add test cases to test file * Rename and move testing file * Fix linting errors * Make functions exit early on check * Fix setBackgroundColor function call in test file * Fix styling of test file * Fix mac name mismatch and make variable name more clear Co-authored-by: Michaela Laurencin <mlaurencin@microsoft.com>
39 lines
1.0 KiB
C++
39 lines
1.0 KiB
C++
// Copyright (c) 2017 GitHub, Inc.
|
|
// Use of this source code is governed by the MIT license that can be
|
|
// found in the LICENSE file.
|
|
|
|
#include <vector>
|
|
|
|
#include "shell/browser/native_browser_view.h"
|
|
|
|
#include "shell/browser/api/electron_api_web_contents.h"
|
|
#include "shell/browser/ui/inspectable_web_contents.h"
|
|
|
|
namespace electron {
|
|
|
|
NativeBrowserView::NativeBrowserView(
|
|
InspectableWebContents* inspectable_web_contents)
|
|
: inspectable_web_contents_(inspectable_web_contents) {
|
|
Observe(inspectable_web_contents_->GetWebContents());
|
|
}
|
|
|
|
NativeBrowserView::~NativeBrowserView() = default;
|
|
|
|
InspectableWebContentsView* NativeBrowserView::GetInspectableWebContentsView() {
|
|
if (!inspectable_web_contents_)
|
|
return nullptr;
|
|
return inspectable_web_contents_->GetView();
|
|
}
|
|
|
|
content::WebContents* NativeBrowserView::GetWebContents() {
|
|
if (!inspectable_web_contents_)
|
|
return nullptr;
|
|
return inspectable_web_contents_->GetWebContents();
|
|
}
|
|
|
|
void NativeBrowserView::WebContentsDestroyed() {
|
|
inspectable_web_contents_ = nullptr;
|
|
}
|
|
|
|
} // namespace electron
|