#include <optional>
#include <string>
#include <vector>
#include "base/functional/callback.h"
#include "base/process/process_info.h"
#include "base/test/metrics/histogram_tester.h"
#include "base/test/scoped_feature_list.h"
#include "base/test/test_future.h"
#include "chrome/browser/browser_features.h"
#include "chrome/browser/net/cookie_encryption_provider_impl.h"
#include "chrome/browser/policy/chrome_browser_policy_connector.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/test/base/in_process_browser_test.h"
#include "chrome/test/base/ui_test_utils.h"
#include "components/policy/core/common/mock_configuration_policy_provider.h"
#include "components/policy/core/common/policy_map.h"
#include "components/policy/policy_constants.h"
#include "content/public/browser/storage_partition.h"
#include "content/public/test/browser_test.h"
#include "content/public/test/test_launcher.h"
#include "net/cookies/canonical_cookie.h"
#include "services/network/public/mojom/cookie_manager.mojom.h"
#include "services/network/public/mojom/network_context.mojom.h"
#include "testing/gtest/include/gtest/gtest.h"
#if BUILDFLAG(IS_WIN)
#include "chrome/browser/os_crypt/app_bound_encryption_win.h"
#include "chrome/browser/os_crypt/test_support.h"
#include "chrome/install_static/test/scoped_install_details.h"
#endif
namespace {
enum TestConfiguration { … };
enum MetricsExpectation { … };
struct TestCase { … };
#if BUILDFLAG(IS_WIN)
bool IsElevationRequired(TestConfiguration configuration) {
switch (configuration) {
case kOSCryptSync:
[[fallthrough]];
case kOSCryptAsync:
[[fallthrough]];
case kOSCryptAsyncWithAppBoundProviderWithEncryptionNoService:
return false;
case kOSCryptAsyncWithAppBoundProvider:
[[fallthrough]];
case kOSCryptAsyncWithAppBoundProviderWithEncryption:
[[fallthrough]];
case kOSCryptAsyncWithAppBoundProviderWithEncryptionUnsupportedUserData:
[[fallthrough]];
case kOSCryptAsyncWithAppBoundProviderDisabledByPolicy:
return true;
}
}
#endif
}
class CookieEncryptionProviderBrowserTest
: public InProcessBrowserTest,
public testing::WithParamInterface<TestCase> { … };
IN_PROC_BROWSER_TEST_P(CookieEncryptionProviderBrowserTest, PRE_CookieStorage) { … }
IN_PROC_BROWSER_TEST_P(CookieEncryptionProviderBrowserTest, CookieStorage) { … }
INSTANTIATE_TEST_SUITE_P(
,
CookieEncryptionProviderBrowserTest,
testing::ValuesIn<TestCase>({ … };