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

Side by Side Diff: chrome/browser/policy/policy_browsertest.cc

Issue 11275088: Remove implicit scoped_refptr operator T* Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 8 years, 1 month 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 (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 772 matching lines...) Expand 10 before | Expand all | Expand 10 after
783 IN_PROC_BROWSER_TEST_F(PolicyTest, DisabledPlugins) { 783 IN_PROC_BROWSER_TEST_F(PolicyTest, DisabledPlugins) {
784 // Verifies that plugins can be forced to be disabled by policy. 784 // Verifies that plugins can be forced to be disabled by policy.
785 785
786 // Verify that the Flash plugin exists and that it can be enabled and disabled 786 // Verify that the Flash plugin exists and that it can be enabled and disabled
787 // by the user. 787 // by the user.
788 std::vector<webkit::WebPluginInfo> plugins; 788 std::vector<webkit::WebPluginInfo> plugins;
789 GetPluginList(&plugins); 789 GetPluginList(&plugins);
790 const webkit::WebPluginInfo* flash = GetFlashPlugin(plugins); 790 const webkit::WebPluginInfo* flash = GetFlashPlugin(plugins);
791 if (!flash) 791 if (!flash)
792 return; 792 return;
793 PluginPrefs* plugin_prefs = PluginPrefs::GetForProfile(browser()->profile()); 793 PluginPrefs* plugin_prefs =
794 PluginPrefs::GetForProfile(browser()->profile()).get();
794 EXPECT_TRUE(plugin_prefs->IsPluginEnabled(*flash)); 795 EXPECT_TRUE(plugin_prefs->IsPluginEnabled(*flash));
795 EXPECT_TRUE(SetPluginEnabled(plugin_prefs, flash, false)); 796 EXPECT_TRUE(SetPluginEnabled(plugin_prefs, flash, false));
796 EXPECT_FALSE(plugin_prefs->IsPluginEnabled(*flash)); 797 EXPECT_FALSE(plugin_prefs->IsPluginEnabled(*flash));
797 EXPECT_TRUE(SetPluginEnabled(plugin_prefs, flash, true)); 798 EXPECT_TRUE(SetPluginEnabled(plugin_prefs, flash, true));
798 EXPECT_TRUE(plugin_prefs->IsPluginEnabled(*flash)); 799 EXPECT_TRUE(plugin_prefs->IsPluginEnabled(*flash));
799 800
800 // Now disable it with a policy. 801 // Now disable it with a policy.
801 base::ListValue disabled_plugins; 802 base::ListValue disabled_plugins;
802 disabled_plugins.Append(base::Value::CreateStringValue("*Flash*")); 803 disabled_plugins.Append(base::Value::CreateStringValue("*Flash*"));
803 PolicyMap policies; 804 PolicyMap policies;
804 policies.Set(key::kDisabledPlugins, POLICY_LEVEL_MANDATORY, 805 policies.Set(key::kDisabledPlugins, POLICY_LEVEL_MANDATORY,
805 POLICY_SCOPE_USER, disabled_plugins.DeepCopy()); 806 POLICY_SCOPE_USER, disabled_plugins.DeepCopy());
806 provider_.UpdateChromePolicy(policies); 807 provider_.UpdateChromePolicy(policies);
807 EXPECT_FALSE(plugin_prefs->IsPluginEnabled(*flash)); 808 EXPECT_FALSE(plugin_prefs->IsPluginEnabled(*flash));
808 // The user shouldn't be able to enable it. 809 // The user shouldn't be able to enable it.
809 EXPECT_FALSE(SetPluginEnabled(plugin_prefs, flash, true)); 810 EXPECT_FALSE(SetPluginEnabled(plugin_prefs, flash, true));
810 EXPECT_FALSE(plugin_prefs->IsPluginEnabled(*flash)); 811 EXPECT_FALSE(plugin_prefs->IsPluginEnabled(*flash));
811 } 812 }
812 813
813 IN_PROC_BROWSER_TEST_F(PolicyTest, DisabledPluginsExceptions) { 814 IN_PROC_BROWSER_TEST_F(PolicyTest, DisabledPluginsExceptions) {
814 // Verifies that plugins with an exception in the blacklist can be enabled. 815 // Verifies that plugins with an exception in the blacklist can be enabled.
815 816
816 // Verify that the Flash plugin exists and that it can be enabled and disabled 817 // Verify that the Flash plugin exists and that it can be enabled and disabled
817 // by the user. 818 // by the user.
818 std::vector<webkit::WebPluginInfo> plugins; 819 std::vector<webkit::WebPluginInfo> plugins;
819 GetPluginList(&plugins); 820 GetPluginList(&plugins);
820 const webkit::WebPluginInfo* flash = GetFlashPlugin(plugins); 821 const webkit::WebPluginInfo* flash = GetFlashPlugin(plugins);
821 if (!flash) 822 if (!flash)
822 return; 823 return;
823 PluginPrefs* plugin_prefs = PluginPrefs::GetForProfile(browser()->profile()); 824 PluginPrefs* plugin_prefs =
825 PluginPrefs::GetForProfile(browser()->profile()).get();
824 EXPECT_TRUE(plugin_prefs->IsPluginEnabled(*flash)); 826 EXPECT_TRUE(plugin_prefs->IsPluginEnabled(*flash));
825 827
826 // Disable all plugins. 828 // Disable all plugins.
827 base::ListValue disabled_plugins; 829 base::ListValue disabled_plugins;
828 disabled_plugins.Append(base::Value::CreateStringValue("*")); 830 disabled_plugins.Append(base::Value::CreateStringValue("*"));
829 PolicyMap policies; 831 PolicyMap policies;
830 policies.Set(key::kDisabledPlugins, POLICY_LEVEL_MANDATORY, 832 policies.Set(key::kDisabledPlugins, POLICY_LEVEL_MANDATORY,
831 POLICY_SCOPE_USER, disabled_plugins.DeepCopy()); 833 POLICY_SCOPE_USER, disabled_plugins.DeepCopy());
832 provider_.UpdateChromePolicy(policies); 834 provider_.UpdateChromePolicy(policies);
833 EXPECT_FALSE(plugin_prefs->IsPluginEnabled(*flash)); 835 EXPECT_FALSE(plugin_prefs->IsPluginEnabled(*flash));
(...skipping 17 matching lines...) Expand all
851 EXPECT_TRUE(plugin_prefs->IsPluginEnabled(*flash)); 853 EXPECT_TRUE(plugin_prefs->IsPluginEnabled(*flash));
852 } 854 }
853 855
854 IN_PROC_BROWSER_TEST_F(PolicyTest, EnabledPlugins) { 856 IN_PROC_BROWSER_TEST_F(PolicyTest, EnabledPlugins) {
855 // Verifies that a plugin can be force-installed with a policy. 857 // Verifies that a plugin can be force-installed with a policy.
856 std::vector<webkit::WebPluginInfo> plugins; 858 std::vector<webkit::WebPluginInfo> plugins;
857 GetPluginList(&plugins); 859 GetPluginList(&plugins);
858 const webkit::WebPluginInfo* flash = GetFlashPlugin(plugins); 860 const webkit::WebPluginInfo* flash = GetFlashPlugin(plugins);
859 if (!flash) 861 if (!flash)
860 return; 862 return;
861 PluginPrefs* plugin_prefs = PluginPrefs::GetForProfile(browser()->profile()); 863 PluginPrefs* plugin_prefs =
864 PluginPrefs::GetForProfile(browser()->profile()).get();
862 EXPECT_TRUE(plugin_prefs->IsPluginEnabled(*flash)); 865 EXPECT_TRUE(plugin_prefs->IsPluginEnabled(*flash));
863 866
864 // The user disables it and then a policy forces it to be enabled. 867 // The user disables it and then a policy forces it to be enabled.
865 EXPECT_TRUE(SetPluginEnabled(plugin_prefs, flash, false)); 868 EXPECT_TRUE(SetPluginEnabled(plugin_prefs, flash, false));
866 EXPECT_FALSE(plugin_prefs->IsPluginEnabled(*flash)); 869 EXPECT_FALSE(plugin_prefs->IsPluginEnabled(*flash));
867 base::ListValue plugin_list; 870 base::ListValue plugin_list;
868 plugin_list.Append(base::Value::CreateStringValue(kFlashPluginName)); 871 plugin_list.Append(base::Value::CreateStringValue(kFlashPluginName));
869 PolicyMap policies; 872 PolicyMap policies;
870 policies.Set(key::kEnabledPlugins, POLICY_LEVEL_MANDATORY, 873 policies.Set(key::kEnabledPlugins, POLICY_LEVEL_MANDATORY,
871 POLICY_SCOPE_USER, plugin_list.DeepCopy()); 874 POLICY_SCOPE_USER, plugin_list.DeepCopy());
(...skipping 702 matching lines...) Expand 10 before | Expand all | Expand 10 after
1574 EXPECT_EQ(kExpectedLabel, text.substr(0, kExpectedLabel.size())); 1577 EXPECT_EQ(kExpectedLabel, text.substr(0, kExpectedLabel.size()));
1575 // HomepageLocation has policy ID 1. 1578 // HomepageLocation has policy ID 1.
1576 EXPECT_NE(std::string::npos, text.find("<br>1 ---")); 1579 EXPECT_NE(std::string::npos, text.find("<br>1 ---"));
1577 // ShowHomeButton has policy ID 35. 1580 // ShowHomeButton has policy ID 35.
1578 EXPECT_NE(std::string::npos, text.find("<br>35 ---")); 1581 EXPECT_NE(std::string::npos, text.find("<br>35 ---"));
1579 // BookmarkBarEnabled has policy ID 82. 1582 // BookmarkBarEnabled has policy ID 82.
1580 EXPECT_NE(std::string::npos, text.find("<br>82 ---")); 1583 EXPECT_NE(std::string::npos, text.find("<br>82 ---"));
1581 } 1584 }
1582 1585
1583 } // namespace policy 1586 } // namespace policy
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698