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/prefs/pref_service.h" | 40 #include "chrome/browser/prefs/pref_service.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 1223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1286 POLICY_SCOPE_USER, base::Value::CreateBooleanValue(true)); | 1287 POLICY_SCOPE_USER, base::Value::CreateBooleanValue(true)); |
1287 UpdateProviderPolicy(policies); | 1288 UpdateProviderPolicy(policies); |
1288 EXPECT_TRUE(chrome::ExecuteCommand(browser(), IDC_HOME)); | 1289 EXPECT_TRUE(chrome::ExecuteCommand(browser(), IDC_HOME)); |
1289 content::WaitForLoadStop(contents); | 1290 content::WaitForLoadStop(contents); |
1290 EXPECT_EQ(GURL(chrome::kChromeUINewTabURL), contents->GetURL()); | 1291 EXPECT_EQ(GURL(chrome::kChromeUINewTabURL), contents->GetURL()); |
1291 } | 1292 } |
1292 | 1293 |
1293 IN_PROC_BROWSER_TEST_F(PolicyTest, IncognitoEnabled) { | 1294 IN_PROC_BROWSER_TEST_F(PolicyTest, IncognitoEnabled) { |
1294 // Verifies that incognito windows can't be opened when disabled by policy. | 1295 // Verifies that incognito windows can't be opened when disabled by policy. |
1295 | 1296 |
| 1297 // Only test this on the native desktop. |
| 1298 const chrome::BrowserListImpl* native_browser_list = |
| 1299 chrome::BrowserListImpl::GetInstance(chrome::HOST_DESKTOP_TYPE_NATIVE); |
| 1300 |
1296 // Disable incognito via policy and verify that incognito windows can't be | 1301 // Disable incognito via policy and verify that incognito windows can't be |
1297 // opened. | 1302 // opened. |
1298 EXPECT_EQ(1u, BrowserList::size()); | 1303 EXPECT_EQ(1u, native_browser_list->size()); |
1299 EXPECT_FALSE(BrowserList::IsOffTheRecordSessionActive()); | 1304 EXPECT_FALSE(native_browser_list->IsIncognitoWindowOpen()); |
1300 PolicyMap policies; | 1305 PolicyMap policies; |
1301 policies.Set(key::kIncognitoEnabled, POLICY_LEVEL_MANDATORY, | 1306 policies.Set(key::kIncognitoEnabled, POLICY_LEVEL_MANDATORY, |
1302 POLICY_SCOPE_USER, base::Value::CreateBooleanValue(false)); | 1307 POLICY_SCOPE_USER, base::Value::CreateBooleanValue(false)); |
1303 UpdateProviderPolicy(policies); | 1308 UpdateProviderPolicy(policies); |
1304 EXPECT_FALSE(chrome::ExecuteCommand(browser(), IDC_NEW_INCOGNITO_WINDOW)); | 1309 EXPECT_FALSE(chrome::ExecuteCommand(browser(), IDC_NEW_INCOGNITO_WINDOW)); |
1305 EXPECT_EQ(1u, BrowserList::size()); | 1310 EXPECT_EQ(1u, native_browser_list->size()); |
1306 EXPECT_FALSE(BrowserList::IsOffTheRecordSessionActive()); | 1311 EXPECT_FALSE(native_browser_list->IsIncognitoWindowOpen()); |
1307 | 1312 |
1308 // Enable via policy and verify that incognito windows can be opened. | 1313 // Enable via policy and verify that incognito windows can be opened. |
1309 policies.Set(key::kIncognitoEnabled, POLICY_LEVEL_MANDATORY, | 1314 policies.Set(key::kIncognitoEnabled, POLICY_LEVEL_MANDATORY, |
1310 POLICY_SCOPE_USER, base::Value::CreateBooleanValue(true)); | 1315 POLICY_SCOPE_USER, base::Value::CreateBooleanValue(true)); |
1311 UpdateProviderPolicy(policies); | 1316 UpdateProviderPolicy(policies); |
1312 EXPECT_TRUE(chrome::ExecuteCommand(browser(), IDC_NEW_INCOGNITO_WINDOW)); | 1317 EXPECT_TRUE(chrome::ExecuteCommand(browser(), IDC_NEW_INCOGNITO_WINDOW)); |
1313 EXPECT_EQ(2u, BrowserList::size()); | 1318 EXPECT_EQ(2u, native_browser_list->size()); |
1314 EXPECT_TRUE(BrowserList::IsOffTheRecordSessionActive()); | 1319 EXPECT_TRUE(native_browser_list->IsIncognitoWindowOpen()); |
1315 } | 1320 } |
1316 | 1321 |
1317 IN_PROC_BROWSER_TEST_F(PolicyTest, Javascript) { | 1322 IN_PROC_BROWSER_TEST_F(PolicyTest, Javascript) { |
1318 // Verifies that Javascript can be disabled. | 1323 // Verifies that Javascript can be disabled. |
1319 content::WebContents* contents = | 1324 content::WebContents* contents = |
1320 browser()->tab_strip_model()->GetActiveWebContents(); | 1325 browser()->tab_strip_model()->GetActiveWebContents(); |
1321 EXPECT_TRUE(IsJavascriptEnabled(contents)); | 1326 EXPECT_TRUE(IsJavascriptEnabled(contents)); |
1322 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_DEV_TOOLS)); | 1327 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_DEV_TOOLS)); |
1323 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_DEV_TOOLS_CONSOLE)); | 1328 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_DEV_TOOLS_CONSOLE)); |
1324 | 1329 |
(...skipping 547 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1872 this)); | 1877 this)); |
1873 | 1878 |
1874 MessageLoop::current()->Run(); | 1879 MessageLoop::current()->Run(); |
1875 } | 1880 } |
1876 | 1881 |
1877 INSTANTIATE_TEST_CASE_P(MediaStreamDevicesControllerBrowserTestInstance, | 1882 INSTANTIATE_TEST_CASE_P(MediaStreamDevicesControllerBrowserTestInstance, |
1878 MediaStreamDevicesControllerBrowserTest, | 1883 MediaStreamDevicesControllerBrowserTest, |
1879 testing::Bool()); | 1884 testing::Bool()); |
1880 | 1885 |
1881 } // namespace policy | 1886 } // namespace policy |
OLD | NEW |