Skip to content

Commit

Permalink
[Activity log] Expose URL incognito state to private API
Browse files Browse the repository at this point in the history
Expose the incognito state of URLs to the activity log API.  Any
recorded URLs which were from an incognito window are prefixed with
"<incognito>", as is done in the database storage.

Re-enable the incognito subtests in the end-to-end activity log test.

BUG=272920

Review URL: https://chromiumcodereview.appspot.com/23618010

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@221415 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
mvrable@chromium.org committed Sep 5, 2013
1 parent ccdf38d commit 7a04650
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 30 deletions.
4 changes: 2 additions & 2 deletions chrome/browser/extensions/activity_log/activity_actions.cc
Original file line number Diff line number Diff line change
Expand Up @@ -168,10 +168,10 @@ scoped_ptr<ExtensionActivity> Action::ConvertToExtensionActivity() {
if (page_url().is_valid()) {
if (!page_title().empty())
result->page_title.reset(new std::string(page_title()));
result->page_url.reset(new std::string(page_url().spec()));
result->page_url.reset(new std::string(SerializePageUrl()));
}
if (arg_url().is_valid())
result->arg_url.reset(new std::string(arg_url().spec()));
result->arg_url.reset(new std::string(SerializeArgUrl()));
result->extra.reset(new std::string(Serialize(other())));

return result.Pass();
Expand Down
3 changes: 0 additions & 3 deletions chrome/browser/extensions/activity_log/activity_log.cc
Original file line number Diff line number Diff line change
Expand Up @@ -348,9 +348,6 @@ void ActivityLog::LogAction(scoped_refptr<Action> action) {
LookupTabIds(action, profile_);
}

// TODO(mvrable): Add any necessary processing of incognito URLs here, for
// crbug.com/253368

if (IsDatabaseEnabled() && policy_)
policy_->ProcessAction(action);
if (IsWatchdogAppActive())
Expand Down
17 changes: 7 additions & 10 deletions chrome/browser/extensions/activity_log/activity_log_browsertest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ class ActivityLogPrerenderTest : public ExtensionApiTest {
virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE {
ExtensionBrowserTest::SetUpCommandLine(command_line);
command_line->AppendSwitch(switches::kEnableExtensionActivityLogging);
command_line->AppendSwitch(switches::kEnableExtensionActivityLogTesting);
command_line->AppendSwitchASCII(switches::kPrerenderMode,
switches::kPrerenderModeSwitchValueEnabled);
}
Expand All @@ -45,15 +44,13 @@ class ActivityLogPrerenderTest : public ExtensionApiTest {
ASSERT_TRUE(i->size());
scoped_refptr<Action> last = i->front();

std::string args = base::StringPrintf(
"ID=%s CATEGORY=content_script API= ARGS=[\"/google_cs.js\"] "
"PAGE_URL=http://www.google.com.bo:%d/test.html "
"PAGE_TITLE=\"www.google.com.bo:%d/test.html\" "
"OTHER={\"prerender\":true}",
extension_id.c_str(), port, port);
// TODO: Replace PrintForDebug with field testing
// when this feature will be available
ASSERT_EQ(args, last->PrintForDebug());
ASSERT_EQ(Action::ACTION_CONTENT_SCRIPT, last->action_type());
ASSERT_EQ("[\"/google_cs.js\"]",
ActivityLogPolicy::Util::Serialize(last->args()));
ASSERT_EQ(base::StringPrintf("http://www.google.com.bo:%d/test.html", port),
last->page_url().spec());
ASSERT_EQ("{\"prerender\":true}",
ActivityLogPolicy::Util::Serialize(last->other()));
}
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ class ActivityLogApiTest : public ExtensionApiTest {
ExtensionApiTest::SetUpCommandLine(command_line);
saved_cmdline_ = *CommandLine::ForCurrentProcess();
command_line->AppendSwitch(switches::kEnableExtensionActivityLogging);
command_line->AppendSwitch(switches::kEnableExtensionActivityLogTesting);
}

private:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,17 @@ testCases.push({
}
});

function checkIncognito(url, incognitoExpected) {
if (url) {
incognitoExpected = Boolean(incognitoExpected);
var kIncognitoMarker = '<incognito>';
var isIncognito =
(url.substr(0, kIncognitoMarker.length) == kIncognitoMarker);
chrome.test.assertEq(incognitoExpected, isIncognito,
'Bad incognito state for URL ' + url);
}
}

// Listener to check the expected logging is done in the test cases.
var testCaseIndx = 0;
var callIndx = -1;
Expand All @@ -322,20 +333,8 @@ chrome.activityLogPrivate.onExtensionActivity.addListener(
chrome.test.assertEq(expectedCall, apiCall);

// Check that no real URLs are logged in incognito-mode tests.
// TODO(felt): This isn't working correctly. crbug.com/272920
/*if (activity['activityType'] == 'dom_access') {
var url = activity['pageUrl'];
if (url) {
if (testCases[testCaseIndx].is_incognito) {
chrome.test.assertEq('<incognito>', url,
'URL was not anonymized for apiCall:' +
apiCall);
} else {
chrome.test.assertTrue(url != '<incognito>',
'Non-incognito URL was anonymized');
}
}
}*/
checkIncognito(activity['pageUrl'], testCases[testCaseIndx].is_incognito);
checkIncognito(activity['argUrl'], testCases[testCaseIndx].is_incognito);

// If all the expected calls have been logged for this test case then
// mark as suceeded and move to the next. Otherwise look for the next
Expand Down

0 comments on commit 7a04650

Please sign in to comment.