Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/plugin_prefs.h" | 5 #include "chrome/browser/plugin_prefs.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/message_loop.h" | 9 #include "base/message_loop.h" |
| 10 #include "base/threading/sequenced_worker_pool.h" | 10 #include "base/threading/sequenced_worker_pool.h" |
| 11 #include "base/utf_string_conversions.h" | 11 #include "base/utf_string_conversions.h" |
| 12 #include "chrome/test/base/testing_browser_process.h" | 12 #include "chrome/test/base/testing_browser_process.h" |
| 13 #include "chrome/test/base/testing_profile.h" | 13 #include "chrome/test/base/testing_profile.h" |
| 14 #include "chrome/test/base/testing_profile_manager.h" | 14 #include "chrome/test/base/testing_profile_manager.h" |
| 15 #include "content/public/browser/plugin_service.h" | 15 #include "content/public/browser/plugin_service.h" |
| 16 #include "content/public/test/test_browser_thread.h" | 16 #include "content/public/test/test_browser_thread.h" |
| 17 #include "testing/gtest/include/gtest/gtest.h" | 17 #include "testing/gtest/include/gtest/gtest.h" |
| 18 #include "webkit/plugins/npapi/mock_plugin_list.cc" | 18 #include "webkit/plugins/npapi/mock_plugin_list.cc" |
| 19 #include "webkit/plugins/webplugininfo.h" | 19 #include "webkit/plugins/webplugininfo.h" |
| 20 | 20 |
| 21 using content::BrowserThread; | 21 using content::BrowserThread; |
| 22 using content::PluginService; | 22 using content::PluginService; |
| 23 | 23 |
| 24 namespace { | |
| 25 | |
| 26 void CanEnablePluginCallback(bool dummy) { | |
|
Bernhard Bauer
2012/08/31 12:54:11
Nit: Aaaand now please don't call the parameter |d
ibraaaa
2012/09/03 08:55:22
Done.
| |
| 27 ASSERT_TRUE(dummy); | |
| 28 MessageLoop::current()->QuitWhenIdle(); | |
| 29 } | |
| 30 | |
| 31 } // namespace | |
| 32 | |
| 24 class PluginPrefsTest : public ::testing::Test { | 33 class PluginPrefsTest : public ::testing::Test { |
| 25 public: | 34 public: |
| 26 virtual void SetUp() OVERRIDE { | 35 virtual void SetUp() OVERRIDE { |
| 27 plugin_prefs_ = new PluginPrefs(); | 36 plugin_prefs_ = new PluginPrefs(); |
| 28 } | 37 } |
| 29 | 38 |
| 30 void SetPolicyEnforcedPluginPatterns( | 39 void SetPolicyEnforcedPluginPatterns( |
| 31 const std::set<string16>& disabled, | 40 const std::set<string16>& disabled, |
| 32 const std::set<string16>& disabled_exceptions, | 41 const std::set<string16>& disabled_exceptions, |
| 33 const std::set<string16>& enabled) { | 42 const std::set<string16>& enabled) { |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 157 profile_manager.CreateTestingProfile("Profile 1"); | 166 profile_manager.CreateTestingProfile("Profile 1"); |
| 158 PluginPrefs* plugin_prefs = PluginPrefs::GetForTestingProfile(profile_1); | 167 PluginPrefs* plugin_prefs = PluginPrefs::GetForTestingProfile(profile_1); |
| 159 ASSERT_TRUE(plugin_prefs); | 168 ASSERT_TRUE(plugin_prefs); |
| 160 plugin_prefs->SetPluginListForTesting(&plugin_list); | 169 plugin_prefs->SetPluginListForTesting(&plugin_list); |
| 161 | 170 |
| 162 webkit::WebPluginInfo plugin(ASCIIToUTF16("Foo"), | 171 webkit::WebPluginInfo plugin(ASCIIToUTF16("Foo"), |
| 163 FilePath(FILE_PATH_LITERAL("/path/too/foo")), | 172 FilePath(FILE_PATH_LITERAL("/path/too/foo")), |
| 164 ASCIIToUTF16("1.0.0"), | 173 ASCIIToUTF16("1.0.0"), |
| 165 ASCIIToUTF16("Foo plug-in")); | 174 ASCIIToUTF16("Foo plug-in")); |
| 166 plugin_list.AddPluginToLoad(plugin); | 175 plugin_list.AddPluginToLoad(plugin); |
| 167 PluginPrefs::EnablePluginGlobally(false, plugin.path, | 176 PluginPrefs::EnablePluginGlobally( |
| 168 MessageLoop::QuitClosure()); | 177 false, plugin.path, |
| 178 base::Bind(&CanEnablePluginCallback)); | |
| 169 | 179 |
| 170 message_loop.Run(); | 180 message_loop.Run(); |
| 171 | 181 |
| 172 EXPECT_FALSE(plugin_prefs->IsPluginEnabled(plugin)); | 182 EXPECT_FALSE(plugin_prefs->IsPluginEnabled(plugin)); |
| 173 | 183 |
| 174 TestingProfile* profile_2 = | 184 TestingProfile* profile_2 = |
| 175 profile_manager.CreateTestingProfile("Profile 2"); | 185 profile_manager.CreateTestingProfile("Profile 2"); |
| 176 PluginPrefs* plugin_prefs_2 = PluginPrefs::GetForTestingProfile(profile_2); | 186 PluginPrefs* plugin_prefs_2 = PluginPrefs::GetForTestingProfile(profile_2); |
| 177 ASSERT_TRUE(plugin_prefs); | 187 ASSERT_TRUE(plugin_prefs); |
| 178 plugin_prefs_2->SetPluginListForTesting(&plugin_list); | 188 plugin_prefs_2->SetPluginListForTesting(&plugin_list); |
| 179 EXPECT_FALSE(plugin_prefs_2->IsPluginEnabled(plugin)); | 189 EXPECT_FALSE(plugin_prefs_2->IsPluginEnabled(plugin)); |
| 180 | 190 |
| 181 profile_manager.DeleteTestingProfile("Profile 1"); | 191 profile_manager.DeleteTestingProfile("Profile 1"); |
| 182 profile_manager.DeleteTestingProfile("Profile 2"); | 192 profile_manager.DeleteTestingProfile("Profile 2"); |
| 183 } | 193 } |
| OLD | NEW |