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

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: Rebase and increment policy id yet again. 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
« no previous file with comments | « chrome/browser/policy/network_prediction_policy_handler.cc ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 1525 matching lines...) Expand 10 before | Expand all | Expand 10 after
1914 policies.Set(key::kDefaultJavaScriptSetting, 1919 policies.Set(key::kDefaultJavaScriptSetting,
1915 POLICY_LEVEL_MANDATORY, 1920 POLICY_LEVEL_MANDATORY,
1916 POLICY_SCOPE_USER, 1921 POLICY_SCOPE_USER,
1917 new base::FundamentalValue(CONTENT_SETTING_ALLOW), 1922 new base::FundamentalValue(CONTENT_SETTING_ALLOW),
1918 NULL); 1923 NULL);
1919 UpdateProviderPolicy(policies); 1924 UpdateProviderPolicy(policies);
1920 ui_test_utils::NavigateToURL(browser(), GURL(url::kAboutBlankURL)); 1925 ui_test_utils::NavigateToURL(browser(), GURL(url::kAboutBlankURL));
1921 EXPECT_TRUE(IsJavascriptEnabled(contents)); 1926 EXPECT_TRUE(IsJavascriptEnabled(contents));
1922 } 1927 }
1923 1928
1929 IN_PROC_BROWSER_TEST_F(PolicyTest, NetworkPrediction) {
1930 PrefService* prefs = browser()->profile()->GetPrefs();
1931
1932 // Enabled by default.
1933 EXPECT_TRUE(IsNetworkPredictionEnabled(prefs));
1934
1935 // Disable by old, deprecated policy.
1936 PolicyMap policies;
1937 policies.Set(key::kDnsPrefetchingEnabled,
1938 POLICY_LEVEL_MANDATORY,
1939 POLICY_SCOPE_USER,
1940 new base::FundamentalValue(false),
1941 NULL);
1942 UpdateProviderPolicy(policies);
1943
1944 EXPECT_FALSE(IsNetworkPredictionEnabled(prefs));
1945
1946 // Enabled by new policy, this should override old one.
1947 policies.Set(
1948 key::kNetworkPredictionOptions,
1949 POLICY_LEVEL_MANDATORY,
1950 POLICY_SCOPE_USER,
1951 new base::FundamentalValue(chrome_browser_net::NETWORK_PREDICTION_ALWAYS),
1952 NULL);
1953 UpdateProviderPolicy(policies);
1954
1955 EXPECT_TRUE(IsNetworkPredictionEnabled(prefs));
1956 }
1957
1924 IN_PROC_BROWSER_TEST_F(PolicyTest, SavingBrowserHistoryDisabled) { 1958 IN_PROC_BROWSER_TEST_F(PolicyTest, SavingBrowserHistoryDisabled) {
1925 // Verifies that browsing history is not saved. 1959 // Verifies that browsing history is not saved.
1926 PolicyMap policies; 1960 PolicyMap policies;
1927 policies.Set(key::kSavingBrowserHistoryDisabled, 1961 policies.Set(key::kSavingBrowserHistoryDisabled,
1928 POLICY_LEVEL_MANDATORY, 1962 POLICY_LEVEL_MANDATORY,
1929 POLICY_SCOPE_USER, 1963 POLICY_SCOPE_USER,
1930 new base::FundamentalValue(true), 1964 new base::FundamentalValue(true),
1931 NULL); 1965 NULL);
1932 UpdateProviderPolicy(policies); 1966 UpdateProviderPolicy(policies);
1933 GURL url = ui_test_utils::GetTestUrl( 1967 GURL url = ui_test_utils::GetTestUrl(
(...skipping 1245 matching lines...) Expand 10 before | Expand all | Expand 10 after
3179 EXPECT_TRUE(content::ExecuteScriptAndExtractBool( 3213 EXPECT_TRUE(content::ExecuteScriptAndExtractBool(
3180 browser2->tab_strip_model()->GetActiveWebContents(), 3214 browser2->tab_strip_model()->GetActiveWebContents(),
3181 "domAutomationController.send(window.showModalDialog !== undefined);", 3215 "domAutomationController.send(window.showModalDialog !== undefined);",
3182 &result)); 3216 &result));
3183 EXPECT_TRUE(result); 3217 EXPECT_TRUE(result);
3184 } 3218 }
3185 3219
3186 #endif // !defined(CHROME_OS) 3220 #endif // !defined(CHROME_OS)
3187 3221
3188 } // namespace policy 3222 } // namespace policy
OLDNEW
« no previous file with comments | « chrome/browser/policy/network_prediction_policy_handler.cc ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698