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 <algorithm> | 5 #include <algorithm> |
6 #include <string> | 6 #include <string> |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
(...skipping 19 matching lines...) Expand all Loading... |
30 #include "chrome/browser/extensions/extension_system.h" | 30 #include "chrome/browser/extensions/extension_system.h" |
31 #include "chrome/browser/infobars/infobar_tab_helper.h" | 31 #include "chrome/browser/infobars/infobar_tab_helper.h" |
32 #include "chrome/browser/net/url_request_mock_util.h" | 32 #include "chrome/browser/net/url_request_mock_util.h" |
33 #include "chrome/browser/plugins/plugin_prefs.h" | 33 #include "chrome/browser/plugins/plugin_prefs.h" |
34 #include "chrome/browser/policy/browser_policy_connector.h" | 34 #include "chrome/browser/policy/browser_policy_connector.h" |
35 #include "chrome/browser/policy/mock_configuration_policy_provider.h" | 35 #include "chrome/browser/policy/mock_configuration_policy_provider.h" |
36 #include "chrome/browser/policy/policy_map.h" | 36 #include "chrome/browser/policy/policy_map.h" |
37 #include "chrome/browser/prefs/pref_service.h" | 37 #include "chrome/browser/prefs/pref_service.h" |
38 #include "chrome/browser/prefs/session_startup_pref.h" | 38 #include "chrome/browser/prefs/session_startup_pref.h" |
39 #include "chrome/browser/profiles/profile.h" | 39 #include "chrome/browser/profiles/profile.h" |
40 #include "chrome/browser/net/url_request_mock_util.h" | |
41 #include "chrome/browser/search_engines/template_url.h" | 40 #include "chrome/browser/search_engines/template_url.h" |
42 #include "chrome/browser/search_engines/template_url_service.h" | 41 #include "chrome/browser/search_engines/template_url_service.h" |
43 #include "chrome/browser/search_engines/template_url_service_factory.h" | 42 #include "chrome/browser/search_engines/template_url_service_factory.h" |
44 #include "chrome/browser/translate/translate_infobar_delegate.h" | 43 #include "chrome/browser/translate/translate_infobar_delegate.h" |
45 #include "chrome/browser/ui/bookmarks/bookmark_bar.h" | 44 #include "chrome/browser/ui/bookmarks/bookmark_bar.h" |
46 #include "chrome/browser/ui/browser.h" | 45 #include "chrome/browser/ui/browser.h" |
47 #include "chrome/browser/ui/browser_commands.h" | 46 #include "chrome/browser/ui/browser_commands.h" |
48 #include "chrome/browser/ui/browser_list.h" | 47 #include "chrome/browser/ui/browser_list.h" |
49 #include "chrome/browser/ui/browser_tabstrip.h" | 48 #include "chrome/browser/ui/browser_tabstrip.h" |
50 #include "chrome/browser/ui/browser_window.h" | 49 #include "chrome/browser/ui/browser_window.h" |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
87 #include "net/base/net_util.h" | 86 #include "net/base/net_util.h" |
88 #include "net/http/http_stream_factory.h" | 87 #include "net/http/http_stream_factory.h" |
89 #include "net/url_request/url_request.h" | 88 #include "net/url_request/url_request.h" |
90 #include "net/url_request/url_request_filter.h" | 89 #include "net/url_request/url_request_filter.h" |
91 #include "policy/policy_constants.h" | 90 #include "policy/policy_constants.h" |
92 #include "testing/gmock/include/gmock/gmock.h" | 91 #include "testing/gmock/include/gmock/gmock.h" |
93 #include "testing/gtest/include/gtest/gtest.h" | 92 #include "testing/gtest/include/gtest/gtest.h" |
94 #include "ui/base/l10n/l10n_util.h" | 93 #include "ui/base/l10n/l10n_util.h" |
95 #include "ui/base/resource/resource_bundle.h" | 94 #include "ui/base/resource/resource_bundle.h" |
96 #include "webkit/plugins/npapi/plugin_utils.h" | 95 #include "webkit/plugins/npapi/plugin_utils.h" |
| 96 #include "webkit/plugins/plugin_constants.h" |
97 #include "webkit/plugins/webplugininfo.h" | 97 #include "webkit/plugins/webplugininfo.h" |
98 | 98 |
99 #if defined(OS_CHROMEOS) | 99 #if defined(OS_CHROMEOS) |
100 #include "ash/accelerators/accelerator_controller.h" | 100 #include "ash/accelerators/accelerator_controller.h" |
101 #include "ash/accelerators/accelerator_table.h" | 101 #include "ash/accelerators/accelerator_table.h" |
102 #include "ash/shell.h" | 102 #include "ash/shell.h" |
103 #include "ash/shell_delegate.h" | 103 #include "ash/shell_delegate.h" |
104 #include "chrome/browser/chromeos/audio/audio_handler.h" | 104 #include "chrome/browser/chromeos/audio/audio_handler.h" |
105 #endif | 105 #endif |
106 | 106 |
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
258 void GetPluginList(std::vector<webkit::WebPluginInfo>* plugins) { | 258 void GetPluginList(std::vector<webkit::WebPluginInfo>* plugins) { |
259 content::PluginService* service = content::PluginService::GetInstance(); | 259 content::PluginService* service = content::PluginService::GetInstance(); |
260 service->GetPlugins(base::Bind(CopyPluginListAndQuit, plugins)); | 260 service->GetPlugins(base::Bind(CopyPluginListAndQuit, plugins)); |
261 content::RunMessageLoop(); | 261 content::RunMessageLoop(); |
262 } | 262 } |
263 | 263 |
264 const webkit::WebPluginInfo* GetFlashPlugin( | 264 const webkit::WebPluginInfo* GetFlashPlugin( |
265 const std::vector<webkit::WebPluginInfo>& plugins) { | 265 const std::vector<webkit::WebPluginInfo>& plugins) { |
266 const webkit::WebPluginInfo* flash = NULL; | 266 const webkit::WebPluginInfo* flash = NULL; |
267 for (size_t i = 0; i < plugins.size(); ++i) { | 267 for (size_t i = 0; i < plugins.size(); ++i) { |
268 if (plugins[i].name == ASCIIToUTF16("Shockwave Flash")) { | 268 if (plugins[i].name == ASCIIToUTF16(kFlashPluginName)) { |
269 flash = &plugins[i]; | 269 flash = &plugins[i]; |
270 break; | 270 break; |
271 } | 271 } |
272 } | 272 } |
273 #if defined(OFFICIAL_BUILD) | 273 #if defined(OFFICIAL_BUILD) |
274 // Official builds bundle Flash. | 274 // Official builds bundle Flash. |
275 EXPECT_TRUE(flash); | 275 EXPECT_TRUE(flash); |
276 #else | 276 #else |
277 if (!flash) | 277 if (!flash) |
278 LOG(INFO) << "Test skipped because the Flash plugin couldn't be found."; | 278 LOG(INFO) << "Test skipped because the Flash plugin couldn't be found."; |
(...skipping 494 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
773 const webkit::WebPluginInfo* flash = GetFlashPlugin(plugins); | 773 const webkit::WebPluginInfo* flash = GetFlashPlugin(plugins); |
774 if (!flash) | 774 if (!flash) |
775 return; | 775 return; |
776 PluginPrefs* plugin_prefs = PluginPrefs::GetForProfile(browser()->profile()); | 776 PluginPrefs* plugin_prefs = PluginPrefs::GetForProfile(browser()->profile()); |
777 EXPECT_TRUE(plugin_prefs->IsPluginEnabled(*flash)); | 777 EXPECT_TRUE(plugin_prefs->IsPluginEnabled(*flash)); |
778 | 778 |
779 // The user disables it and then a policy forces it to be enabled. | 779 // The user disables it and then a policy forces it to be enabled. |
780 EXPECT_TRUE(SetPluginEnabled(plugin_prefs, flash, false)); | 780 EXPECT_TRUE(SetPluginEnabled(plugin_prefs, flash, false)); |
781 EXPECT_FALSE(plugin_prefs->IsPluginEnabled(*flash)); | 781 EXPECT_FALSE(plugin_prefs->IsPluginEnabled(*flash)); |
782 base::ListValue plugin_list; | 782 base::ListValue plugin_list; |
783 plugin_list.Append(base::Value::CreateStringValue("Shockwave Flash")); | 783 plugin_list.Append(base::Value::CreateStringValue(kFlashPluginName)); |
784 PolicyMap policies; | 784 PolicyMap policies; |
785 policies.Set(key::kEnabledPlugins, POLICY_LEVEL_MANDATORY, | 785 policies.Set(key::kEnabledPlugins, POLICY_LEVEL_MANDATORY, |
786 POLICY_SCOPE_USER, plugin_list.DeepCopy()); | 786 POLICY_SCOPE_USER, plugin_list.DeepCopy()); |
787 provider_.UpdateChromePolicy(policies); | 787 provider_.UpdateChromePolicy(policies); |
788 EXPECT_TRUE(plugin_prefs->IsPluginEnabled(*flash)); | 788 EXPECT_TRUE(plugin_prefs->IsPluginEnabled(*flash)); |
789 // The user can't disable it anymore. | 789 // The user can't disable it anymore. |
790 EXPECT_FALSE(SetPluginEnabled(plugin_prefs, flash, false)); | 790 EXPECT_FALSE(SetPluginEnabled(plugin_prefs, flash, false)); |
791 EXPECT_TRUE(plugin_prefs->IsPluginEnabled(*flash)); | 791 EXPECT_TRUE(plugin_prefs->IsPluginEnabled(*flash)); |
792 | 792 |
793 // When a plugin is both enabled and disabled, the whitelist takes precedence. | 793 // When a plugin is both enabled and disabled, the whitelist takes precedence. |
(...skipping 703 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1497 INSTANTIATE_TEST_CASE_P( | 1497 INSTANTIATE_TEST_CASE_P( |
1498 RestoreOnStartupPolicyTestInstance, | 1498 RestoreOnStartupPolicyTestInstance, |
1499 RestoreOnStartupPolicyTest, | 1499 RestoreOnStartupPolicyTest, |
1500 testing::Values(&RestoreOnStartupPolicyTest::HomepageIsNotNTP, | 1500 testing::Values(&RestoreOnStartupPolicyTest::HomepageIsNotNTP, |
1501 &RestoreOnStartupPolicyTest::HomepageIsNTP, | 1501 &RestoreOnStartupPolicyTest::HomepageIsNTP, |
1502 &RestoreOnStartupPolicyTest::ListOfURLs, | 1502 &RestoreOnStartupPolicyTest::ListOfURLs, |
1503 &RestoreOnStartupPolicyTest::NTP, | 1503 &RestoreOnStartupPolicyTest::NTP, |
1504 &RestoreOnStartupPolicyTest::Last)); | 1504 &RestoreOnStartupPolicyTest::Last)); |
1505 | 1505 |
1506 } // namespace policy | 1506 } // namespace policy |
OLD | NEW |