OLD | NEW |
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 29 matching lines...) Expand all Loading... |
40 #include "chrome/browser/policy/policy_map.h" | 40 #include "chrome/browser/policy/policy_map.h" |
41 #include "chrome/browser/prefs/session_startup_pref.h" | 41 #include "chrome/browser/prefs/session_startup_pref.h" |
42 #include "chrome/browser/profiles/profile.h" | 42 #include "chrome/browser/profiles/profile.h" |
43 #include "chrome/browser/search_engines/template_url.h" | 43 #include "chrome/browser/search_engines/template_url.h" |
44 #include "chrome/browser/search_engines/template_url_service.h" | 44 #include "chrome/browser/search_engines/template_url_service.h" |
45 #include "chrome/browser/search_engines/template_url_service_factory.h" | 45 #include "chrome/browser/search_engines/template_url_service_factory.h" |
46 #include "chrome/browser/translate/translate_infobar_delegate.h" | 46 #include "chrome/browser/translate/translate_infobar_delegate.h" |
47 #include "chrome/browser/ui/bookmarks/bookmark_bar.h" | 47 #include "chrome/browser/ui/bookmarks/bookmark_bar.h" |
48 #include "chrome/browser/ui/browser.h" | 48 #include "chrome/browser/ui/browser.h" |
49 #include "chrome/browser/ui/browser_commands.h" | 49 #include "chrome/browser/ui/browser_commands.h" |
50 #include "chrome/browser/ui/browser_list.h" | 50 #include "chrome/browser/ui/browser_list_impl.h" |
51 #include "chrome/browser/ui/browser_tabstrip.h" | 51 #include "chrome/browser/ui/browser_tabstrip.h" |
52 #include "chrome/browser/ui/browser_window.h" | 52 #include "chrome/browser/ui/browser_window.h" |
| 53 #include "chrome/browser/ui/host_desktop.h" |
53 #include "chrome/browser/ui/omnibox/location_bar.h" | 54 #include "chrome/browser/ui/omnibox/location_bar.h" |
54 #include "chrome/browser/ui/omnibox/omnibox_edit_model.h" | 55 #include "chrome/browser/ui/omnibox/omnibox_edit_model.h" |
55 #include "chrome/browser/ui/omnibox/omnibox_view.h" | 56 #include "chrome/browser/ui/omnibox/omnibox_view.h" |
56 #include "chrome/browser/ui/search/search.h" | 57 #include "chrome/browser/ui/search/search.h" |
57 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 58 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
58 #include "chrome/common/chrome_notification_types.h" | 59 #include "chrome/common/chrome_notification_types.h" |
59 #include "chrome/common/chrome_paths.h" | 60 #include "chrome/common/chrome_paths.h" |
60 #include "chrome/common/chrome_switches.h" | 61 #include "chrome/common/chrome_switches.h" |
61 #include "chrome/common/content_settings.h" | 62 #include "chrome/common/content_settings.h" |
62 #include "chrome/common/extensions/extension.h" | 63 #include "chrome/common/extensions/extension.h" |
(...skipping 1226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1289 POLICY_SCOPE_USER, base::Value::CreateBooleanValue(true)); | 1290 POLICY_SCOPE_USER, base::Value::CreateBooleanValue(true)); |
1290 UpdateProviderPolicy(policies); | 1291 UpdateProviderPolicy(policies); |
1291 EXPECT_TRUE(chrome::ExecuteCommand(browser(), IDC_HOME)); | 1292 EXPECT_TRUE(chrome::ExecuteCommand(browser(), IDC_HOME)); |
1292 content::WaitForLoadStop(contents); | 1293 content::WaitForLoadStop(contents); |
1293 EXPECT_EQ(GURL(chrome::kChromeUINewTabURL), contents->GetURL()); | 1294 EXPECT_EQ(GURL(chrome::kChromeUINewTabURL), contents->GetURL()); |
1294 } | 1295 } |
1295 | 1296 |
1296 IN_PROC_BROWSER_TEST_F(PolicyTest, IncognitoEnabled) { | 1297 IN_PROC_BROWSER_TEST_F(PolicyTest, IncognitoEnabled) { |
1297 // Verifies that incognito windows can't be opened when disabled by policy. | 1298 // Verifies that incognito windows can't be opened when disabled by policy. |
1298 | 1299 |
| 1300 // Only test this on the native desktop. |
| 1301 const chrome::BrowserListImpl* native_browser_list = |
| 1302 chrome::BrowserListImpl::GetInstance(chrome::HOST_DESKTOP_TYPE_NATIVE); |
| 1303 |
1299 // Disable incognito via policy and verify that incognito windows can't be | 1304 // Disable incognito via policy and verify that incognito windows can't be |
1300 // opened. | 1305 // opened. |
1301 EXPECT_EQ(1u, BrowserList::size()); | 1306 EXPECT_EQ(1u, native_browser_list->size()); |
1302 EXPECT_FALSE(BrowserList::IsOffTheRecordSessionActive()); | 1307 EXPECT_FALSE(native_browser_list->IsIncognitoWindowOpen()); |
1303 PolicyMap policies; | 1308 PolicyMap policies; |
1304 policies.Set(key::kIncognitoEnabled, POLICY_LEVEL_MANDATORY, | 1309 policies.Set(key::kIncognitoEnabled, POLICY_LEVEL_MANDATORY, |
1305 POLICY_SCOPE_USER, base::Value::CreateBooleanValue(false)); | 1310 POLICY_SCOPE_USER, base::Value::CreateBooleanValue(false)); |
1306 UpdateProviderPolicy(policies); | 1311 UpdateProviderPolicy(policies); |
1307 EXPECT_FALSE(chrome::ExecuteCommand(browser(), IDC_NEW_INCOGNITO_WINDOW)); | 1312 EXPECT_FALSE(chrome::ExecuteCommand(browser(), IDC_NEW_INCOGNITO_WINDOW)); |
1308 EXPECT_EQ(1u, BrowserList::size()); | 1313 EXPECT_EQ(1u, native_browser_list->size()); |
1309 EXPECT_FALSE(BrowserList::IsOffTheRecordSessionActive()); | 1314 EXPECT_FALSE(native_browser_list->IsIncognitoWindowOpen()); |
1310 | 1315 |
1311 // Enable via policy and verify that incognito windows can be opened. | 1316 // Enable via policy and verify that incognito windows can be opened. |
1312 policies.Set(key::kIncognitoEnabled, POLICY_LEVEL_MANDATORY, | 1317 policies.Set(key::kIncognitoEnabled, POLICY_LEVEL_MANDATORY, |
1313 POLICY_SCOPE_USER, base::Value::CreateBooleanValue(true)); | 1318 POLICY_SCOPE_USER, base::Value::CreateBooleanValue(true)); |
1314 UpdateProviderPolicy(policies); | 1319 UpdateProviderPolicy(policies); |
1315 EXPECT_TRUE(chrome::ExecuteCommand(browser(), IDC_NEW_INCOGNITO_WINDOW)); | 1320 EXPECT_TRUE(chrome::ExecuteCommand(browser(), IDC_NEW_INCOGNITO_WINDOW)); |
1316 EXPECT_EQ(2u, BrowserList::size()); | 1321 EXPECT_EQ(2u, native_browser_list->size()); |
1317 EXPECT_TRUE(BrowserList::IsOffTheRecordSessionActive()); | 1322 EXPECT_TRUE(native_browser_list->IsIncognitoWindowOpen()); |
1318 } | 1323 } |
1319 | 1324 |
1320 IN_PROC_BROWSER_TEST_F(PolicyTest, Javascript) { | 1325 IN_PROC_BROWSER_TEST_F(PolicyTest, Javascript) { |
1321 // Verifies that Javascript can be disabled. | 1326 // Verifies that Javascript can be disabled. |
1322 content::WebContents* contents = | 1327 content::WebContents* contents = |
1323 browser()->tab_strip_model()->GetActiveWebContents(); | 1328 browser()->tab_strip_model()->GetActiveWebContents(); |
1324 EXPECT_TRUE(IsJavascriptEnabled(contents)); | 1329 EXPECT_TRUE(IsJavascriptEnabled(contents)); |
1325 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_DEV_TOOLS)); | 1330 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_DEV_TOOLS)); |
1326 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_DEV_TOOLS_CONSOLE)); | 1331 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_DEV_TOOLS_CONSOLE)); |
1327 | 1332 |
(...skipping 553 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1881 this)); | 1886 this)); |
1882 | 1887 |
1883 MessageLoop::current()->Run(); | 1888 MessageLoop::current()->Run(); |
1884 } | 1889 } |
1885 | 1890 |
1886 INSTANTIATE_TEST_CASE_P(MediaStreamDevicesControllerBrowserTestInstance, | 1891 INSTANTIATE_TEST_CASE_P(MediaStreamDevicesControllerBrowserTestInstance, |
1887 MediaStreamDevicesControllerBrowserTest, | 1892 MediaStreamDevicesControllerBrowserTest, |
1888 testing::Bool()); | 1893 testing::Bool()); |
1889 | 1894 |
1890 } // namespace policy | 1895 } // namespace policy |
OLD | NEW |