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

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

Issue 2356053002: [HBD] Only use Plugin Content Settings for Flash. (Closed)
Patch Set: address xhwang comments Created 4 years, 2 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 "build/build_config.h" 13 #include "build/build_config.h"
14 #include "chrome/browser/content_settings/host_content_settings_map_factory.h" 14 #include "chrome/browser/content_settings/host_content_settings_map_factory.h"
15 #include "chrome/browser/plugins/plugin_utils.h" 15 #include "chrome/browser/plugins/plugin_utils.h"
16 #include "chrome/common/pref_names.h" 16 #include "chrome/common/pref_names.h"
17 #include "chrome/common/render_messages.h" 17 #include "chrome/common/render_messages.h"
18 #include "chrome/test/base/testing_profile.h" 18 #include "chrome/test/base/testing_profile.h"
19 #include "components/content_settings/core/browser/host_content_settings_map.h" 19 #include "components/content_settings/core/browser/host_content_settings_map.h"
20 #include "components/content_settings/core/common/pref_names.h" 20 #include "components/content_settings/core/common/pref_names.h"
21 #include "components/syncable_prefs/testing_pref_service_syncable.h" 21 #include "components/syncable_prefs/testing_pref_service_syncable.h"
22 #include "content/public/browser/plugin_service.h" 22 #include "content/public/browser/plugin_service.h"
23 #include "content/public/browser/plugin_service_filter.h" 23 #include "content/public/browser/plugin_service_filter.h"
24 #include "content/public/browser/render_process_host.h" 24 #include "content/public/browser/render_process_host.h"
25 #include "content/public/common/content_constants.h"
25 #include "content/public/test/test_browser_thread_bundle.h" 26 #include "content/public/test/test_browser_thread_bundle.h"
26 #include "testing/gmock/include/gmock/gmock.h" 27 #include "testing/gmock/include/gmock/gmock.h"
27 #include "testing/gtest/include/gtest/gtest.h" 28 #include "testing/gtest/include/gtest/gtest.h"
28 29
29 using content::PluginService; 30 using content::PluginService;
30 31
31 namespace { 32 namespace {
32 33
33 void PluginsLoaded(const base::Closure& callback, 34 void PluginsLoaded(const base::Closure& callback,
34 const std::vector<content::WebPluginInfo>& plugins) { 35 const std::vector<content::WebPluginInfo>& plugins) {
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 138
138 void VerifyPluginContentSetting(const GURL& url, 139 void VerifyPluginContentSetting(const GURL& url,
139 const std::string& plugin, 140 const std::string& plugin,
140 ContentSetting expected_setting, 141 ContentSetting expected_setting,
141 bool expected_is_default, 142 bool expected_is_default,
142 bool expected_is_managed) { 143 bool expected_is_managed) {
143 ContentSetting setting = expected_setting == CONTENT_SETTING_DEFAULT ? 144 ContentSetting setting = expected_setting == CONTENT_SETTING_DEFAULT ?
144 CONTENT_SETTING_BLOCK : CONTENT_SETTING_DEFAULT; 145 CONTENT_SETTING_BLOCK : CONTENT_SETTING_DEFAULT;
145 bool is_default = !expected_is_default; 146 bool is_default = !expected_is_default;
146 bool is_managed = !expected_is_managed; 147 bool is_managed = !expected_is_managed;
147 PluginUtils::GetPluginContentSetting( 148
148 host_content_settings_map_, content::WebPluginInfo(), url, url, plugin, 149 // Pass in a fake Flash plugin info.
149 &setting, &is_default, &is_managed); 150 content::WebPluginInfo plugin_info(
151 base::ASCIIToUTF16(content::kFlashPluginName), base::FilePath(),
152 base::ASCIIToUTF16("1"), base::ASCIIToUTF16("Fake Flash"));
153
154 PluginUtils::GetPluginContentSetting(host_content_settings_map_,
155 plugin_info, url, url, plugin,
156 &setting, &is_default, &is_managed);
150 EXPECT_EQ(expected_setting, setting); 157 EXPECT_EQ(expected_setting, setting);
151 EXPECT_EQ(expected_is_default, is_default); 158 EXPECT_EQ(expected_is_default, is_default);
152 EXPECT_EQ(expected_is_managed, is_managed); 159 EXPECT_EQ(expected_is_managed, is_managed);
153 } 160 }
154 161
155 base::FilePath foo_plugin_path_; 162 base::FilePath foo_plugin_path_;
156 base::FilePath bar_plugin_path_; 163 base::FilePath bar_plugin_path_;
157 FakePluginServiceFilter filter_; 164 FakePluginServiceFilter filter_;
158 165
159 private: 166 private:
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
263 profile()->GetTestingPrefService(); 270 profile()->GetTestingPrefService();
264 prefs->SetManagedPref(prefs::kManagedDefaultPluginsSetting, 271 prefs->SetManagedPref(prefs::kManagedDefaultPluginsSetting,
265 new base::FundamentalValue(CONTENT_SETTING_BLOCK)); 272 new base::FundamentalValue(CONTENT_SETTING_BLOCK));
266 273
267 // All plugins should be blocked now. 274 // All plugins should be blocked now.
268 VerifyPluginContentSetting(host, "foo", CONTENT_SETTING_BLOCK, true, true); 275 VerifyPluginContentSetting(host, "foo", CONTENT_SETTING_BLOCK, true, true);
269 VerifyPluginContentSetting(host, "bar", CONTENT_SETTING_BLOCK, true, true); 276 VerifyPluginContentSetting(host, "bar", CONTENT_SETTING_BLOCK, true, true);
270 VerifyPluginContentSetting(unmatched_host, "bar", CONTENT_SETTING_BLOCK, 277 VerifyPluginContentSetting(unmatched_host, "bar", CONTENT_SETTING_BLOCK,
271 true, true); 278 true, true);
272 } 279 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698