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

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

Issue 431493003: Implement policy for kNetworkPredictionOptions. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 4 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 <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 25 matching lines...) Expand all
36 #include "chrome/browser/extensions/api/messaging/native_message_process_host.h" 36 #include "chrome/browser/extensions/api/messaging/native_message_process_host.h"
37 #include "chrome/browser/extensions/crx_installer.h" 37 #include "chrome/browser/extensions/crx_installer.h"
38 #include "chrome/browser/extensions/extension_service.h" 38 #include "chrome/browser/extensions/extension_service.h"
39 #include "chrome/browser/extensions/unpacked_installer.h" 39 #include "chrome/browser/extensions/unpacked_installer.h"
40 #include "chrome/browser/extensions/updater/extension_cache_fake.h" 40 #include "chrome/browser/extensions/updater/extension_cache_fake.h"
41 #include "chrome/browser/extensions/updater/extension_updater.h" 41 #include "chrome/browser/extensions/updater/extension_updater.h"
42 #include "chrome/browser/infobars/infobar_service.h" 42 #include "chrome/browser/infobars/infobar_service.h"
43 #include "chrome/browser/media/media_capture_devices_dispatcher.h" 43 #include "chrome/browser/media/media_capture_devices_dispatcher.h"
44 #include "chrome/browser/media/media_stream_devices_controller.h" 44 #include "chrome/browser/media/media_stream_devices_controller.h"
45 #include "chrome/browser/metrics/variations/variations_service.h" 45 #include "chrome/browser/metrics/variations/variations_service.h"
46 #include "chrome/browser/net/prediction_options.h"
46 #include "chrome/browser/net/url_request_mock_util.h" 47 #include "chrome/browser/net/url_request_mock_util.h"
47 #include "chrome/browser/plugins/plugin_prefs.h" 48 #include "chrome/browser/plugins/plugin_prefs.h"
48 #include "chrome/browser/policy/cloud/test_request_interceptor.h" 49 #include "chrome/browser/policy/cloud/test_request_interceptor.h"
49 #include "chrome/browser/policy/profile_policy_connector.h" 50 #include "chrome/browser/policy/profile_policy_connector.h"
50 #include "chrome/browser/policy/profile_policy_connector_factory.h" 51 #include "chrome/browser/policy/profile_policy_connector_factory.h"
51 #include "chrome/browser/prefs/session_startup_pref.h" 52 #include "chrome/browser/prefs/session_startup_pref.h"
52 #include "chrome/browser/profiles/profile.h" 53 #include "chrome/browser/profiles/profile.h"
53 #include "chrome/browser/search/instant_service.h" 54 #include "chrome/browser/search/instant_service.h"
54 #include "chrome/browser/search/instant_service_factory.h" 55 #include "chrome/browser/search/instant_service_factory.h"
55 #include "chrome/browser/search/search.h" 56 #include "chrome/browser/search/search.h"
(...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after
369 370
370 bool IsJavascriptEnabled(content::WebContents* contents) { 371 bool IsJavascriptEnabled(content::WebContents* contents) {
371 scoped_ptr<base::Value> value = content::ExecuteScriptAndGetValue( 372 scoped_ptr<base::Value> value = content::ExecuteScriptAndGetValue(
372 contents->GetMainFrame(), "123"); 373 contents->GetMainFrame(), "123");
373 int result = 0; 374 int result = 0;
374 if (!value->GetAsInteger(&result)) 375 if (!value->GetAsInteger(&result))
375 EXPECT_EQ(base::Value::TYPE_NULL, value->GetType()); 376 EXPECT_EQ(base::Value::TYPE_NULL, value->GetType());
376 return result == 123; 377 return result == 123;
377 } 378 }
378 379
380 bool IsNetworkPredictionEnabled(PrefService* prefs) {
381 return chrome_browser_net::CanPredictNetworkActionsUI(prefs);
382 }
383
379 void CopyPluginListAndQuit(std::vector<content::WebPluginInfo>* out, 384 void CopyPluginListAndQuit(std::vector<content::WebPluginInfo>* out,
380 const std::vector<content::WebPluginInfo>& in) { 385 const std::vector<content::WebPluginInfo>& in) {
381 *out = in; 386 *out = in;
382 base::MessageLoop::current()->QuitWhenIdle(); 387 base::MessageLoop::current()->QuitWhenIdle();
383 } 388 }
384 389
385 template<typename T> 390 template<typename T>
386 void CopyValueAndQuit(T* out, T in) { 391 void CopyValueAndQuit(T* out, T in) {
387 *out = in; 392 *out = in;
388 base::MessageLoop::current()->QuitWhenIdle(); 393 base::MessageLoop::current()->QuitWhenIdle();
(...skipping 1521 matching lines...) Expand 10 before | Expand all | Expand 10 after
1910 policies.Set(key::kDefaultJavaScriptSetting, 1915 policies.Set(key::kDefaultJavaScriptSetting,
1911 POLICY_LEVEL_MANDATORY, 1916 POLICY_LEVEL_MANDATORY,
1912 POLICY_SCOPE_USER, 1917 POLICY_SCOPE_USER,
1913 new base::FundamentalValue(CONTENT_SETTING_ALLOW), 1918 new base::FundamentalValue(CONTENT_SETTING_ALLOW),
1914 NULL); 1919 NULL);
1915 UpdateProviderPolicy(policies); 1920 UpdateProviderPolicy(policies);
1916 ui_test_utils::NavigateToURL(browser(), GURL(url::kAboutBlankURL)); 1921 ui_test_utils::NavigateToURL(browser(), GURL(url::kAboutBlankURL));
1917 EXPECT_TRUE(IsJavascriptEnabled(contents)); 1922 EXPECT_TRUE(IsJavascriptEnabled(contents));
1918 } 1923 }
1919 1924
1925 IN_PROC_BROWSER_TEST_F(PolicyTest, NetworkPrediction) {
1926 PrefService* prefs = browser()->profile()->GetPrefs();
1927
1928 // Enabled by default.
1929 EXPECT_TRUE(IsNetworkPredictionEnabled(prefs));
1930
1931 // Disable by old, deprecated policy.
1932 PolicyMap policies;
1933 policies.Set(key::kDnsPrefetchingEnabled,
1934 POLICY_LEVEL_MANDATORY,
1935 POLICY_SCOPE_USER,
1936 new base::FundamentalValue(false),
1937 NULL);
1938 UpdateProviderPolicy(policies);
1939
1940 EXPECT_FALSE(IsNetworkPredictionEnabled(prefs));
1941
1942 // Enabled by new policy, this should override old one.
1943 policies.Set(
1944 key::kNetworkPredictionOptions,
1945 POLICY_LEVEL_MANDATORY,
1946 POLICY_SCOPE_USER,
1947 new base::FundamentalValue(chrome_browser_net::NETWORK_PREDICTION_ALWAYS),
1948 NULL);
1949 UpdateProviderPolicy(policies);
1950
1951 EXPECT_TRUE(IsNetworkPredictionEnabled(prefs));
1952 }
1953
1920 IN_PROC_BROWSER_TEST_F(PolicyTest, SavingBrowserHistoryDisabled) { 1954 IN_PROC_BROWSER_TEST_F(PolicyTest, SavingBrowserHistoryDisabled) {
1921 // Verifies that browsing history is not saved. 1955 // Verifies that browsing history is not saved.
1922 PolicyMap policies; 1956 PolicyMap policies;
1923 policies.Set(key::kSavingBrowserHistoryDisabled, 1957 policies.Set(key::kSavingBrowserHistoryDisabled,
1924 POLICY_LEVEL_MANDATORY, 1958 POLICY_LEVEL_MANDATORY,
1925 POLICY_SCOPE_USER, 1959 POLICY_SCOPE_USER,
1926 new base::FundamentalValue(true), 1960 new base::FundamentalValue(true),
1927 NULL); 1961 NULL);
1928 UpdateProviderPolicy(policies); 1962 UpdateProviderPolicy(policies);
1929 GURL url = ui_test_utils::GetTestUrl( 1963 GURL url = ui_test_utils::GetTestUrl(
(...skipping 1245 matching lines...) Expand 10 before | Expand all | Expand 10 after
3175 EXPECT_TRUE(content::ExecuteScriptAndExtractBool( 3209 EXPECT_TRUE(content::ExecuteScriptAndExtractBool(
3176 browser2->tab_strip_model()->GetActiveWebContents(), 3210 browser2->tab_strip_model()->GetActiveWebContents(),
3177 "domAutomationController.send(window.showModalDialog !== undefined);", 3211 "domAutomationController.send(window.showModalDialog !== undefined);",
3178 &result)); 3212 &result));
3179 EXPECT_TRUE(result); 3213 EXPECT_TRUE(result);
3180 } 3214 }
3181 3215
3182 #endif // !defined(CHROME_OS) 3216 #endif // !defined(CHROME_OS)
3183 3217
3184 } // namespace policy 3218 } // namespace policy
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698