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

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

Issue 2369353002: Adds a pref and a policy to decide if PDFs should always be opened externally. (Closed)
Patch Set: Address 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 (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/path_service.h" 9 #include "base/path_service.h"
10 #include "base/run_loop.h" 10 #include "base/run_loop.h"
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 } // namespace 58 } // namespace
59 59
60 class PluginPrefsTest : public ::testing::Test { 60 class PluginPrefsTest : public ::testing::Test {
61 public: 61 public:
62 void SetUp() override { plugin_prefs_ = new PluginPrefs(); } 62 void SetUp() override { plugin_prefs_ = new PluginPrefs(); }
63 63
64 void SetPolicyEnforcedPluginPatterns( 64 void SetPolicyEnforcedPluginPatterns(
65 const std::set<base::string16>& disabled, 65 const std::set<base::string16>& disabled,
66 const std::set<base::string16>& disabled_exceptions, 66 const std::set<base::string16>& disabled_exceptions,
67 const std::set<base::string16>& enabled) { 67 const std::set<base::string16>& enabled) {
68 plugin_prefs_->SetPolicyEnforcedPluginPatterns( 68 plugin_prefs_->SetPolicyEnforcedPluginPatternsForTests(
69 disabled, disabled_exceptions, enabled); 69 disabled, disabled_exceptions, enabled);
70 } 70 }
71 71
72 void SetAlwaysOpenPdfExternally(bool value) {
73 plugin_prefs_->SetAlwaysOpenPdfExternallyForTests(value);
74 }
75
72 protected: 76 protected:
73 void EnablePluginSynchronously(bool enabled, 77 void EnablePluginSynchronously(bool enabled,
74 const base::FilePath& path, 78 const base::FilePath& path,
75 bool expected_can_change) { 79 bool expected_can_change) {
76 base::RunLoop run_loop; 80 base::RunLoop run_loop;
77 plugin_prefs_->EnablePlugin( 81 plugin_prefs_->EnablePlugin(
78 enabled, path, 82 enabled, path,
79 base::Bind(&CanEnablePluginCallback, run_loop.QuitClosure(), 83 base::Bind(&CanEnablePluginCallback, run_loop.QuitClosure(),
80 expected_can_change)); 84 expected_can_change));
81 run_loop.Run(); 85 run_loop.Run();
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
278 EXPECT_FALSE(plugin_prefs_->IsPluginEnabled(component_updated_plugin_2)); 282 EXPECT_FALSE(plugin_prefs_->IsPluginEnabled(component_updated_plugin_2));
279 EXPECT_FALSE(plugin_prefs_->IsPluginEnabled(bundled_plugin)); 283 EXPECT_FALSE(plugin_prefs_->IsPluginEnabled(bundled_plugin));
280 284
281 EnablePluginSynchronously(true, bundled_plugin.path, true); 285 EnablePluginSynchronously(true, bundled_plugin.path, true);
282 EXPECT_FALSE(plugin_prefs_->IsPluginEnabled(component_updated_plugin_1)); 286 EXPECT_FALSE(plugin_prefs_->IsPluginEnabled(component_updated_plugin_1));
283 EXPECT_FALSE(plugin_prefs_->IsPluginEnabled(component_updated_plugin_2)); 287 EXPECT_FALSE(plugin_prefs_->IsPluginEnabled(component_updated_plugin_2));
284 EXPECT_TRUE(plugin_prefs_->IsPluginEnabled(bundled_plugin)); 288 EXPECT_TRUE(plugin_prefs_->IsPluginEnabled(bundled_plugin));
285 } 289 }
286 290
287 #endif 291 #endif
292
293 TEST_F(PluginPrefsTest, AlwaysOpenPdfExternally) {
294 EXPECT_EQ(PluginPrefs::NO_POLICY,
295 plugin_prefs_->PolicyStatusForPlugin(
296 base::ASCIIToUTF16(ChromeContentClient::kPDFPluginName)));
297
298 SetAlwaysOpenPdfExternally(true);
299
300 EXPECT_EQ(PluginPrefs::POLICY_DISABLED,
301 plugin_prefs_->PolicyStatusForPlugin(
302 base::ASCIIToUTF16(ChromeContentClient::kPDFPluginName)));
303 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698