diff options
author | mpcomplete@chromium.org <mpcomplete@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-05-04 22:33:11 +0000 |
---|---|---|
committer | mpcomplete@chromium.org <mpcomplete@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-05-04 22:33:11 +0000 |
commit | 0608b20fd9d9dca88679dd305b3e36b2f20726a2 (patch) | |
tree | 55998856dd6ba245d224ff8741e9c81ed28f8f9a | |
parent | 34722a6023f5ef0816aaaa2de40102ebdab65129 (diff) | |
download | chromium_src-0608b20fd9d9dca88679dd305b3e36b2f20726a2.zip chromium_src-0608b20fd9d9dca88679dd305b3e36b2f20726a2.tar.gz chromium_src-0608b20fd9d9dca88679dd305b3e36b2f20726a2.tar.bz2 |
Merge 46390 - Prevent chrome extension URL overrides from applying in incognito mode.
BUG=39372
Review URL: http://codereview.chromium.org/1940002
TBR=mpcomplete@chromium.org
Review URL: http://codereview.chromium.org/1930003
git-svn-id: svn://svn.chromium.org/chrome/branches/375/src@46399 0039d316-1c4b-4281-b951-d872f2087c98
-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_; { |