| 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 <string> | 5 #include <string> |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
| 9 #include "base/file_path.h" | 9 #include "base/file_path.h" |
| 10 #if defined(OS_MACOSX) | 10 #if defined(OS_MACOSX) |
| (...skipping 1290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1301 IncognitoModePrefs::DISABLED); | 1301 IncognitoModePrefs::DISABLED); |
| 1302 // Make sure Manage Extensions command is disabled. | 1302 // Make sure Manage Extensions command is disabled. |
| 1303 EXPECT_FALSE(command_updater->IsCommandEnabled(IDC_MANAGE_EXTENSIONS)); | 1303 EXPECT_FALSE(command_updater->IsCommandEnabled(IDC_MANAGE_EXTENSIONS)); |
| 1304 EXPECT_TRUE(command_updater->IsCommandEnabled(IDC_NEW_WINDOW)); | 1304 EXPECT_TRUE(command_updater->IsCommandEnabled(IDC_NEW_WINDOW)); |
| 1305 EXPECT_TRUE(command_updater->IsCommandEnabled(IDC_SHOW_BOOKMARK_MANAGER)); | 1305 EXPECT_TRUE(command_updater->IsCommandEnabled(IDC_SHOW_BOOKMARK_MANAGER)); |
| 1306 EXPECT_TRUE(command_updater->IsCommandEnabled(IDC_IMPORT_SETTINGS)); | 1306 EXPECT_TRUE(command_updater->IsCommandEnabled(IDC_IMPORT_SETTINGS)); |
| 1307 EXPECT_TRUE(command_updater->IsCommandEnabled(IDC_OPTIONS)); | 1307 EXPECT_TRUE(command_updater->IsCommandEnabled(IDC_OPTIONS)); |
| 1308 | 1308 |
| 1309 // Create a popup (non-main-UI-type) browser. Settings command as well | 1309 // Create a popup (non-main-UI-type) browser. Settings command as well |
| 1310 // as Extensions should be disabled. | 1310 // as Extensions should be disabled. |
| 1311 Browser* popup_browser = browser()->CreateForType(Browser::TYPE_POPUP, | 1311 Browser* popup_browser = browser()->CreateWithParams( |
| 1312 browser()->profile()); | 1312 Browser::CreateParams(Browser::TYPE_POPUP, browser()->profile())); |
| 1313 CommandUpdater* popup_command_updater = popup_browser->command_updater(); | 1313 CommandUpdater* popup_command_updater = popup_browser->command_updater(); |
| 1314 EXPECT_FALSE(popup_command_updater->IsCommandEnabled(IDC_MANAGE_EXTENSIONS)); | 1314 EXPECT_FALSE(popup_command_updater->IsCommandEnabled(IDC_MANAGE_EXTENSIONS)); |
| 1315 EXPECT_FALSE(popup_command_updater->IsCommandEnabled(IDC_OPTIONS)); | 1315 EXPECT_FALSE(popup_command_updater->IsCommandEnabled(IDC_OPTIONS)); |
| 1316 EXPECT_TRUE(popup_command_updater->IsCommandEnabled( | 1316 EXPECT_TRUE(popup_command_updater->IsCommandEnabled( |
| 1317 IDC_SHOW_BOOKMARK_MANAGER)); | 1317 IDC_SHOW_BOOKMARK_MANAGER)); |
| 1318 EXPECT_FALSE(popup_command_updater->IsCommandEnabled(IDC_IMPORT_SETTINGS)); | 1318 EXPECT_FALSE(popup_command_updater->IsCommandEnabled(IDC_IMPORT_SETTINGS)); |
| 1319 } | 1319 } |
| 1320 | 1320 |
| 1321 // Makes sure Extensions and Settings commands are disabled in certain | 1321 // Makes sure Extensions and Settings commands are disabled in certain |
| 1322 // circumstances even though normally they should stay enabled. | 1322 // circumstances even though normally they should stay enabled. |
| 1323 IN_PROC_BROWSER_TEST_F(BrowserTest, | 1323 IN_PROC_BROWSER_TEST_F(BrowserTest, |
| 1324 DisableOptionsAndImportMenuItemsConsistently) { | 1324 DisableOptionsAndImportMenuItemsConsistently) { |
| 1325 // Create a popup browser. | 1325 // Create a popup browser. |
| 1326 Browser* popup_browser = browser()->CreateForType(Browser::TYPE_POPUP, | 1326 Browser* popup_browser = browser()->CreateWithParams( |
| 1327 browser()->profile()); | 1327 Browser::CreateParams(Browser::TYPE_POPUP, browser()->profile())); |
| 1328 CommandUpdater* command_updater = popup_browser->command_updater(); | 1328 CommandUpdater* command_updater = popup_browser->command_updater(); |
| 1329 // OPTIONS and IMPORT_SETTINGS are disabled for a non-normal UI. | 1329 // OPTIONS and IMPORT_SETTINGS are disabled for a non-normal UI. |
| 1330 EXPECT_FALSE(command_updater->IsCommandEnabled(IDC_OPTIONS)); | 1330 EXPECT_FALSE(command_updater->IsCommandEnabled(IDC_OPTIONS)); |
| 1331 EXPECT_FALSE(command_updater->IsCommandEnabled(IDC_IMPORT_SETTINGS)); | 1331 EXPECT_FALSE(command_updater->IsCommandEnabled(IDC_IMPORT_SETTINGS)); |
| 1332 | 1332 |
| 1333 // Set Incognito to FORCED. | 1333 // Set Incognito to FORCED. |
| 1334 IncognitoModePrefs::SetAvailability(popup_browser->profile()->GetPrefs(), | 1334 IncognitoModePrefs::SetAvailability(popup_browser->profile()->GetPrefs(), |
| 1335 IncognitoModePrefs::FORCED); | 1335 IncognitoModePrefs::FORCED); |
| 1336 // OPTIONS and IMPORT_SETTINGS are disabled when Incognito is forced. | 1336 // OPTIONS and IMPORT_SETTINGS are disabled when Incognito is forced. |
| 1337 EXPECT_FALSE(command_updater->IsCommandEnabled(IDC_OPTIONS)); | 1337 EXPECT_FALSE(command_updater->IsCommandEnabled(IDC_OPTIONS)); |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1481 net::ScopedDefaultHostResolverProc scoped_host_resolver_proc_; | 1481 net::ScopedDefaultHostResolverProc scoped_host_resolver_proc_; |
| 1482 }; | 1482 }; |
| 1483 | 1483 |
| 1484 IN_PROC_BROWSER_TEST_F(BrowserTest2, NoTabsInPopups) { | 1484 IN_PROC_BROWSER_TEST_F(BrowserTest2, NoTabsInPopups) { |
| 1485 Browser::RegisterAppPrefs(L"Test"); | 1485 Browser::RegisterAppPrefs(L"Test"); |
| 1486 | 1486 |
| 1487 // We start with a normal browser with one tab. | 1487 // We start with a normal browser with one tab. |
| 1488 EXPECT_EQ(1, browser()->tab_count()); | 1488 EXPECT_EQ(1, browser()->tab_count()); |
| 1489 | 1489 |
| 1490 // Open a popup browser with a single blank foreground tab. | 1490 // Open a popup browser with a single blank foreground tab. |
| 1491 Browser* popup_browser = browser()->CreateForType(Browser::TYPE_POPUP, | 1491 Browser* popup_browser = browser()->CreateWithParams( |
| 1492 browser()->profile()); | 1492 Browser::CreateParams(Browser::TYPE_POPUP, browser()->profile())); |
| 1493 popup_browser->AddBlankTab(true); | 1493 popup_browser->AddBlankTab(true); |
| 1494 EXPECT_EQ(1, popup_browser->tab_count()); | 1494 EXPECT_EQ(1, popup_browser->tab_count()); |
| 1495 | 1495 |
| 1496 // Now try opening another tab in the popup browser. | 1496 // Now try opening another tab in the popup browser. |
| 1497 AddTabWithURLParams params1(url, content::PAGE_TRANSITION_TYPED); | 1497 AddTabWithURLParams params1(url, content::PAGE_TRANSITION_TYPED); |
| 1498 popup_browser->AddTabWithURL(¶ms1); | 1498 popup_browser->AddTabWithURL(¶ms1); |
| 1499 EXPECT_EQ(popup_browser, params1.target); | 1499 EXPECT_EQ(popup_browser, params1.target); |
| 1500 | 1500 |
| 1501 // The popup should still only have one tab. | 1501 // The popup should still only have one tab. |
| 1502 EXPECT_EQ(1, popup_browser->tab_count()); | 1502 EXPECT_EQ(1, popup_browser->tab_count()); |
| 1503 | 1503 |
| 1504 // The normal browser should now have two. | 1504 // The normal browser should now have two. |
| 1505 EXPECT_EQ(2, browser()->tab_count()); | 1505 EXPECT_EQ(2, browser()->tab_count()); |
| 1506 | 1506 |
| 1507 // Open an app frame browser with a single blank foreground tab. | 1507 // Open an app frame browser with a single blank foreground tab. |
| 1508 Browser* app_browser = | 1508 Browser* app_browser = browser()->CreateWithParams( |
| 1509 browser()->CreateForApp(L"Test", browser()->profile(), false); | 1509 Browser::CreateParams::CreateForApp( |
| 1510 L"Test", browser()->profile(), false)); |
| 1510 app_browser->AddBlankTab(true); | 1511 app_browser->AddBlankTab(true); |
| 1511 EXPECT_EQ(1, app_browser->tab_count()); | 1512 EXPECT_EQ(1, app_browser->tab_count()); |
| 1512 | 1513 |
| 1513 // Now try opening another tab in the app browser. | 1514 // Now try opening another tab in the app browser. |
| 1514 AddTabWithURLParams params2(GURL(chrome::kAboutBlankURL), | 1515 AddTabWithURLParams params2(GURL(chrome::kAboutBlankURL), |
| 1515 content::PAGE_TRANSITION_TYPED); | 1516 content::PAGE_TRANSITION_TYPED); |
| 1516 app_browser->AddTabWithURL(¶ms2); | 1517 app_browser->AddTabWithURL(¶ms2); |
| 1517 EXPECT_EQ(app_browser, params2.target); | 1518 EXPECT_EQ(app_browser, params2.target); |
| 1518 | 1519 |
| 1519 // The popup should still only have one tab. | 1520 // The popup should still only have one tab. |
| 1520 EXPECT_EQ(1, app_browser->tab_count()); | 1521 EXPECT_EQ(1, app_browser->tab_count()); |
| 1521 | 1522 |
| 1522 // The normal browser should now have three. | 1523 // The normal browser should now have three. |
| 1523 EXPECT_EQ(3, browser()->tab_count()); | 1524 EXPECT_EQ(3, browser()->tab_count()); |
| 1524 | 1525 |
| 1525 // Open an app frame popup browser with a single blank foreground tab. | 1526 // Open an app frame popup browser with a single blank foreground tab. |
| 1526 Browser* app_popup_browser = | 1527 Browser* app_popup_browser = browser()->CreateWithParams( |
| 1527 browser()->CreateForApp(L"Test", browser()->profile(), false); | 1528 Browser::CreateParams::CreateForApp( |
| 1529 L"Test", browser()->profile(), false)); |
| 1528 app_popup_browser->AddBlankTab(true); | 1530 app_popup_browser->AddBlankTab(true); |
| 1529 EXPECT_EQ(1, app_popup_browser->tab_count()); | 1531 EXPECT_EQ(1, app_popup_browser->tab_count()); |
| 1530 | 1532 |
| 1531 // Now try opening another tab in the app popup browser. | 1533 // Now try opening another tab in the app popup browser. |
| 1532 AddTabWithURLParams params3(GURL(chrome::kAboutBlankURL), | 1534 AddTabWithURLParams params3(GURL(chrome::kAboutBlankURL), |
| 1533 content::PAGE_TRANSITION_TYPED); | 1535 content::PAGE_TRANSITION_TYPED); |
| 1534 app_popup_browser->AddTabWithURL(¶ms3); | 1536 app_popup_browser->AddTabWithURL(¶ms3); |
| 1535 EXPECT_EQ(app_popup_browser, params3.target); | 1537 EXPECT_EQ(app_popup_browser, params3.target); |
| 1536 | 1538 |
| 1537 // The popup should still only have one tab. | 1539 // The popup should still only have one tab. |
| 1538 EXPECT_EQ(1, app_popup_browser->tab_count()); | 1540 EXPECT_EQ(1, app_popup_browser->tab_count()); |
| 1539 | 1541 |
| 1540 // The normal browser should now have four. | 1542 // The normal browser should now have four. |
| 1541 EXPECT_EQ(4, browser()->tab_count()); | 1543 EXPECT_EQ(4, browser()->tab_count()); |
| 1542 | 1544 |
| 1543 // Close the additional browsers. | 1545 // Close the additional browsers. |
| 1544 popup_browser->CloseAllTabs(); | 1546 popup_browser->CloseAllTabs(); |
| 1545 app_browser->CloseAllTabs(); | 1547 app_browser->CloseAllTabs(); |
| 1546 app_popup_browser->CloseAllTabs(); | 1548 app_popup_browser->CloseAllTabs(); |
| 1547 } | 1549 } |
| 1548 #endif | 1550 #endif |
| OLD | NEW |