| Index: chrome/browser/plugins/chrome_plugin_service_filter_unittest.cc
|
| diff --git a/chrome/browser/plugins/chrome_plugin_service_filter_unittest.cc b/chrome/browser/plugins/chrome_plugin_service_filter_unittest.cc
|
| index edc2710ce031f8540f9889c901c349b689bba402..37e3651ba5ace5b23fa844db7ef068d79c291895 100644
|
| --- a/chrome/browser/plugins/chrome_plugin_service_filter_unittest.cc
|
| +++ b/chrome/browser/plugins/chrome_plugin_service_filter_unittest.cc
|
| @@ -36,6 +36,7 @@
|
| #include "content/public/browser/web_contents.h"
|
| #include "content/public/common/content_constants.h"
|
| #include "content/public/test/test_utils.h"
|
| +#include "url/origin.h"
|
|
|
| namespace {
|
|
|
| @@ -52,7 +53,7 @@ class ChromePluginServiceFilterTest : public ChromeRenderViewHostTestHarness {
|
| flash_plugin_path_(FILE_PATH_LITERAL("/path/to/flash")) {}
|
|
|
| bool IsPluginAvailable(const GURL& plugin_content_url,
|
| - const GURL& main_url,
|
| + const url::Origin& main_url,
|
| const void* resource_context,
|
| const content::WebPluginInfo& plugin_info) {
|
| bool is_available = false;
|
| @@ -85,7 +86,7 @@ class ChromePluginServiceFilterTest : public ChromeRenderViewHostTestHarness {
|
| }
|
|
|
| void IsPluginAvailableOnIOThread(const GURL& plugin_content_url,
|
| - const GURL& main_url,
|
| + const url::Origin& main_url,
|
| const void* resource_context,
|
| content::WebPluginInfo plugin_info,
|
| bool* is_available) {
|
| @@ -103,8 +104,8 @@ TEST_F(ChromePluginServiceFilterTest, FlashAvailableByDefault) {
|
| content::WebPluginInfo flash_plugin(
|
| base::ASCIIToUTF16(content::kFlashPluginName), flash_plugin_path_,
|
| base::ASCIIToUTF16("1"), base::ASCIIToUTF16("The Flash plugin."));
|
| - EXPECT_TRUE(IsPluginAvailable(GURL(), GURL(), profile()->GetResourceContext(),
|
| - flash_plugin));
|
| + EXPECT_TRUE(IsPluginAvailable(GURL(), url::Origin(),
|
| + profile()->GetResourceContext(), flash_plugin));
|
| }
|
|
|
| TEST_F(ChromePluginServiceFilterTest, PreferHtmlOverPluginsDefault) {
|
| @@ -119,8 +120,9 @@ TEST_F(ChromePluginServiceFilterTest, PreferHtmlOverPluginsDefault) {
|
| // The default content setting should block Flash, as there should be 0
|
| // engagement.
|
| GURL url("http://www.google.com");
|
| - EXPECT_FALSE(IsPluginAvailable(url, url, profile()->GetResourceContext(),
|
| - flash_plugin));
|
| + url::Origin main_frame_origin(url);
|
| + EXPECT_FALSE(IsPluginAvailable(
|
| + url, main_frame_origin, profile()->GetResourceContext(), flash_plugin));
|
|
|
| // Block plugins.
|
| HostContentSettingsMap* map =
|
| @@ -128,22 +130,22 @@ TEST_F(ChromePluginServiceFilterTest, PreferHtmlOverPluginsDefault) {
|
| map->SetDefaultContentSetting(CONTENT_SETTINGS_TYPE_PLUGINS,
|
| CONTENT_SETTING_BLOCK);
|
|
|
| - EXPECT_FALSE(IsPluginAvailable(url, url, profile()->GetResourceContext(),
|
| - flash_plugin));
|
| + EXPECT_FALSE(IsPluginAvailable(
|
| + url, main_frame_origin, profile()->GetResourceContext(), flash_plugin));
|
|
|
| // Allow plugins.
|
| map->SetDefaultContentSetting(CONTENT_SETTINGS_TYPE_PLUGINS,
|
| CONTENT_SETTING_ALLOW);
|
|
|
| - EXPECT_TRUE(IsPluginAvailable(url, url, profile()->GetResourceContext(),
|
| - flash_plugin));
|
| + EXPECT_TRUE(IsPluginAvailable(url, main_frame_origin,
|
| + profile()->GetResourceContext(), flash_plugin));
|
|
|
| // Detect important content should block on 0 engagement.
|
| map->SetDefaultContentSetting(CONTENT_SETTINGS_TYPE_PLUGINS,
|
| CONTENT_SETTING_DETECT_IMPORTANT_CONTENT);
|
|
|
| - EXPECT_FALSE(IsPluginAvailable(url, url, profile()->GetResourceContext(),
|
| - flash_plugin));
|
| + EXPECT_FALSE(IsPluginAvailable(
|
| + url, main_frame_origin, profile()->GetResourceContext(), flash_plugin));
|
| }
|
|
|
| TEST_F(ChromePluginServiceFilterTest,
|
| @@ -164,33 +166,34 @@ TEST_F(ChromePluginServiceFilterTest,
|
|
|
| // This should respect the content setting and be allowed.
|
| GURL url("http://www.google.com");
|
| - EXPECT_TRUE(IsPluginAvailable(url, url, profile()->GetResourceContext(),
|
| - flash_plugin));
|
| + url::Origin main_frame_origin(url);
|
| + EXPECT_TRUE(IsPluginAvailable(url, main_frame_origin,
|
| + profile()->GetResourceContext(), flash_plugin));
|
|
|
| map->SetDefaultContentSetting(CONTENT_SETTINGS_TYPE_PLUGINS,
|
| CONTENT_SETTING_DETECT_IMPORTANT_CONTENT);
|
|
|
| // This should be blocked due to 0 engagement and a detect content setting.
|
| - EXPECT_FALSE(IsPluginAvailable(url, url, profile()->GetResourceContext(),
|
| - flash_plugin));
|
| + EXPECT_FALSE(IsPluginAvailable(
|
| + url, main_frame_origin, profile()->GetResourceContext(), flash_plugin));
|
|
|
| SiteEngagementService* service = SiteEngagementService::Get(profile());
|
| service->ResetScoreForURL(url, 0.5);
|
|
|
| // Should still be blocked.
|
| - EXPECT_FALSE(IsPluginAvailable(url, url, profile()->GetResourceContext(),
|
| - flash_plugin));
|
| + EXPECT_FALSE(IsPluginAvailable(
|
| + url, main_frame_origin, profile()->GetResourceContext(), flash_plugin));
|
|
|
| // Reaching 1.0 engagement should allow Flash.
|
| service->ResetScoreForURL(url, 1.0);
|
| - EXPECT_TRUE(IsPluginAvailable(url, url, profile()->GetResourceContext(),
|
| - flash_plugin));
|
| + EXPECT_TRUE(IsPluginAvailable(url, main_frame_origin,
|
| + profile()->GetResourceContext(), flash_plugin));
|
|
|
| // Blocked content setting should override engagement
|
| map->SetDefaultContentSetting(CONTENT_SETTINGS_TYPE_PLUGINS,
|
| CONTENT_SETTING_BLOCK);
|
| - EXPECT_FALSE(IsPluginAvailable(url, url, profile()->GetResourceContext(),
|
| - flash_plugin));
|
| + EXPECT_FALSE(IsPluginAvailable(
|
| + url, main_frame_origin, profile()->GetResourceContext(), flash_plugin));
|
| }
|
|
|
| TEST_F(ChromePluginServiceFilterTest, PreferHtmlOverPluginsCustomEngagement) {
|
| @@ -231,23 +234,24 @@ TEST_F(ChromePluginServiceFilterTest, PreferHtmlOverPluginsCustomEngagement) {
|
|
|
| // This should be blocked due to 0 engagement.
|
| GURL url("http://www.google.com");
|
| - EXPECT_FALSE(IsPluginAvailable(url, url, profile()->GetResourceContext(),
|
| - flash_plugin));
|
| + url::Origin main_frame_origin(url);
|
| + EXPECT_FALSE(IsPluginAvailable(
|
| + url, main_frame_origin, profile()->GetResourceContext(), flash_plugin));
|
|
|
| // Should still be blocked until engagement reaches 4.
|
| SiteEngagementService* service = SiteEngagementService::Get(profile());
|
| service->ResetScoreForURL(url, 0.5);
|
| - EXPECT_FALSE(IsPluginAvailable(url, url, profile()->GetResourceContext(),
|
| - flash_plugin));
|
| + EXPECT_FALSE(IsPluginAvailable(
|
| + url, main_frame_origin, profile()->GetResourceContext(), flash_plugin));
|
| service->ResetScoreForURL(url, 2.0);
|
| - EXPECT_FALSE(IsPluginAvailable(url, url, profile()->GetResourceContext(),
|
| - flash_plugin));
|
| + EXPECT_FALSE(IsPluginAvailable(
|
| + url, main_frame_origin, profile()->GetResourceContext(), flash_plugin));
|
| service->ResetScoreForURL(url, 3.0);
|
| - EXPECT_FALSE(IsPluginAvailable(url, url, profile()->GetResourceContext(),
|
| - flash_plugin));
|
| + EXPECT_FALSE(IsPluginAvailable(
|
| + url, main_frame_origin, profile()->GetResourceContext(), flash_plugin));
|
| service->ResetScoreForURL(url, 4.0);
|
| - EXPECT_TRUE(IsPluginAvailable(url, url, profile()->GetResourceContext(),
|
| - flash_plugin));
|
| + EXPECT_TRUE(IsPluginAvailable(url, main_frame_origin,
|
| + profile()->GetResourceContext(), flash_plugin));
|
|
|
| variations::testing::ClearAllVariationParams();
|
| }
|
| @@ -273,16 +277,17 @@ TEST_F(ChromePluginServiceFilterTest,
|
|
|
| // We should fail the availablity check in incognito.
|
| GURL url("http://www.google.com");
|
| - EXPECT_FALSE(IsPluginAvailable(url, url, incognito->GetResourceContext(),
|
| - flash_plugin));
|
| + url::Origin main_frame_origin(url);
|
| + EXPECT_FALSE(IsPluginAvailable(
|
| + url, main_frame_origin, incognito->GetResourceContext(), flash_plugin));
|
|
|
| // Add sufficient engagement to allow Flash in the original profile.
|
| SiteEngagementService* service = SiteEngagementService::Get(profile());
|
| service->ResetScoreForURL(url, 1.0);
|
|
|
| // We should still fail the engagement check due to the block.
|
| - EXPECT_FALSE(IsPluginAvailable(url, url, incognito->GetResourceContext(),
|
| - flash_plugin));
|
| + EXPECT_FALSE(IsPluginAvailable(
|
| + url, main_frame_origin, incognito->GetResourceContext(), flash_plugin));
|
|
|
| // Change to detect important content in the original profile.
|
| map->SetDefaultContentSetting(CONTENT_SETTINGS_TYPE_PLUGINS,
|
| @@ -291,8 +296,8 @@ TEST_F(ChromePluginServiceFilterTest,
|
| // Ensure we pass the engagement check in the incognito profile (i.e. it falls
|
| // back to checking engagement from the original profile when nothing is found
|
| // in the incognito profile).
|
| - EXPECT_TRUE(IsPluginAvailable(url, url, incognito->GetResourceContext(),
|
| - flash_plugin));
|
| + EXPECT_TRUE(IsPluginAvailable(url, main_frame_origin,
|
| + incognito->GetResourceContext(), flash_plugin));
|
| }
|
|
|
| TEST_F(ChromePluginServiceFilterTest,
|
| @@ -317,24 +322,25 @@ TEST_F(ChromePluginServiceFilterTest,
|
| // We pass the availablity check in incognito based on the original content
|
| // setting.
|
| GURL url("http://www.google.com");
|
| - EXPECT_TRUE(IsPluginAvailable(url, url, incognito->GetResourceContext(),
|
| - flash_plugin));
|
| + url::Origin main_frame_origin(url);
|
| + EXPECT_TRUE(IsPluginAvailable(url, main_frame_origin,
|
| + incognito->GetResourceContext(), flash_plugin));
|
|
|
| map->SetDefaultContentSetting(CONTENT_SETTINGS_TYPE_PLUGINS,
|
| CONTENT_SETTING_DETECT_IMPORTANT_CONTENT);
|
|
|
| // Now we fail the availability check due to the content setting carrying
|
| // over.
|
| - EXPECT_FALSE(IsPluginAvailable(url, url, incognito->GetResourceContext(),
|
| - flash_plugin));
|
| + EXPECT_FALSE(IsPluginAvailable(
|
| + url, main_frame_origin, incognito->GetResourceContext(), flash_plugin));
|
|
|
| // Add sufficient engagement to allow Flash in the incognito profile.
|
| SiteEngagementService* service = SiteEngagementService::Get(incognito);
|
| service->ResetScoreForURL(url, 2.0);
|
|
|
| // Ensure we pass the engagement check in the incognito profile.
|
| - EXPECT_TRUE(IsPluginAvailable(url, url, incognito->GetResourceContext(),
|
| - flash_plugin));
|
| + EXPECT_TRUE(IsPluginAvailable(url, main_frame_origin,
|
| + incognito->GetResourceContext(), flash_plugin));
|
| }
|
|
|
| TEST_F(ChromePluginServiceFilterTest, BlockIfManagedSetting) {
|
| @@ -354,15 +360,16 @@ TEST_F(ChromePluginServiceFilterTest, BlockIfManagedSetting) {
|
| SiteEngagementService* service = SiteEngagementService::Get(profile());
|
| // Reaching 1.0 engagement should allow Flash.
|
| GURL url("http://www.google.com");
|
| + url::Origin main_frame_origin(url);
|
| service->ResetScoreForURL(url, 1.0);
|
| - EXPECT_TRUE(IsPluginAvailable(url, url, profile()->GetResourceContext(),
|
| - flash_plugin));
|
| + EXPECT_TRUE(IsPluginAvailable(url, main_frame_origin,
|
| + profile()->GetResourceContext(), flash_plugin));
|
|
|
| // Enterprise ASK setting should block flash from being advertised.
|
| syncable_prefs::TestingPrefServiceSyncable* prefs =
|
| profile()->GetTestingPrefService();
|
| prefs->SetManagedPref(prefs::kManagedDefaultPluginsSetting,
|
| new base::FundamentalValue(CONTENT_SETTING_ASK));
|
| - EXPECT_FALSE(IsPluginAvailable(url, url, profile()->GetResourceContext(),
|
| - flash_plugin));
|
| + EXPECT_FALSE(IsPluginAvailable(
|
| + url, main_frame_origin, profile()->GetResourceContext(), flash_plugin));
|
| }
|
|
|