Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(196)

Side by Side Diff: chrome/browser/extensions/activity_log/stream_noargs_ui_policy.cc

Issue 21653002: Cleanups to the refactored extension activity log code (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Clarify comments Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "chrome/browser/extensions/activity_log/stream_noargs_ui_policy.h" 5 #include "chrome/browser/extensions/activity_log/stream_noargs_ui_policy.h"
6 6
7 #include "base/json/json_string_value_serializer.h" 7 #include "base/json/json_string_value_serializer.h"
8 #include "chrome/browser/extensions/activity_log/activity_action_constants.h" 8 #include "chrome/browser/extensions/activity_log/activity_action_constants.h"
9 9
10 namespace constants = activity_log_constants; 10 namespace constants = activity_log_constants;
11 11
12 namespace { 12 namespace {
13 13
14 // We should log the arguments to these API calls. 14 // We should log the arguments to these API calls. Be careful when
15 // constructing this whitelist to not keep arguments that might compromise
16 // privacy by logging too much data to the activity log.
17 //
18 // TODO(mvrable): The contents of this whitelist should be reviewed and
19 // expanded as needed.
15 const char* kAlwaysLog[] = {"extension.connect", "extension.sendMessage", 20 const char* kAlwaysLog[] = {"extension.connect", "extension.sendMessage",
16 "tabs.executeScript", "tabs.insertCSS"}; 21 "tabs.executeScript", "tabs.insertCSS"};
17 22
18 } // namespace 23 } // namespace
19 24
20 namespace extensions { 25 namespace extensions {
21 26
22 StreamWithoutArgsUIPolicy::StreamWithoutArgsUIPolicy(Profile* profile) 27 StreamWithoutArgsUIPolicy::StreamWithoutArgsUIPolicy(Profile* profile)
23 : FullStreamUIPolicy(profile) { 28 : FullStreamUIPolicy(profile) {
24 for (size_t i = 0; i < arraysize(kAlwaysLog); i++) { 29 for (size_t i = 0; i < arraysize(kAlwaysLog); i++) {
25 arg_whitelist_api_.insert(kAlwaysLog[i]); 30 arg_whitelist_api_.insert(kAlwaysLog[i]);
26 } 31 }
27 } 32 }
28 33
29 StreamWithoutArgsUIPolicy::~StreamWithoutArgsUIPolicy() {} 34 StreamWithoutArgsUIPolicy::~StreamWithoutArgsUIPolicy() {}
30 35
31 scoped_refptr<Action> StreamWithoutArgsUIPolicy::ProcessArguments( 36 scoped_refptr<Action> StreamWithoutArgsUIPolicy::ProcessArguments(
32 scoped_refptr<Action> action) const { 37 scoped_refptr<Action> action) const {
33 if (action->action_type() == Action::ACTION_DOM_ACCESS || 38 if (action->action_type() == Action::ACTION_DOM_ACCESS ||
34 action->action_type() == Action::ACTION_DOM_EVENT || 39 action->action_type() == Action::ACTION_DOM_EVENT ||
35 action->action_type() == Action::ACTION_DOM_XHR ||
36 arg_whitelist_api_.find(action->api_name()) != arg_whitelist_api_.end()) { 40 arg_whitelist_api_.find(action->api_name()) != arg_whitelist_api_.end()) {
37 // No stripping of arguments 41 // No stripping of arguments
38 } else { 42 } else {
39 // Do not modify the Action in-place, as there might be other users. 43 // Do not modify the Action in-place, as there might be other users.
40 action = action->Clone(); 44 action = action->Clone();
41 action->set_args(scoped_ptr<ListValue>()); 45 action->set_args(scoped_ptr<ListValue>());
42 46
43 // Strip details of the web request modifications (for privacy reasons). 47 // Strip details of the web request modifications (for privacy reasons).
44 if (action->action_type() == Action::ACTION_WEB_REQUEST) { 48 if (action->action_type() == Action::ACTION_WEB_REQUEST) {
45 DictionaryValue* details = NULL; 49 DictionaryValue* details = NULL;
46 if (action->mutable_other()->GetDictionary(constants::kActionWebRequest, 50 if (action->mutable_other()->GetDictionary(constants::kActionWebRequest,
47 &details)) { 51 &details)) {
48 DictionaryValue::Iterator details_iterator(*details); 52 DictionaryValue::Iterator details_iterator(*details);
49 while (!details_iterator.IsAtEnd()) { 53 while (!details_iterator.IsAtEnd()) {
50 details->SetBoolean(details_iterator.key(), true); 54 details->SetBoolean(details_iterator.key(), true);
51 details_iterator.Advance(); 55 details_iterator.Advance();
52 } 56 }
53 } 57 }
54 } 58 }
55 } 59 }
56 return action; 60 return action;
57 } 61 }
58 62
59 } // namespace extensions 63 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/browser/extensions/activity_log/activity_log.cc ('k') | chrome/browser/renderer_host/chrome_render_message_filter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698