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/plugins/plugin_prefs.h" | 5 #include "chrome/browser/plugins/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/message_loop.h" | |
10 #include "base/path_service.h" | 9 #include "base/path_service.h" |
11 #include "base/run_loop.h" | 10 #include "base/run_loop.h" |
12 #include "base/strings/utf_string_conversions.h" | 11 #include "base/strings/utf_string_conversions.h" |
13 #include "chrome/common/chrome_constants.h" | 12 #include "chrome/common/chrome_constants.h" |
14 #include "chrome/common/chrome_paths.h" | 13 #include "chrome/common/chrome_paths.h" |
15 #include "content/public/browser/plugin_service.h" | 14 #include "content/public/browser/plugin_service.h" |
16 #include "content/public/browser/render_process_host.h" | 15 #include "content/public/browser/render_process_host.h" |
17 #include "content/public/common/webplugininfo.h" | 16 #include "content/public/common/webplugininfo.h" |
18 #include "content/public/test/test_browser_thread.h" | 17 #include "content/public/test/test_browser_thread_bundle.h" |
19 #include "content/public/test/test_utils.h" | 18 #include "content/public/test/test_utils.h" |
20 #include "testing/gtest/include/gtest/gtest.h" | 19 #include "testing/gtest/include/gtest/gtest.h" |
21 | 20 |
22 using base::ASCIIToUTF16; | 21 using base::ASCIIToUTF16; |
23 using content::BrowserThread; | 22 using content::BrowserThread; |
24 using content::PluginService; | 23 using content::PluginService; |
25 | 24 |
26 namespace { | 25 namespace { |
27 | 26 |
28 void CanEnablePluginCallback(const base::Closure& quit_closure, | 27 void CanEnablePluginCallback(const base::Closure& quit_closure, |
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
199 EXPECT_EQ(PluginPrefs::NO_POLICY, | 198 EXPECT_EQ(PluginPrefs::NO_POLICY, |
200 plugin_prefs_->PolicyStatusForPlugin(kGoogleMars)); | 199 plugin_prefs_->PolicyStatusForPlugin(kGoogleMars)); |
201 EXPECT_EQ(PluginPrefs::POLICY_DISABLED, | 200 EXPECT_EQ(PluginPrefs::POLICY_DISABLED, |
202 plugin_prefs_->PolicyStatusForPlugin(k42)); | 201 plugin_prefs_->PolicyStatusForPlugin(k42)); |
203 } | 202 } |
204 | 203 |
205 // Linux Aura doesn't support NPAPI. | 204 // Linux Aura doesn't support NPAPI. |
206 #if !(defined(OS_LINUX) && defined(USE_AURA)) | 205 #if !(defined(OS_LINUX) && defined(USE_AURA)) |
207 | 206 |
208 TEST_F(PluginPrefsTest, UnifiedPepperFlashState) { | 207 TEST_F(PluginPrefsTest, UnifiedPepperFlashState) { |
| 208 content::TestBrowserThreadBundle browser_threads; |
209 base::ShadowingAtExitManager at_exit_manager_; // Destroys the PluginService. | 209 base::ShadowingAtExitManager at_exit_manager_; // Destroys the PluginService. |
210 | 210 |
211 base::MessageLoop message_loop; | |
212 content::TestBrowserThread ui_thread(BrowserThread::UI, &message_loop); | |
213 PluginService::GetInstance()->Init(); | 211 PluginService::GetInstance()->Init(); |
214 PluginService::GetInstance()->DisablePluginsDiscoveryForTesting(); | 212 PluginService::GetInstance()->DisablePluginsDiscoveryForTesting(); |
215 | 213 |
216 base::string16 component_updated_plugin_name( | 214 base::string16 component_updated_plugin_name( |
217 ASCIIToUTF16("Component-updated Pepper Flash")); | 215 ASCIIToUTF16("Component-updated Pepper Flash")); |
218 content::WebPluginInfo component_updated_plugin_1( | 216 content::WebPluginInfo component_updated_plugin_1( |
219 component_updated_plugin_name, | 217 component_updated_plugin_name, |
220 GetComponentUpdatedPepperFlashPath(FILE_PATH_LITERAL("11.3.31.227")), | 218 GetComponentUpdatedPepperFlashPath(FILE_PATH_LITERAL("11.3.31.227")), |
221 ASCIIToUTF16("11.3.31.227"), | 219 ASCIIToUTF16("11.3.31.227"), |
222 ASCIIToUTF16("")); | 220 ASCIIToUTF16("")); |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
276 EXPECT_FALSE(plugin_prefs_->IsPluginEnabled(component_updated_plugin_2)); | 274 EXPECT_FALSE(plugin_prefs_->IsPluginEnabled(component_updated_plugin_2)); |
277 EXPECT_FALSE(plugin_prefs_->IsPluginEnabled(bundled_plugin)); | 275 EXPECT_FALSE(plugin_prefs_->IsPluginEnabled(bundled_plugin)); |
278 | 276 |
279 EnablePluginSynchronously(true, bundled_plugin.path, true); | 277 EnablePluginSynchronously(true, bundled_plugin.path, true); |
280 EXPECT_FALSE(plugin_prefs_->IsPluginEnabled(component_updated_plugin_1)); | 278 EXPECT_FALSE(plugin_prefs_->IsPluginEnabled(component_updated_plugin_1)); |
281 EXPECT_FALSE(plugin_prefs_->IsPluginEnabled(component_updated_plugin_2)); | 279 EXPECT_FALSE(plugin_prefs_->IsPluginEnabled(component_updated_plugin_2)); |
282 EXPECT_TRUE(plugin_prefs_->IsPluginEnabled(bundled_plugin)); | 280 EXPECT_TRUE(plugin_prefs_->IsPluginEnabled(bundled_plugin)); |
283 } | 281 } |
284 | 282 |
285 #endif | 283 #endif |
OLD | NEW |