#include "build/build_config.h"
#include "chrome/browser/content_settings/page_specific_content_settings_delegate.h"
#include "chrome/browser/permissions/permission_manager_factory.h"
#include "chrome/test/base/chrome_render_view_host_test_harness.h"
#include "chrome/test/base/testing_profile.h"
#include "components/content_settings/browser/page_specific_content_settings.h"
#include "components/content_settings/core/common/content_settings_types.h"
#include "components/permissions/features.h"
#include "components/permissions/permission_manager.h"
#include "components/permissions/permission_request_manager.h"
#include "components/permissions/test/mock_permission_prompt_factory.h"
#include "content/public/browser/permission_request_description.h"
#include "content/public/browser/permission_result.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/blink/public/common/permissions/permission_utils.h"
#if BUILDFLAG(IS_ANDROID)
#include "chrome/browser/android/search_permissions/search_permissions_service.h"
#include "components/location/android/location_settings_dialog_outcome.h"
#include "components/location/android/mock_location_settings.h"
#include "components/permissions/contexts/geolocation_permission_context_android.h"
#endif
#if BUILDFLAG(IS_ANDROID)
namespace {
constexpr char kDSETestUrl[] = "https://www.dsetest.com";
class TestSearchEngineDelegate
: public SearchPermissionsService::SearchEngineDelegate {
public:
std::u16string GetDSEName() override { return std::u16string(); }
url::Origin GetDSEOrigin() override {
return url::Origin::Create(GURL(kDSETestUrl));
}
};
}
#endif
class GeolocationPermissionContextDelegateTests
: public ChromeRenderViewHostTestHarness { … };
TEST_F(GeolocationPermissionContextDelegateTests, TabContentSettingIsUpdated) { … }
#if BUILDFLAG(IS_ANDROID)
TEST_F(GeolocationPermissionContextDelegateTests,
DISABLED_SearchGeolocationInIncognito) {
url::Origin requesting_frame_url = url::Origin::Create(GURL(kDSETestUrl));
SearchPermissionsService* service =
SearchPermissionsService::Factory::GetForBrowserContext(profile());
std::unique_ptr<TestSearchEngineDelegate> delegate =
std::make_unique<TestSearchEngineDelegate>();
service->SetSearchEngineDelegateForTest(std::move(delegate));
service->InitializeSettingsIfNeeded();
ASSERT_EQ(
blink::mojom::PermissionStatus::ASK,
GetPermissionResultForOriginWithoutContext(
profile(), blink::PermissionType::GEOLOCATION, requesting_frame_url)
.status);
Profile* otr_profile =
profile()->GetPrimaryOTRProfile(true);
ASSERT_EQ(
blink::mojom::PermissionStatus::ASK,
GetPermissionResultForOriginWithoutContext(
otr_profile, blink::PermissionType::GEOLOCATION, requesting_frame_url)
.status);
}
#endif