Skip to content

Commit

Permalink
Do not create an incognito profile if none exists in cookies.getAllCo…
Browse files Browse the repository at this point in the history
…okieStores

BUG=66817
TEST=ExtensionApiTest.DontCreateIncognitoProfile

Review URL: http://codereview.chromium.org/5742011

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@69240 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
jochen@chromium.org committed Dec 15, 2010
1 parent 49c4fe7 commit 6df23c4
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 5 deletions.
2 changes: 1 addition & 1 deletion chrome/browser/extensions/extension_cookies_api.cc
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,7 @@ bool GetAllCookieStoresFunction::RunImpl() {
scoped_ptr<ListValue> original_tab_ids(new ListValue());
Profile* incognito_profile = NULL;
scoped_ptr<ListValue> incognito_tab_ids;
if (include_incognito()) {
if (include_incognito() && profile()->HasOffTheRecordProfile()) {
incognito_profile = profile()->GetOffTheRecordProfile();
if (incognito_profile)
incognito_tab_ids.reset(new ListValue());
Expand Down
3 changes: 2 additions & 1 deletion chrome/browser/extensions/extension_cookies_helpers.cc
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ Profile* ChooseProfileFromStoreId(const std::string& store_id,
bool include_incognito) {
DCHECK(profile);
bool allow_original = !profile->IsOffTheRecord();
bool allow_incognito = profile->IsOffTheRecord() || include_incognito;
bool allow_incognito = profile->IsOffTheRecord() ||
(include_incognito && profile->HasOffTheRecordProfile());
if (store_id == kOriginalProfileStoreId && allow_original)
return profile->GetOriginalProfile();
if (store_id == kOffTheRecordProfileStoreId && allow_incognito)
Expand Down
4 changes: 4 additions & 0 deletions chrome/browser/extensions/extension_cookies_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ class OtrTestingProfile : public TestingProfile {
return linked_profile_;
}

virtual bool HasOffTheRecordProfile() {
return (!IsOffTheRecord() && linked_profile_);
}

static void LinkProfiles(OtrTestingProfile* profile1,
OtrTestingProfile* profile2) {
profile1->set_linked_profile(profile2);
Expand Down
4 changes: 2 additions & 2 deletions chrome/browser/extensions/extension_incognito_apitest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,8 @@ IN_PROC_BROWSER_TEST_F(ExtensionApiTest, IncognitoYesScript) {
// accidentially create and incognito profile.
IN_PROC_BROWSER_TEST_F(ExtensionApiTest, DontCreateIncognitoProfile) {
ASSERT_FALSE(browser()->profile()->HasOffTheRecordProfile());
ASSERT_TRUE(
RunExtensionTestIncognito("incognito/enumerate_tabs")) << message_;
ASSERT_TRUE(RunExtensionTestIncognito(
"incognito/dont_create_profile")) << message_;
ASSERT_FALSE(browser()->profile()->HasOffTheRecordProfile());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@
chrome.windows.getAll({"populate": true}, function (windows) {
chrome.test.succeed();
});
},
function getAllCookieStores() {
chrome.cookies.getAllCookieStores(function (stores) {
chrome.test.succeed();
});
}
]);
</script>
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
"version": "0.1",
"description": "test that an incognito extension can't accidentially create an OTR profile",
"background_page": "background.html",
"permissions": ["tabs"]
"permissions": ["tabs", "cookies"]
}

0 comments on commit 6df23c4

Please sign in to comment.