Index: chrome/browser/policy/policy_browsertest.cc |
diff --git a/chrome/browser/policy/policy_browsertest.cc b/chrome/browser/policy/policy_browsertest.cc |
index f1fd484be2391a74542ffde0e38acc483d176668..bc4bc930ab5133bc9c2839738c26540fa5a3e2e8 100644 |
--- a/chrome/browser/policy/policy_browsertest.cc |
+++ b/chrome/browser/policy/policy_browsertest.cc |
@@ -43,6 +43,7 @@ |
#include "chrome/browser/media/media_capture_devices_dispatcher.h" |
#include "chrome/browser/media/media_stream_devices_controller.h" |
#include "chrome/browser/metrics/variations/variations_service.h" |
+#include "chrome/browser/net/prediction_options.h" |
#include "chrome/browser/net/url_request_mock_util.h" |
#include "chrome/browser/plugins/plugin_prefs.h" |
#include "chrome/browser/policy/cloud/test_request_interceptor.h" |
@@ -376,6 +377,10 @@ bool IsJavascriptEnabled(content::WebContents* contents) { |
return result == 123; |
} |
+bool IsNetworkPredictionEnabled(PrefService* prefs) { |
+ return chrome_browser_net::CanPredictNetworkActionsUI(prefs); |
+} |
+ |
void CopyPluginListAndQuit(std::vector<content::WebPluginInfo>* out, |
const std::vector<content::WebPluginInfo>& in) { |
*out = in; |
@@ -1921,6 +1926,35 @@ IN_PROC_BROWSER_TEST_F(PolicyTest, Javascript) { |
EXPECT_TRUE(IsJavascriptEnabled(contents)); |
} |
+IN_PROC_BROWSER_TEST_F(PolicyTest, NetworkPrediction) { |
+ PrefService* prefs = browser()->profile()->GetPrefs(); |
+ |
+ // Enabled by default. |
+ EXPECT_TRUE(IsNetworkPredictionEnabled(prefs)); |
+ |
+ // Disable by old, deprecated policy. |
+ PolicyMap policies; |
+ policies.Set(key::kDnsPrefetchingEnabled, |
+ POLICY_LEVEL_MANDATORY, |
+ POLICY_SCOPE_USER, |
+ new base::FundamentalValue(false), |
+ NULL); |
+ UpdateProviderPolicy(policies); |
+ |
+ EXPECT_FALSE(IsNetworkPredictionEnabled(prefs)); |
+ |
+ // Enabled by new policy, this should override old one. |
+ policies.Set( |
+ key::kNetworkPredictionOptions, |
+ POLICY_LEVEL_MANDATORY, |
+ POLICY_SCOPE_USER, |
+ new base::FundamentalValue(chrome_browser_net::NETWORK_PREDICTION_ALWAYS), |
+ NULL); |
+ UpdateProviderPolicy(policies); |
+ |
+ EXPECT_TRUE(IsNetworkPredictionEnabled(prefs)); |
+} |
+ |
IN_PROC_BROWSER_TEST_F(PolicyTest, SavingBrowserHistoryDisabled) { |
// Verifies that browsing history is not saved. |
PolicyMap policies; |