| Index: chrome/browser/geolocation/geolocation_permission_context_unittest.cc
|
| diff --git a/chrome/browser/geolocation/geolocation_permission_context_unittest.cc b/chrome/browser/geolocation/geolocation_permission_context_unittest.cc
|
| index e33acba4d82811a21d7f142d86537eba91f46aba..42273ac3be4ebeb9efb8052049a9e50094b3c88d 100644
|
| --- a/chrome/browser/geolocation/geolocation_permission_context_unittest.cc
|
| +++ b/chrome/browser/geolocation/geolocation_permission_context_unittest.cc
|
| @@ -25,6 +25,7 @@
|
| #include "chrome/browser/permissions/permission_request_id.h"
|
| #include "chrome/browser/ui/website_settings/permission_bubble_request.h"
|
| #include "chrome/common/chrome_switches.h"
|
| +#include "chrome/common/features.h"
|
| #include "chrome/test/base/chrome_render_view_host_test_harness.h"
|
| #include "chrome/test/base/testing_profile.h"
|
| #include "components/content_settings/core/browser/host_content_settings_map.h"
|
| @@ -44,7 +45,7 @@
|
| #include "content/public/test/web_contents_tester.h"
|
| #include "testing/gtest/include/gtest/gtest.h"
|
|
|
| -#if defined(OS_ANDROID)
|
| +#if BUILDFLAG(ANDROID_JAVA_UI)
|
| #include "base/prefs/pref_service.h"
|
| #include "chrome/browser/android/mock_location_settings.h"
|
| #include "chrome/browser/geolocation/geolocation_permission_context_android.h"
|
| @@ -143,7 +144,7 @@ class GeolocationPermissionContextTests
|
| void AddNewTab(const GURL& url);
|
| void CheckTabContentsState(const GURL& requesting_frame,
|
| ContentSetting expected_content_setting);
|
| -#if !defined(OS_ANDROID)
|
| +#if !BUILDFLAG(ANDROID_JAVA_UI)
|
| size_t GetBubblesQueueSize(PermissionBubbleManager* manager);
|
| void AcceptBubble(PermissionBubbleManager* manager);
|
| void DenyBubble(PermissionBubbleManager* manager);
|
| @@ -239,7 +240,7 @@ void GeolocationPermissionContextTests::AddNewTab(const GURL& url) {
|
| #if defined(ENABLE_EXTENSIONS)
|
| extensions::SetViewType(new_tab, extensions::VIEW_TYPE_TAB_CONTENTS);
|
| #endif
|
| -#if defined(OS_ANDROID)
|
| +#if BUILDFLAG(ANDROID_JAVA_UI)
|
| InfoBarService::CreateForWebContents(new_tab);
|
| #else
|
| PermissionBubbleManager::CreateForWebContents(new_tab);
|
| @@ -279,7 +280,7 @@ void GeolocationPermissionContextTests::SetUp() {
|
| TabSpecificContentSettings::CreateForWebContents(web_contents());
|
| geolocation_permission_context_ =
|
| GeolocationPermissionContextFactory::GetForProfile(profile());
|
| -#if defined(OS_ANDROID)
|
| +#if BUILDFLAG(ANDROID_JAVA_UI)
|
| static_cast<GeolocationPermissionContextAndroid*>(
|
| geolocation_permission_context_)
|
| ->SetLocationSettingsForTesting(
|
| @@ -299,7 +300,7 @@ void GeolocationPermissionContextTests::TearDown() {
|
| ChromeRenderViewHostTestHarness::TearDown();
|
| }
|
|
|
| -#if !defined(OS_ANDROID)
|
| +#if !BUILDFLAG(ANDROID_JAVA_UI)
|
| size_t GeolocationPermissionContextTests::GetBubblesQueueSize(
|
| PermissionBubbleManager* manager) {
|
| return manager->requests_.size();
|
| @@ -328,7 +329,7 @@ void GeolocationPermissionContextTests::BubbleManagerDocumentLoadCompleted() {
|
|
|
| void GeolocationPermissionContextTests::BubbleManagerDocumentLoadCompleted(
|
| content::WebContents* web_contents) {
|
| -#if !defined(OS_ANDROID)
|
| +#if !BUILDFLAG(ANDROID_JAVA_UI)
|
| PermissionBubbleManager::FromWebContents(web_contents)->
|
| DocumentOnLoadCompletedInMainFrame();
|
| #endif
|
| @@ -344,7 +345,7 @@ ContentSetting GeolocationPermissionContextTests::GetGeolocationContentSetting(
|
| }
|
|
|
| size_t GeolocationPermissionContextTests::GetNumberOfPrompts() {
|
| -#if !defined(OS_ANDROID)
|
| +#if !BUILDFLAG(ANDROID_JAVA_UI)
|
| PermissionBubbleManager* manager =
|
| PermissionBubbleManager::FromWebContents(web_contents());
|
| return GetBubblesQueueSize(manager);
|
| @@ -354,7 +355,7 @@ size_t GeolocationPermissionContextTests::GetNumberOfPrompts() {
|
| }
|
|
|
| void GeolocationPermissionContextTests::AcceptPrompt() {
|
| -#if !defined(OS_ANDROID)
|
| +#if !BUILDFLAG(ANDROID_JAVA_UI)
|
| PermissionBubbleManager* manager =
|
| PermissionBubbleManager::FromWebContents(web_contents());
|
| AcceptBubble(manager);
|
| @@ -367,7 +368,7 @@ void GeolocationPermissionContextTests::AcceptPrompt() {
|
| }
|
|
|
| base::string16 GeolocationPermissionContextTests::GetPromptText() {
|
| -#if !defined(OS_ANDROID)
|
| +#if !BUILDFLAG(ANDROID_JAVA_UI)
|
| PermissionBubbleManager* manager =
|
| PermissionBubbleManager::FromWebContents(web_contents());
|
| return manager->requests_.front()->GetMessageText();
|
| @@ -392,7 +393,7 @@ TEST_F(GeolocationPermissionContextTests, SinglePermissionBubble) {
|
| ASSERT_EQ(1U, GetNumberOfPrompts());
|
| }
|
|
|
| -#if defined(OS_ANDROID)
|
| +#if BUILDFLAG(ANDROID_JAVA_UI)
|
| TEST_F(GeolocationPermissionContextTests, SinglePermissionInfobar) {
|
| GURL requesting_frame("http://www.example.com/geolocation");
|
| NavigateAndCommit(requesting_frame);
|
| @@ -490,7 +491,7 @@ TEST_F(GeolocationPermissionContextTests, QueuedPermission) {
|
| CheckTabContentsState(requesting_frame_0, CONTENT_SETTING_ALLOW);
|
| CheckPermissionMessageSent(0, true);
|
|
|
| -#if defined(OS_ANDROID)
|
| +#if BUILDFLAG(ANDROID_JAVA_UI)
|
| infobars::InfoBar* infobar_0 = infobar_service()->infobar_at(0);
|
| infobar_service()->RemoveInfoBar(infobar_0);
|
| EXPECT_EQ(1U, closed_infobar_tracker_.size());
|
| @@ -506,7 +507,7 @@ TEST_F(GeolocationPermissionContextTests, QueuedPermission) {
|
| EXPECT_NE(text_0, text_1);
|
|
|
| // Cancel (block) this frame.
|
| -#if !defined(OS_ANDROID)
|
| +#if !BUILDFLAG(ANDROID_JAVA_UI)
|
| PermissionBubbleManager* manager =
|
| PermissionBubbleManager::FromWebContents(web_contents());
|
| DenyBubble(manager);
|
| @@ -536,7 +537,7 @@ TEST_F(GeolocationPermissionContextTests, HashIsIgnored) {
|
|
|
| // Check permission is requested.
|
| ASSERT_EQ(0U, GetNumberOfPrompts());
|
| -#if defined(OS_ANDROID)
|
| +#if BUILDFLAG(ANDROID_JAVA_UI)
|
| const bool user_gesture = false;
|
| #else
|
| const bool user_gesture = true;
|
| @@ -556,7 +557,7 @@ TEST_F(GeolocationPermissionContextTests, HashIsIgnored) {
|
| CheckPermissionMessageSent(0, true);
|
|
|
| // Cleanup.
|
| -#if defined(OS_ANDROID)
|
| +#if BUILDFLAG(ANDROID_JAVA_UI)
|
| infobars::InfoBar* infobar = infobar_service()->infobar_at(0);
|
| infobar_service()->RemoveInfoBar(infobar);
|
| EXPECT_EQ(1U, closed_infobar_tracker_.size());
|
| @@ -566,7 +567,7 @@ TEST_F(GeolocationPermissionContextTests, HashIsIgnored) {
|
|
|
| // TODO(felt): The bubble is rejecting file:// permission requests.
|
| // Fix and enable this test. crbug.com/444047
|
| -#if defined(OS_ANDROID)
|
| +#if BUILDFLAG(ANDROID_JAVA_UI)
|
| #define MAYBE_PermissionForFileScheme PermissionForFileScheme
|
| #else
|
| #define MAYBE_PermissionForFileScheme DISABLED_PermissionForFileScheme
|
| @@ -618,7 +619,7 @@ TEST_F(GeolocationPermissionContextTests, CancelGeolocationPermissionRequest) {
|
| ASSERT_FALSE(text_0.empty());
|
|
|
| // Simulate the frame going away; the request should be removed.
|
| -#if !defined(OS_ANDROID)
|
| +#if !BUILDFLAG(ANDROID_JAVA_UI)
|
| PermissionBubbleManager* manager =
|
| PermissionBubbleManager::FromWebContents(web_contents());
|
| CloseBubble(manager);
|
| @@ -667,7 +668,7 @@ TEST_F(GeolocationPermissionContextTests, SameOriginMultipleTabs) {
|
| BubbleManagerDocumentLoadCompleted();
|
| BubbleManagerDocumentLoadCompleted(extra_tabs_[0]);
|
| BubbleManagerDocumentLoadCompleted(extra_tabs_[1]);
|
| -#if !defined(OS_ANDROID)
|
| +#if !BUILDFLAG(ANDROID_JAVA_UI)
|
| PermissionBubbleManager* manager_a0 =
|
| PermissionBubbleManager::FromWebContents(web_contents());
|
| PermissionBubbleManager* manager_b =
|
| @@ -684,7 +685,7 @@ TEST_F(GeolocationPermissionContextTests, SameOriginMultipleTabs) {
|
| RequestGeolocationPermission(
|
| extra_tabs_[1], RequestIDForTab(1, 0), url_a, true);
|
| ASSERT_EQ(1U, GetNumberOfPrompts()); // For A0.
|
| -#if !defined(OS_ANDROID)
|
| +#if !BUILDFLAG(ANDROID_JAVA_UI)
|
| ASSERT_EQ(1U, GetBubblesQueueSize(manager_b));
|
| ASSERT_EQ(1U, GetBubblesQueueSize(manager_a1));
|
| #else
|
| @@ -693,7 +694,7 @@ TEST_F(GeolocationPermissionContextTests, SameOriginMultipleTabs) {
|
| #endif
|
|
|
| // Accept the permission in tab A0.
|
| -#if !defined(OS_ANDROID)
|
| +#if !BUILDFLAG(ANDROID_JAVA_UI)
|
| AcceptBubble(manager_a0);
|
| #else
|
| infobars::InfoBar* infobar_a0 = infobar_service()->infobar_at(0);
|
| @@ -710,7 +711,7 @@ TEST_F(GeolocationPermissionContextTests, SameOriginMultipleTabs) {
|
| // disappear. It does not cause the bubble to disappear: crbug.com/443013.
|
| // TODO(felt): Update this test when the bubble's behavior is changed.
|
| // Either way, tab B should still have a pending permission request.
|
| -#if !defined(OS_ANDROID)
|
| +#if !BUILDFLAG(ANDROID_JAVA_UI)
|
| ASSERT_EQ(1U, GetBubblesQueueSize(manager_a1));
|
| ASSERT_EQ(1U, GetBubblesQueueSize(manager_b));
|
| #else
|
| @@ -724,7 +725,7 @@ TEST_F(GeolocationPermissionContextTests, QueuedOriginMultipleTabs) {
|
| GURL url_b("http://www.example-2.com/geolocation");
|
| NavigateAndCommit(url_a); // Tab A0.
|
| AddNewTab(url_a); // Tab A1.
|
| -#if !defined(OS_ANDROID)
|
| +#if !BUILDFLAG(ANDROID_JAVA_UI)
|
| BubbleManagerDocumentLoadCompleted();
|
| BubbleManagerDocumentLoadCompleted(extra_tabs_[0]);
|
| PermissionBubbleManager* manager_a0 =
|
| @@ -741,7 +742,7 @@ TEST_F(GeolocationPermissionContextTests, QueuedOriginMultipleTabs) {
|
| extra_tabs_[0], RequestIDForTab(0, 0), url_a, true);
|
| RequestGeolocationPermission(
|
| extra_tabs_[0], RequestIDForTab(0, 1), url_b, true);
|
| -#if !defined(OS_ANDROID)
|
| +#if !BUILDFLAG(ANDROID_JAVA_UI)
|
| ASSERT_EQ(1U, GetBubblesQueueSize(manager_a0));
|
| ASSERT_EQ(1U, GetBubblesQueueSize(manager_a1));
|
| #else
|
| @@ -750,7 +751,7 @@ TEST_F(GeolocationPermissionContextTests, QueuedOriginMultipleTabs) {
|
| #endif
|
|
|
| // Accept the first request in tab A1.
|
| -#if !defined(OS_ANDROID)
|
| +#if !BUILDFLAG(ANDROID_JAVA_UI)
|
| AcceptBubble(manager_a1);
|
| #else
|
| infobars::InfoBar* infobar_a1 = infobar_service_for_tab(0)->infobar_at(0);
|
| @@ -767,7 +768,7 @@ TEST_F(GeolocationPermissionContextTests, QueuedOriginMultipleTabs) {
|
| // Because they're the same origin, this will cause tab A0's infobar to
|
| // disappear. It does not cause the bubble to disappear: crbug.com/443013.
|
| // TODO(felt): Update this test when the bubble's behavior is changed.
|
| -#if !defined(OS_ANDROID)
|
| +#if !BUILDFLAG(ANDROID_JAVA_UI)
|
| EXPECT_EQ(1U, GetBubblesQueueSize(manager_a0));
|
| #else
|
| EXPECT_EQ(0U, infobar_service()->infobar_count());
|
| @@ -775,14 +776,14 @@ TEST_F(GeolocationPermissionContextTests, QueuedOriginMultipleTabs) {
|
| #endif
|
|
|
| // The second request should now be visible in tab A1.
|
| -#if !defined(OS_ANDROID)
|
| +#if !BUILDFLAG(ANDROID_JAVA_UI)
|
| ASSERT_EQ(1U, GetBubblesQueueSize(manager_a1));
|
| #else
|
| ASSERT_EQ(1U, infobar_service_for_tab(0)->infobar_count());
|
| #endif
|
|
|
| // Accept the second request and check that it's gone.
|
| -#if !defined(OS_ANDROID)
|
| +#if !BUILDFLAG(ANDROID_JAVA_UI)
|
| AcceptBubble(manager_a1);
|
| EXPECT_EQ(0U, GetBubblesQueueSize(manager_a1));
|
| #else
|
| @@ -817,7 +818,7 @@ TEST_F(GeolocationPermissionContextTests, TabDestroyed) {
|
| ASSERT_EQ(1U, GetNumberOfPrompts());
|
|
|
| // Delete the tab contents.
|
| -#if defined(OS_ANDROID)
|
| +#if BUILDFLAG(ANDROID_JAVA_UI)
|
| infobars::InfoBar* infobar = infobar_service()->infobar_at(0);
|
| DeleteContents();
|
| ASSERT_EQ(1U, closed_infobar_tracker_.size());
|
| @@ -915,7 +916,7 @@ TEST_F(GeolocationPermissionContextTests, LastUsageAuditedMultipleFrames) {
|
|
|
| // Accept the first frame.
|
| AcceptPrompt();
|
| -#if defined(OS_ANDROID)
|
| +#if BUILDFLAG(ANDROID_JAVA_UI)
|
| infobar_service()->RemoveInfoBar(infobar_service()->infobar_at(0));
|
| #endif
|
| CheckTabContentsState(requesting_frame_0, CONTENT_SETTING_ALLOW);
|
| @@ -940,7 +941,7 @@ TEST_F(GeolocationPermissionContextTests, LastUsageAuditedMultipleFrames) {
|
| AcceptPrompt();
|
| CheckTabContentsState(requesting_frame_1, CONTENT_SETTING_ALLOW);
|
| CheckPermissionMessageSent(1, true);
|
| -#if defined(OS_ANDROID)
|
| +#if BUILDFLAG(ANDROID_JAVA_UI)
|
| infobar_service()->RemoveInfoBar(infobar_service()->infobar_at(0));
|
| #endif
|
|
|
|
|