diff options
-rw-r--r-- | chrome/browser/extensions/extension_dom_ui.cc | 7 | ||||
-rw-r--r-- | chrome/browser/extensions/extension_override_apitest.cc | 24 |
2 files changed, 27 insertions, 4 deletions
diff --git a/chrome/browser/extensions/extension_dom_ui.cc b/chrome/browser/extensions/extension_dom_ui.cc index 5314078..0594f18 100644 --- a/chrome/browser/extensions/extension_dom_ui.cc +++ b/chrome/browser/extensions/extension_dom_ui.cc @@ -167,10 +167,8 @@ bool ExtensionDOMUI::HandleChromeURLOverride(GURL* url, Profile* profile) { if (!url->SchemeIs(chrome::kChromeUIScheme)) return false; - // Even when the extensions service is enabled by default, it's still - // disabled in incognito mode. - ExtensionsService* service = profile->GetExtensionsService(); - if (!service) + // We can't handle chrome-extension URLs in incognito mode. + if (profile->IsOffTheRecord()) return false; const DictionaryValue* overrides = @@ -180,6 +178,7 @@ bool ExtensionDOMUI::HandleChromeURLOverride(GURL* url, Profile* profile) { if (!overrides || !overrides->GetList(UTF8ToWide(page), &url_list)) return false; + ExtensionsService* service = profile->GetExtensionsService(); if (!service->is_ready()) { // TODO(erikkay) So far, it looks like extensions load before the new tab // page. I don't know if we have anything that enforces this, so add this diff --git a/chrome/browser/extensions/extension_override_apitest.cc b/chrome/browser/extensions/extension_override_apitest.cc index 2afe199..336f5a4 100644 --- a/chrome/browser/extensions/extension_override_apitest.cc +++ b/chrome/browser/extensions/extension_override_apitest.cc @@ -3,8 +3,11 @@ // found in the LICENSE file. #include "chrome/browser/browser.h" +#include "chrome/browser/browser_list.h" #include "chrome/browser/extensions/extension_apitest.h" #include "chrome/browser/extensions/extension_dom_ui.h" +#include "chrome/browser/tab_contents/tab_contents.h" +#include "chrome/common/url_constants.h" #include "chrome/test/ui_test_utils.h" class ExtensionOverrideTest : public ExtensionApiTest { @@ -42,6 +45,11 @@ IN_PROC_BROWSER_TEST_F(ExtensionOverrideTest, OverrideNewtab) { // Navigate to the new tab page. The overridden new tab page // will call chrome.test.notifyPass() . ui_test_utils::NavigateToURL(browser(), GURL("chrome://newtab/")); + TabContents* tab = browser()->GetSelectedTabContents(); + ASSERT_TRUE(tab->controller().GetActiveEntry()); + EXPECT_TRUE(tab->controller().GetActiveEntry()->url(). + SchemeIs(chrome::kExtensionScheme)); + ASSERT_TRUE(catcher.GetNextResult()); } @@ -49,6 +57,22 @@ IN_PROC_BROWSER_TEST_F(ExtensionOverrideTest, OverrideNewtab) { // Verify behavior, then unload the first and verify behavior, etc. } +IN_PROC_BROWSER_TEST_F(ExtensionOverrideTest, OverrideNewtabIncognito) { + ASSERT_TRUE(RunExtensionTest("override/newtab")) << message_; + + // Navigate an incognito tab to the new tab page. We should get the actual + // new tab page because we can't load chrome-extension URLs in incognito. + ui_test_utils::OpenURLOffTheRecord(browser()->profile(), + GURL("chrome://newtab/")); + Browser* otr_browser = BrowserList::FindBrowserWithType( + browser()->profile()->GetOffTheRecordProfile(), Browser::TYPE_NORMAL, + false); + TabContents* tab = otr_browser->GetSelectedTabContents(); + ASSERT_TRUE(tab->controller().GetActiveEntry()); + EXPECT_FALSE(tab->controller().GetActiveEntry()->url(). + SchemeIs(chrome::kExtensionScheme)); +} + IN_PROC_BROWSER_TEST_F(ExtensionOverrideTest, OverrideHistory) { ASSERT_TRUE(RunExtensionTest("override/history")) << message_; { |