| 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 <limits.h> | 5 #include <limits.h> |
| 6 #include <stddef.h> | 6 #include <stddef.h> |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| (...skipping 413 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 424 | 424 |
| 425 IN_PROC_BROWSER_TEST_F(ExtensionTabsTest, | 425 IN_PROC_BROWSER_TEST_F(ExtensionTabsTest, |
| 426 DefaultToIncognitoWhenItIsForced) { | 426 DefaultToIncognitoWhenItIsForced) { |
| 427 static const char kArgsWithoutExplicitIncognitoParam[] = | 427 static const char kArgsWithoutExplicitIncognitoParam[] = |
| 428 "[{\"url\": \"about:blank\"}]"; | 428 "[{\"url\": \"about:blank\"}]"; |
| 429 // Force Incognito mode. | 429 // Force Incognito mode. |
| 430 IncognitoModePrefs::SetAvailability(browser()->profile()->GetPrefs(), | 430 IncognitoModePrefs::SetAvailability(browser()->profile()->GetPrefs(), |
| 431 IncognitoModePrefs::FORCED); | 431 IncognitoModePrefs::FORCED); |
| 432 // Run without an explicit "incognito" param. | 432 // Run without an explicit "incognito" param. |
| 433 scoped_refptr<WindowsCreateFunction> function(new WindowsCreateFunction()); | 433 scoped_refptr<WindowsCreateFunction> function(new WindowsCreateFunction()); |
| 434 function->SetRenderFrameHost( |
| 435 browser()->tab_strip_model()->GetActiveWebContents()->GetMainFrame()); |
| 434 scoped_refptr<Extension> extension(test_util::CreateEmptyExtension()); | 436 scoped_refptr<Extension> extension(test_util::CreateEmptyExtension()); |
| 435 function->set_extension(extension.get()); | 437 function->set_extension(extension.get()); |
| 436 scoped_ptr<base::DictionaryValue> result(utils::ToDictionary( | 438 scoped_ptr<base::DictionaryValue> result(utils::ToDictionary( |
| 437 utils::RunFunctionAndReturnSingleResult( | 439 utils::RunFunctionAndReturnSingleResult( |
| 438 function.get(), | 440 function.get(), |
| 439 kArgsWithoutExplicitIncognitoParam, | 441 kArgsWithoutExplicitIncognitoParam, |
| 440 browser(), | 442 browser(), |
| 441 utils::INCLUDE_INCOGNITO))); | 443 utils::INCLUDE_INCOGNITO))); |
| 442 | 444 |
| 443 // Make sure it is a new(different) window. | 445 // Make sure it is a new(different) window. |
| 444 EXPECT_NE(ExtensionTabUtil::GetWindowId(browser()), | 446 EXPECT_NE(ExtensionTabUtil::GetWindowId(browser()), |
| 445 GetWindowId(result.get())); | 447 GetWindowId(result.get())); |
| 446 // ... and it is incognito. | 448 // ... and it is incognito. |
| 447 EXPECT_TRUE(api_test_utils::GetBoolean(result.get(), "incognito")); | 449 EXPECT_TRUE(api_test_utils::GetBoolean(result.get(), "incognito")); |
| 448 | 450 |
| 449 // Now try creating a window from incognito window. | 451 // Now try creating a window from incognito window. |
| 450 Browser* incognito_browser = CreateIncognitoBrowser(); | 452 Browser* incognito_browser = CreateIncognitoBrowser(); |
| 451 // Run without an explicit "incognito" param. | 453 // Run without an explicit "incognito" param. |
| 452 function = new WindowsCreateFunction(); | 454 function = new WindowsCreateFunction(); |
| 455 function->SetRenderFrameHost( |
| 456 browser()->tab_strip_model()->GetActiveWebContents()->GetMainFrame()); |
| 453 function->set_extension(extension.get()); | 457 function->set_extension(extension.get()); |
| 454 result.reset(utils::ToDictionary( | 458 result.reset(utils::ToDictionary( |
| 455 utils::RunFunctionAndReturnSingleResult( | 459 utils::RunFunctionAndReturnSingleResult( |
| 456 function.get(), | 460 function.get(), |
| 457 kArgsWithoutExplicitIncognitoParam, | 461 kArgsWithoutExplicitIncognitoParam, |
| 458 incognito_browser, | 462 incognito_browser, |
| 459 utils::INCLUDE_INCOGNITO))); | 463 utils::INCLUDE_INCOGNITO))); |
| 460 // Make sure it is a new(different) window. | 464 // Make sure it is a new(different) window. |
| 461 EXPECT_NE(ExtensionTabUtil::GetWindowId(incognito_browser), | 465 EXPECT_NE(ExtensionTabUtil::GetWindowId(incognito_browser), |
| 462 GetWindowId(result.get())); | 466 GetWindowId(result.get())); |
| (...skipping 1283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1746 EXPECT_TRUE( | 1750 EXPECT_TRUE( |
| 1747 base::MatchPattern(error, manifest_errors::kCannotAccessChromeUrl)); | 1751 base::MatchPattern(error, manifest_errors::kCannotAccessChromeUrl)); |
| 1748 | 1752 |
| 1749 // chrome.tabs.setZoomSettings(). | 1753 // chrome.tabs.setZoomSettings(). |
| 1750 error = RunSetZoomSettingsExpectError(tab_id, "manual", "per-tab"); | 1754 error = RunSetZoomSettingsExpectError(tab_id, "manual", "per-tab"); |
| 1751 EXPECT_TRUE( | 1755 EXPECT_TRUE( |
| 1752 base::MatchPattern(error, manifest_errors::kCannotAccessChromeUrl)); | 1756 base::MatchPattern(error, manifest_errors::kCannotAccessChromeUrl)); |
| 1753 } | 1757 } |
| 1754 | 1758 |
| 1755 } // namespace extensions | 1759 } // namespace extensions |
| OLD | NEW |