Commit 04c4b1b3 authored by Christopher Cameron's avatar Christopher Cameron Committed by Commit Bot

MacPWAs: Enable multi-profile by default

This is now in a good enough shape to turn on. The remaining work is to
add tracking to ensure that we open the most-recently-used profile on
launch.

Bug: 982024
Change-Id: Ib6b922a1ebca043a6c8f8eb2ded2cd3c837cc80d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1902866
Commit-Queue: ccameron <ccameron@chromium.org>
Reviewed-by: default avatarDominick Ng <dominickn@chromium.org>
Cr-Commit-Position: refs/heads/master@{#713659}
parent 98234211
...@@ -314,13 +314,15 @@ class TestHost : public AppShimHost { ...@@ -314,13 +314,15 @@ class TestHost : public AppShimHost {
DISALLOW_COPY_AND_ASSIGN(TestHost); DISALLOW_COPY_AND_ASSIGN(TestHost);
}; };
class ExtensionAppShimHandlerTest : public testing::Test { class ExtensionAppShimHandlerTestBase : public testing::Test {
protected: protected:
ExtensionAppShimHandlerTest() ExtensionAppShimHandlerTestBase() {}
: delegate_(new MockDelegate),
handler_(new TestingExtensionAppShimHandler(delegate_)), void SetUp() override {
profile_path_a_("Profile A"), delegate_ = new MockDelegate;
profile_path_b_("Profile B") { handler_.reset(new TestingExtensionAppShimHandler(delegate_));
profile_path_a_ = base::FilePath("Profile A");
profile_path_b_ = base::FilePath("Profile B");
AppShimHostBootstrap::SetClient(handler_.get()); AppShimHostBootstrap::SetClient(handler_.get());
bootstrap_aa_ = (new TestingAppShimHostBootstrap( bootstrap_aa_ = (new TestingAppShimHostBootstrap(
profile_path_a_, kTestAppIdA, profile_path_a_, kTestAppIdA,
...@@ -421,7 +423,7 @@ class ExtensionAppShimHandlerTest : public testing::Test { ...@@ -421,7 +423,7 @@ class ExtensionAppShimHandlerTest : public testing::Test {
.WillRepeatedly(Return()); .WillRepeatedly(Return());
} }
~ExtensionAppShimHandlerTest() override { ~ExtensionAppShimHandlerTestBase() override {
host_aa_unique_.reset(); host_aa_unique_.reset();
host_ab_unique_.reset(); host_ab_unique_.reset();
host_bb_unique_.reset(); host_bb_unique_.reset();
...@@ -529,7 +531,34 @@ class ExtensionAppShimHandlerTest : public testing::Test { ...@@ -529,7 +531,34 @@ class ExtensionAppShimHandlerTest : public testing::Test {
scoped_refptr<const Extension> extension_b_; scoped_refptr<const Extension> extension_b_;
private: private:
DISALLOW_COPY_AND_ASSIGN(ExtensionAppShimHandlerTest); DISALLOW_COPY_AND_ASSIGN(ExtensionAppShimHandlerTestBase);
};
class ExtensionAppShimHandlerTest : public ExtensionAppShimHandlerTestBase {
public:
void SetUp() override {
scoped_features_.InitWithFeatures(
/*enabled_features=*/{},
/*disabled_features=*/{features::kAppShimMultiProfile});
ExtensionAppShimHandlerTestBase::SetUp();
}
private:
base::test::ScopedFeatureList scoped_features_;
};
class ExtensionAppShimHandlerTestMultiProfile
: public ExtensionAppShimHandlerTestBase {
public:
void SetUp() override {
scoped_features_.InitWithFeatures(
/*enabled_features=*/{features::kAppShimMultiProfile},
/*disabled_features=*/{});
ExtensionAppShimHandlerTestBase::SetUp();
}
private:
base::test::ScopedFeatureList scoped_features_;
}; };
TEST_F(ExtensionAppShimHandlerTest, LaunchProfileNotFound) { TEST_F(ExtensionAppShimHandlerTest, LaunchProfileNotFound) {
...@@ -866,12 +895,7 @@ TEST_F(ExtensionAppShimHandlerTest, PreExistingHost) { ...@@ -866,12 +895,7 @@ TEST_F(ExtensionAppShimHandlerTest, PreExistingHost) {
EXPECT_EQ(host_aa_.get(), handler_->FindHost(&profile_a_, kTestAppIdA)); EXPECT_EQ(host_aa_.get(), handler_->FindHost(&profile_a_, kTestAppIdA));
} }
TEST_F(ExtensionAppShimHandlerTest, MultiProfile) { TEST_F(ExtensionAppShimHandlerTestMultiProfile, MultiProfile) {
base::test::ScopedFeatureList scoped_features;
scoped_features.InitWithFeatures(
/*enabled_features=*/{features::kAppShimMultiProfile},
/*disabled_features=*/{});
// Test with a bookmark app (host is shared). // Test with a bookmark app (host is shared).
{ {
// Create a host for profile A. // Create a host for profile A.
...@@ -907,12 +931,7 @@ TEST_F(ExtensionAppShimHandlerTest, MultiProfile) { ...@@ -907,12 +931,7 @@ TEST_F(ExtensionAppShimHandlerTest, MultiProfile) {
} }
} }
TEST_F(ExtensionAppShimHandlerTest, MultiProfileShimLaunch) { TEST_F(ExtensionAppShimHandlerTestMultiProfile, MultiProfileShimLaunch) {
base::test::ScopedFeatureList scoped_features;
scoped_features.InitWithFeatures(
/*enabled_features=*/{features::kAppShimMultiProfile},
/*disabled_features=*/{});
delegate_->SetHostForCreate(std::move(host_aa_unique_)); delegate_->SetHostForCreate(std::move(host_aa_unique_));
ShimLaunchedCallback launched_callback; ShimLaunchedCallback launched_callback;
delegate_->SetCaptureShimLaunchedCallback(&launched_callback); delegate_->SetCaptureShimLaunchedCallback(&launched_callback);
...@@ -939,12 +958,7 @@ TEST_F(ExtensionAppShimHandlerTest, MultiProfileShimLaunch) { ...@@ -939,12 +958,7 @@ TEST_F(ExtensionAppShimHandlerTest, MultiProfileShimLaunch) {
EXPECT_TRUE(terminated_callback); EXPECT_TRUE(terminated_callback);
} }
TEST_F(ExtensionAppShimHandlerTest, MultiProfileSelectMenu) { TEST_F(ExtensionAppShimHandlerTestMultiProfile, MultiProfileSelectMenu) {
base::test::ScopedFeatureList scoped_features;
scoped_features.InitWithFeatures(
/*enabled_features=*/{features::kAppShimMultiProfile},
/*disabled_features=*/{});
delegate_->SetHostForCreate(std::move(host_aa_unique_)); delegate_->SetHostForCreate(std::move(host_aa_unique_));
ShimLaunchedCallback launched_callback; ShimLaunchedCallback launched_callback;
delegate_->SetCaptureShimLaunchedCallback(&launched_callback); delegate_->SetCaptureShimLaunchedCallback(&launched_callback);
...@@ -980,12 +994,7 @@ TEST_F(ExtensionAppShimHandlerTest, MultiProfileSelectMenu) { ...@@ -980,12 +994,7 @@ TEST_F(ExtensionAppShimHandlerTest, MultiProfileSelectMenu) {
host_aa_->ProfileSelectedFromMenu(profile_path_b_); host_aa_->ProfileSelectedFromMenu(profile_path_b_);
} }
TEST_F(ExtensionAppShimHandlerTest, ProfileMenuOneProfile) { TEST_F(ExtensionAppShimHandlerTestMultiProfile, ProfileMenuOneProfile) {
base::test::ScopedFeatureList scoped_features;
scoped_features.InitWithFeatures(
/*enabled_features=*/{features::kAppShimMultiProfile},
/*disabled_features=*/{});
// Set this app to be installed for profile A. // Set this app to be installed for profile A.
{ {
auto item_a = chrome::mojom::ProfileMenuItem::New(); auto item_a = chrome::mojom::ProfileMenuItem::New();
...@@ -1048,12 +1057,7 @@ TEST_F(ExtensionAppShimHandlerTest, ProfileMenuOneProfile) { ...@@ -1048,12 +1057,7 @@ TEST_F(ExtensionAppShimHandlerTest, ProfileMenuOneProfile) {
EXPECT_FALSE(delegate_->RunGetProfilesForAppCallback()); EXPECT_FALSE(delegate_->RunGetProfilesForAppCallback());
} }
TEST_F(ExtensionAppShimHandlerTest, FindProfileFromBadProfile) { TEST_F(ExtensionAppShimHandlerTestMultiProfile, FindProfileFromBadProfile) {
base::test::ScopedFeatureList scoped_features;
scoped_features.InitWithFeatures(
/*enabled_features=*/{features::kAppShimMultiProfile},
/*disabled_features=*/{});
// Set this app to be installed for profile A. // Set this app to be installed for profile A.
{ {
auto item_a = chrome::mojom::ProfileMenuItem::New(); auto item_a = chrome::mojom::ProfileMenuItem::New();
...@@ -1076,12 +1080,7 @@ TEST_F(ExtensionAppShimHandlerTest, FindProfileFromBadProfile) { ...@@ -1076,12 +1080,7 @@ TEST_F(ExtensionAppShimHandlerTest, FindProfileFromBadProfile) {
EXPECT_EQ(host_aa_.get(), handler_->FindHost(&profile_a_, kTestAppIdA)); EXPECT_EQ(host_aa_.get(), handler_->FindHost(&profile_a_, kTestAppIdA));
} }
TEST_F(ExtensionAppShimHandlerTest, FindProfileFromNoProfile) { TEST_F(ExtensionAppShimHandlerTestMultiProfile, FindProfileFromNoProfile) {
base::test::ScopedFeatureList scoped_features;
scoped_features.InitWithFeatures(
/*enabled_features=*/{features::kAppShimMultiProfile},
/*disabled_features=*/{});
// Set this app to be installed for profile A. // Set this app to be installed for profile A.
{ {
auto item_a = chrome::mojom::ProfileMenuItem::New(); auto item_a = chrome::mojom::ProfileMenuItem::New();
......
...@@ -20,6 +20,8 @@ ...@@ -20,6 +20,8 @@
#include "base/path_service.h" #include "base/path_service.h"
#include "base/strings/sys_string_conversions.h" #include "base/strings/sys_string_conversions.h"
#include "base/strings/utf_string_conversions.h" #include "base/strings/utf_string_conversions.h"
#include "base/test/scoped_feature_list.h"
#include "chrome/common/chrome_features.h"
#include "chrome/common/chrome_paths.h" #include "chrome/common/chrome_paths.h"
#include "chrome/common/chrome_switches.h" #include "chrome/common/chrome_switches.h"
#import "chrome/common/mac/app_mode_common.h" #import "chrome/common/mac/app_mode_common.h"
...@@ -348,6 +350,11 @@ TEST_F(WebAppShortcutCreatorTest, DeleteShortcuts) { ...@@ -348,6 +350,11 @@ TEST_F(WebAppShortcutCreatorTest, DeleteShortcuts) {
} }
TEST_F(WebAppShortcutCreatorTest, DeleteAllShortcutsForProfile) { TEST_F(WebAppShortcutCreatorTest, DeleteAllShortcutsForProfile) {
base::test::ScopedFeatureList scoped_features;
scoped_features.InitWithFeatures(
/*enabled_features=*/{},
/*disabled_features=*/{features::kAppShimMultiProfile});
NiceMock<WebAppShortcutCreatorMock> shortcut_creator(app_data_dir_, NiceMock<WebAppShortcutCreatorMock> shortcut_creator(app_data_dir_,
info_.get()); info_.get());
base::FilePath profile_path = info_->profile_path; base::FilePath profile_path = info_->profile_path;
......
...@@ -37,7 +37,7 @@ const base::Feature kApkWebAppInstalls{"ApkWebAppInstalls", ...@@ -37,7 +37,7 @@ const base::Feature kApkWebAppInstalls{"ApkWebAppInstalls",
// Enable the new multi-profile-aware app shim mode. // Enable the new multi-profile-aware app shim mode.
// TODO(https://crbug.com/982024): Delete this flag when feature is complete. // TODO(https://crbug.com/982024): Delete this flag when feature is complete.
const base::Feature kAppShimMultiProfile{"AppShimMultiProfile", const base::Feature kAppShimMultiProfile{"AppShimMultiProfile",
base::FEATURE_DISABLED_BY_DEFAULT}; base::FEATURE_ENABLED_BY_DEFAULT};
// Can be used to disable RemoteCocoa (hosting NSWindows for apps in the app // Can be used to disable RemoteCocoa (hosting NSWindows for apps in the app
// process). For debugging purposes only. // process). For debugging purposes only.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment