Commit ef94b43e authored by Mugdha Lakhani's avatar Mugdha Lakhani Committed by Commit Bot

[WebLayer] Implement GetContentSettings, GetPermisisonResult.

Implement two more methods in PageInfoDelegateImpl and add browsertests
to verify expected behavior.

Bug: 1052375
Change-Id: I474bbd06ad2736894881461cb8381b0adf0dcfa4
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2170348Reviewed-by: default avatarClark DuVall <cduvall@chromium.org>
Commit-Queue: Mugdha Lakhani <nator@chromium.org>
Cr-Commit-Position: refs/heads/master@{#763428}
parent c0e1f715
......@@ -2,6 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "components/content_settings/core/common/content_settings.h"
#include "components/page_info/android/page_info_client.h"
#include "components/page_info/page_info_delegate.h"
#include "weblayer/browser/tab_impl.h"
......@@ -46,4 +47,29 @@ IN_PROC_BROWSER_TEST_F(PageInfoBrowserTest, PermissionDecisionAutoblocker) {
EXPECT_TRUE(page_info_delegate->GetPermissionDecisionAutoblocker());
}
IN_PROC_BROWSER_TEST_F(PageInfoBrowserTest, ContentSettings) {
std::unique_ptr<PageInfoDelegate> page_info_delegate =
page_info::GetPageInfoClient()->CreatePageInfoDelegate(GetWebContents());
ASSERT_TRUE(page_info_delegate);
EXPECT_TRUE(page_info_delegate->GetContentSettings());
}
IN_PROC_BROWSER_TEST_F(PageInfoBrowserTest, PermissionStatus) {
std::unique_ptr<PageInfoDelegate> page_info_delegate =
page_info::GetPageInfoClient()->CreatePageInfoDelegate(GetWebContents());
ASSERT_TRUE(page_info_delegate);
GURL url("https://example.com");
auto* content_settings_map = page_info_delegate->GetContentSettings();
ASSERT_TRUE(content_settings_map);
content_settings_map->SetContentSettingDefaultScope(
url, url, ContentSettingsType::BACKGROUND_SYNC, std::string(),
CONTENT_SETTING_BLOCK);
// Check that |page_info_delegate| returns expected ContentSettingsType.
EXPECT_EQ(page_info_delegate
->GetPermissionStatus(ContentSettingsType::NOTIFICATIONS, url)
.content_setting,
CONTENT_SETTING_BLOCK);
}
} // namespace weblayer
......@@ -4,10 +4,13 @@
#include "weblayer/browser/url_bar/page_info_delegate_impl.h"
#include "components/permissions/permission_manager.h"
#include "components/security_interstitials/content/stateful_ssl_host_state_delegate.h"
#include "components/security_state/content/content_utils.h"
#include "content/public/browser/browser_context.h"
#include "weblayer/browser/host_content_settings_map_factory.h"
#include "weblayer/browser/permissions/permission_decision_auto_blocker_factory.h"
#include "weblayer/browser/permissions/permission_manager_factory.h"
#include "weblayer/browser/stateful_ssl_host_state_delegate_factory.h"
PageInfoDelegateImpl::PageInfoDelegateImpl(content::WebContents* web_contents)
......@@ -45,10 +48,9 @@ base::string16 PageInfoDelegateImpl::GetWarningDetailText() {
permissions::PermissionResult PageInfoDelegateImpl::GetPermissionStatus(
ContentSettingsType type,
const GURL& site_url) {
// TODO(crbug.com/1052375): Implement.
NOTREACHED();
return permissions::PermissionResult(
CONTENT_SETTING_BLOCK, permissions::PermissionStatusSource::UNSPECIFIED);
return weblayer::PermissionManagerFactory::GetForBrowserContext(
GetBrowserContext())
->GetPermissionStatus(type, site_url, site_url);
}
#if !defined(OS_ANDROID)
......@@ -77,10 +79,8 @@ PageInfoDelegateImpl::GetStatefulSSLHostStateDelegate() {
}
HostContentSettingsMap* PageInfoDelegateImpl::GetContentSettings() {
// TODO(crbug.com/1052375): Implement once site settings code has been
// componentized.
NOTREACHED();
return nullptr;
return weblayer::HostContentSettingsMapFactory::GetForBrowserContext(
GetBrowserContext());
}
bool PageInfoDelegateImpl::IsContentDisplayedInVrHeadset() {
......
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