Truly independent web browser
LibWebView: Default to a developer profile in development builds
Timothy Flynnf8338f506b8d
diff --git a/Libraries/LibCore/BrowserVersion.h.in b/Libraries/LibCore/BrowserVersion.h.inindex 872844b86ba..e1079974ad3 100644--- a/Libraries/LibCore/BrowserVersion.h.in+++ b/Libraries/LibCore/BrowserVersion.h.in@@ -8,6 +8,7 @@#define BROWSER_VERSION "@LADYBIRD_BROWSER_VERSION@"#define BROWSER_BUILD_CONFIGURATION "@CMAKE_BUILD_TYPE@"-#define BROWSER_RELEASE_STAGE "@browser_release_stage@"#define BROWSER_PRODUCT_NAME "@browser_product_name@"+#define BROWSER_RELEASE_STAGE "@browser_release_stage@"+#define BROWSER_IS_RELEASE_BUILD @browser_is_release_build@#define BROWSER_IS_FINAL_RELEASE @browser_is_final_release@diff --git a/Libraries/LibCore/CMakeLists.txt b/Libraries/LibCore/CMakeLists.txtindex b0d4824147d..42f4d405a27 100644--- a/Libraries/LibCore/CMakeLists.txt+++ b/Libraries/LibCore/CMakeLists.txt@@ -115,8 +115,10 @@ ladybird_lib(LibCore core EXPLICIT_SYMBOL_EXPORT)target_link_libraries(LibCore PRIVATE Threads::Threads LibUnicode LibTextCodec mimalloc)# Development builds are in no stage of development, and leave it out of their product name.+set(browser_is_release_build 0)set(browser_is_final_release 0)if (NOT LADYBIRD_VERSION STREQUAL "")+ set(browser_is_release_build 1)set(browser_release_stage "${LADYBIRD_RELEASE_STAGE}")if (browser_release_stage STREQUAL "")set(browser_is_final_release 1)diff --git a/Libraries/LibWebView/Profile.cpp b/Libraries/LibWebView/Profile.cppindex 5407a6cded5..e476d3acdc1 100644--- a/Libraries/LibWebView/Profile.cpp+++ b/Libraries/LibWebView/Profile.cpp@@ -143,7 +143,7 @@ ErrorOr<Profile> Profile::create(ProfileSelection const& selection, ProfileRootsreturn Profile { "temporary"sv, move(paths), move(root) };}- auto identifier = selection.name.value_or("default"sv);+ auto identifier = selection.name.value_or(DEFAULT_PROFILE_NAME);ProfilePaths paths {.config = profile_path(roots.config, identifier),diff --git a/Libraries/LibWebView/Profile.h b/Libraries/LibWebView/Profile.hindex 0ae3c0d248f..2de8981c538 100644--- a/Libraries/LibWebView/Profile.h+++ b/Libraries/LibWebView/Profile.h@@ -9,10 +9,13 @@#include <AK/ByteString.h>#include <AK/Error.h>#include <AK/Optional.h>+#include <LibCore/BrowserVersion.h>#include <LibWebView/Export.h>namespace WebView {+constexpr inline auto DEFAULT_PROFILE_NAME = BROWSER_IS_RELEASE_BUILD ? "default"sv : "developer"sv;+struct ProfileSelection {Optional<ByteString> name {};Optional<ByteString> path {};diff --git a/Tests/LibWebView/TestProfile.cpp b/Tests/LibWebView/TestProfile.cppindex ab25bc658b9..574c4bb85d8 100644--- a/Tests/LibWebView/TestProfile.cpp+++ b/Tests/LibWebView/TestProfile.cpp@@ -87,14 +87,20 @@ TEST_CASE(named_and_default_layouts)EXPECT_EQ(named.paths().runtime, LexicalPath::join(profile_roots.runtime, "Ladybird/Profiles/work"sv).string());auto default_profile = MUST(WebView::Profile::create({}, profile_roots));- EXPECT_EQ(default_profile.identifier(), "default"sv);- EXPECT_EQ(default_profile.paths().config, LexicalPath::join(profile_roots.config, "Ladybird/Profiles/default"sv).string());- EXPECT_EQ(default_profile.paths().data, LexicalPath::join(profile_roots.data, "Ladybird/Profiles/default"sv).string());- EXPECT_EQ(default_profile.paths().cache, LexicalPath::join(profile_roots.cache, "Ladybird/Profiles/default"sv).string());- EXPECT_EQ(default_profile.paths().runtime, LexicalPath::join(profile_roots.runtime, "Ladybird/Profiles/default"sv).string());+ auto default_profile_path = LexicalPath::join("Ladybird/Profiles"sv, WebView::DEFAULT_PROFILE_NAME).string();+ EXPECT_EQ(default_profile.identifier(), WebView::DEFAULT_PROFILE_NAME);+ EXPECT_EQ(default_profile.paths().config, LexicalPath::join(profile_roots.config, default_profile_path).string());+ EXPECT_EQ(default_profile.paths().data, LexicalPath::join(profile_roots.data, default_profile_path).string());+ EXPECT_EQ(default_profile.paths().cache, LexicalPath::join(profile_roots.cache, default_profile_path).string());+ EXPECT_EQ(default_profile.paths().runtime, LexicalPath::join(profile_roots.runtime, default_profile_path).string());auto explicit_default_profile = MUST(WebView::Profile::create({ .name = "default" }, profile_roots));- EXPECT_EQ(explicit_default_profile.paths().identity, default_profile.paths().identity);+ auto explicit_developer_profile = MUST(WebView::Profile::create({ .name = "developer" }, profile_roots));+ EXPECT_EQ(explicit_default_profile.identifier(), "default"sv);+ EXPECT_EQ(explicit_developer_profile.identifier(), "developer"sv);+ EXPECT_NE(explicit_default_profile.paths().identity, explicit_developer_profile.paths().identity);+ auto explicitly_selected_default = MUST(WebView::Profile::create({ .name = WebView::DEFAULT_PROFILE_NAME }, profile_roots));+ EXPECT_EQ(default_profile.paths().identity, explicitly_selected_default.paths().identity);remove_test_root();}