Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: electron/electron
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v35.1.0
Choose a base ref
...
head repository: electron/electron
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v35.1.1
Choose a head ref
  • 3 commits
  • 11 files changed
  • 2 contributors

Commits on Mar 26, 2025

  1. perf: avoid redundant map lookup in WebFrameMain constructor (#46275)

    perf: avoid double map lookup in WebFrameMain constructor
    
    Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
    Co-authored-by: Charles Kerr <charles@charleskerr.com>
    trop[bot] and ckerr authored Mar 26, 2025
    Copy the full SHA
    a3ba653 View commit details
  2. refactor: add ElectronBrowserContext::GetDefaultBrowserContext() (#…

    …46085)
    
    * refactor: add ElectronBrowserContext::DestroyAllContexts()
    
    Simpler semantics than previous implementation; also hides the
    "default context must be destroyed last" implementation detail.
    
    Co-authored-by: Charles Kerr <charles@charleskerr.com>
    
    * refactor: add ElectronBrowserContext::GetDefaultBrowserContext()
    
    clearer semantics than everyone calling From("", false)
    
    Co-authored-by: Charles Kerr <charles@charleskerr.com>
    
    * fixup! refactor: add ElectronBrowserContext::DestroyAllContexts()
    
    fix: collision with 998de7a
    
    ---------
    
    Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
    Co-authored-by: Charles Kerr <charles@charleskerr.com>
    trop[bot] and ckerr authored Mar 26, 2025
    Copy the full SHA
    c6c6720 View commit details
  3. fix: build failure when printing is disabled (#46285)

    fix: ftbfs when printing is disabled
    
    Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
    Co-authored-by: Charles Kerr <charles@charleskerr.com>
    trop[bot] and ckerr authored Mar 26, 2025
    Copy the full SHA
    6e112a8 View commit details
2 changes: 1 addition & 1 deletion shell/browser/api/electron_api_global_shortcut.cc
Original file line number Diff line number Diff line change
@@ -122,7 +122,7 @@ bool GlobalShortcut::Register(const ui::Accelerator& accelerator,
}

if (instance->IsRegistrationHandledExternally()) {
auto* context = ElectronBrowserContext::From("", false);
auto* context = ElectronBrowserContext::GetDefaultBrowserContext();
PrefService* prefs = context->prefs();

// Need a unique profile id. Set one if not generated yet, otherwise re-use
2 changes: 1 addition & 1 deletion shell/browser/api/electron_api_session.cc
Original file line number Diff line number Diff line change
@@ -1779,7 +1779,7 @@ gin::Handle<Session> Session::FromPartition(v8::Isolate* isolate,
ElectronBrowserContext* browser_context;
if (partition.empty()) {
browser_context =
ElectronBrowserContext::From("", false, std::move(options));
ElectronBrowserContext::GetDefaultBrowserContext(std::move(options));
} else if (partition.starts_with(kPersistPrefix)) {
std::string name = partition.substr(8);
browser_context =
2 changes: 2 additions & 0 deletions shell/browser/api/electron_api_web_contents.cc
Original file line number Diff line number Diff line change
@@ -2079,6 +2079,7 @@ void WebContents::DraggableRegionsChanged(
draggable_region_ = DraggableRegionsToSkRegion(regions);
}

#if BUILDFLAG(ENABLE_PRINTING)
void WebContents::PrintCrossProcessSubframe(
content::WebContents* web_contents,
const gfx::Rect& rect,
@@ -2089,6 +2090,7 @@ void WebContents::PrintCrossProcessSubframe(
client->PrintCrossProcessSubframe(rect, document_cookie, subframe_host);
}
}
#endif

SkRegion* WebContents::draggable_region() {
return g_disable_draggable_regions ? nullptr : draggable_region_.get();
2 changes: 2 additions & 0 deletions shell/browser/api/electron_api_web_contents.h
Original file line number Diff line number Diff line change
@@ -630,11 +630,13 @@ class WebContents final : public ExclusiveAccessContext,
void DraggableRegionsChanged(
const std::vector<blink::mojom::DraggableRegionPtr>& regions,
content::WebContents* contents) override;
#if BUILDFLAG(ENABLE_PRINTING)
void PrintCrossProcessSubframe(
content::WebContents* web_contents,
const gfx::Rect& rect,
int document_cookie,
content::RenderFrameHost* subframe_host) const override;
#endif

// content::WebContentsObserver:
void BeforeUnloadFired(bool proceed) override;
4 changes: 2 additions & 2 deletions shell/browser/api/electron_api_web_frame_main.cc
Original file line number Diff line number Diff line change
@@ -155,8 +155,8 @@ WebFrameMain::WebFrameMain(content::RenderFrameHost* rfh)
if (!render_frame_detached_)
GetFrameTreeNodeIdMap().emplace(frame_tree_node_id_, this);

DCHECK(!GetFrameTokenMap().contains(frame_token_));
GetFrameTokenMap().emplace(frame_token_, this);
const auto [_, inserted] = GetFrameTokenMap().emplace(frame_token_, this);
DCHECK(inserted);

// WebFrameMain should only be created for active or unloading frames.
DCHECK(GetLifecycleState(rfh) == LifecycleState::kActive ||
6 changes: 6 additions & 0 deletions shell/browser/electron_browser_context.cc
Original file line number Diff line number Diff line change
@@ -882,6 +882,12 @@ ElectronBrowserContext* ElectronBrowserContext::From(
return context.get();
}

// static
ElectronBrowserContext* ElectronBrowserContext::GetDefaultBrowserContext(
base::Value::Dict options) {
return ElectronBrowserContext::From("", false, std::move(options));
}

ElectronBrowserContext* ElectronBrowserContext::FromPath(
const base::FilePath& path,
base::Value::Dict options) {
4 changes: 4 additions & 0 deletions shell/browser/electron_browser_context.h
Original file line number Diff line number Diff line change
@@ -63,6 +63,10 @@ class ElectronBrowserContext : public content::BrowserContext {

[[nodiscard]] static bool IsValidContext(const void* context);

// Get or create the default BrowserContext.
static ElectronBrowserContext* GetDefaultBrowserContext(
base::Value::Dict options = {});

// Get or create the BrowserContext according to its |partition| and
// |in_memory|. The |options| will be passed to constructor when there is no
// existing BrowserContext.
Original file line number Diff line number Diff line change
@@ -108,7 +108,7 @@ BrowserContext* ElectronExtensionsBrowserClient::GetOriginalContext(
BrowserContext* context) {
DCHECK(context);
if (context->IsOffTheRecord()) {
return ElectronBrowserContext::From("", false);
return ElectronBrowserContext::GetDefaultBrowserContext();
} else {
return context;
}
3 changes: 2 additions & 1 deletion shell/browser/feature_list.cc
Original file line number Diff line number Diff line change
@@ -16,6 +16,7 @@
#include "electron/buildflags/buildflags.h"
#include "media/base/media_switches.h"
#include "net/base/features.h"
#include "printing/buildflags/buildflags.h"
#include "services/network/public/cpp/features.h"
#include "third_party/blink/public/common/features.h"

@@ -60,7 +61,7 @@ void InitializeFeatureList() {
std::string(",") + features::kMacWebContentsOcclusion.name;
#endif

#if BUILDFLAG(IS_LINUX)
#if BUILDFLAG(IS_LINUX) && BUILDFLAG(ENABLE_PRINTING)
disable_features +=
// EnableOopPrintDrivers is still a bit half-baked on Linux and
// causes crashes when trying to show dialogs.
3 changes: 1 addition & 2 deletions shell/browser/net/electron_url_loader_factory.cc
Original file line number Diff line number Diff line change
@@ -671,8 +671,7 @@ void ElectronURLLoaderFactory::StartLoadingHttp(
request->method != net::HttpRequestHeaders::kHeadMethod)
dict.Get("uploadData", &upload_data);

ElectronBrowserContext* browser_context =
ElectronBrowserContext::From("", false);
auto* browser_context = ElectronBrowserContext::GetDefaultBrowserContext();
v8::Local<v8::Value> value;
if (dict.Get("session", &value)) {
if (value->IsNull()) {
2 changes: 1 addition & 1 deletion shell/browser/ui/devtools_manager_delegate.cc
Original file line number Diff line number Diff line change
@@ -139,7 +139,7 @@ bool DevToolsManagerDelegate::HasBundledFrontendResources() {
}

content::BrowserContext* DevToolsManagerDelegate::GetDefaultBrowserContext() {
return ElectronBrowserContext::From("", false);
return ElectronBrowserContext::GetDefaultBrowserContext();
}

} // namespace electron