Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(47)

Side by Side Diff: chrome/browser/plugins/plugin_info_message_filter_unittest.cc

Issue 2945243002: Permissions: Allow PermissionManager to return more PermissionStatusSources.
Patch Set: Cleanup. Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/plugins/plugin_info_message_filter.h" 5 #include "chrome/browser/plugins/plugin_info_message_filter.h"
6 6
7 #include "base/at_exit.h" 7 #include "base/at_exit.h"
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/bind_helpers.h" 9 #include "base/bind_helpers.h"
10 #include "base/message_loop/message_loop.h" 10 #include "base/message_loop/message_loop.h"
11 #include "base/run_loop.h" 11 #include "base/run_loop.h"
12 #include "base/strings/utf_string_conversions.h" 12 #include "base/strings/utf_string_conversions.h"
13 #include "base/test/scoped_feature_list.h" 13 #include "base/test/scoped_feature_list.h"
14 #include "build/build_config.h" 14 #include "build/build_config.h"
15 #include "chrome/browser/content_settings/host_content_settings_map_factory.h" 15 #include "chrome/browser/content_settings/host_content_settings_map_factory.h"
16 #include "chrome/browser/permissions/permission_result.h"
16 #include "chrome/browser/plugins/plugin_metadata.h" 17 #include "chrome/browser/plugins/plugin_metadata.h"
17 #include "chrome/browser/plugins/plugin_utils.h" 18 #include "chrome/browser/plugins/plugin_utils.h"
18 #include "chrome/common/chrome_features.h" 19 #include "chrome/common/chrome_features.h"
19 #include "chrome/common/pref_names.h" 20 #include "chrome/common/pref_names.h"
20 #include "chrome/common/render_messages.h" 21 #include "chrome/common/render_messages.h"
21 #include "chrome/test/base/testing_profile.h" 22 #include "chrome/test/base/testing_profile.h"
22 #include "components/content_settings/core/browser/host_content_settings_map.h" 23 #include "components/content_settings/core/browser/host_content_settings_map.h"
23 #include "components/content_settings/core/common/pref_names.h" 24 #include "components/content_settings/core/common/pref_names.h"
24 #include "components/sync_preferences/testing_pref_service_syncable.h" 25 #include "components/sync_preferences/testing_pref_service_syncable.h"
25 #include "content/public/browser/plugin_service.h" 26 #include "content/public/browser/plugin_service.h"
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 ContentSetting setting = expected_setting == CONTENT_SETTING_DEFAULT ? 159 ContentSetting setting = expected_setting == CONTENT_SETTING_DEFAULT ?
159 CONTENT_SETTING_BLOCK : CONTENT_SETTING_DEFAULT; 160 CONTENT_SETTING_BLOCK : CONTENT_SETTING_DEFAULT;
160 bool is_default = !expected_is_default; 161 bool is_default = !expected_is_default;
161 bool is_managed = !expected_is_managed; 162 bool is_managed = !expected_is_managed;
162 163
163 // Pass in a fake Flash plugin info. 164 // Pass in a fake Flash plugin info.
164 content::WebPluginInfo plugin_info( 165 content::WebPluginInfo plugin_info(
165 base::ASCIIToUTF16(content::kFlashPluginName), base::FilePath(), 166 base::ASCIIToUTF16(content::kFlashPluginName), base::FilePath(),
166 base::ASCIIToUTF16("1"), base::ASCIIToUTF16("Fake Flash")); 167 base::ASCIIToUTF16("1"), base::ASCIIToUTF16("Fake Flash"));
167 168
169 PermissionResult result(setting, PermissionStatusSource::UNSPECIFIED);
168 PluginUtils::GetPluginContentSetting( 170 PluginUtils::GetPluginContentSetting(
169 host_content_settings_map_, plugin_info, url::Origin(url), url, plugin, 171 host_content_settings_map_, plugin_info, url::Origin(url), url, plugin,
170 &setting, &is_default, &is_managed); 172 &result, &is_default, &is_managed);
173 setting = result.content_setting;
171 EXPECT_EQ(expected_setting, setting); 174 EXPECT_EQ(expected_setting, setting);
172 EXPECT_EQ(expected_is_default, is_default); 175 EXPECT_EQ(expected_is_default, is_default);
173 EXPECT_EQ(expected_is_managed, is_managed); 176 EXPECT_EQ(expected_is_managed, is_managed);
174 } 177 }
175 178
176 base::FilePath foo_plugin_path_; 179 base::FilePath foo_plugin_path_;
177 base::FilePath bar_plugin_path_; 180 base::FilePath bar_plugin_path_;
178 base::FilePath fake_flash_path_; 181 base::FilePath fake_flash_path_;
179 FakePluginServiceFilter filter_; 182 FakePluginServiceFilter filter_;
180 183
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
324 profile()->GetTestingPrefService(); 327 profile()->GetTestingPrefService();
325 prefs->SetManagedPref(prefs::kManagedDefaultPluginsSetting, 328 prefs->SetManagedPref(prefs::kManagedDefaultPluginsSetting,
326 base::MakeUnique<base::Value>(CONTENT_SETTING_BLOCK)); 329 base::MakeUnique<base::Value>(CONTENT_SETTING_BLOCK));
327 330
328 // All plugins should be blocked now. 331 // All plugins should be blocked now.
329 VerifyPluginContentSetting(host, "foo", CONTENT_SETTING_BLOCK, true, true); 332 VerifyPluginContentSetting(host, "foo", CONTENT_SETTING_BLOCK, true, true);
330 VerifyPluginContentSetting(host, "bar", CONTENT_SETTING_BLOCK, true, true); 333 VerifyPluginContentSetting(host, "bar", CONTENT_SETTING_BLOCK, true, true);
331 VerifyPluginContentSetting(unmatched_host, "bar", CONTENT_SETTING_BLOCK, 334 VerifyPluginContentSetting(unmatched_host, "bar", CONTENT_SETTING_BLOCK,
332 true, true); 335 true, true);
333 } 336 }
OLDNEW
« no previous file with comments | « chrome/browser/plugins/plugin_info_message_filter.cc ('k') | chrome/browser/plugins/plugin_utils.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698