| OLD | NEW | 
|---|
|  | (Empty) | 
| 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 |  | 
| 3 // found in the LICENSE file. |  | 
| 4 |  | 
| 5 #include "chrome/browser/extensions/activity_log/stream_noargs_ui_policy.h" |  | 
| 6 |  | 
| 7 #include "base/json/json_string_value_serializer.h" |  | 
| 8 #include "chrome/browser/extensions/activity_log/activity_action_constants.h" |  | 
| 9 |  | 
| 10 namespace constants = activity_log_constants; |  | 
| 11 |  | 
| 12 namespace { |  | 
| 13 |  | 
| 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. |  | 
| 20 const char* kAlwaysLog[] = {"extension.connect", "extension.sendMessage", |  | 
| 21                             "tabs.executeScript", "tabs.insertCSS"}; |  | 
| 22 |  | 
| 23 }  // namespace |  | 
| 24 |  | 
| 25 namespace extensions { |  | 
| 26 |  | 
| 27 StreamWithoutArgsUIPolicy::StreamWithoutArgsUIPolicy(Profile* profile) |  | 
| 28     : FullStreamUIPolicy(profile) { |  | 
| 29   for (size_t i = 0; i < arraysize(kAlwaysLog); i++) { |  | 
| 30     arg_whitelist_api_.insert(kAlwaysLog[i]); |  | 
| 31   } |  | 
| 32 } |  | 
| 33 |  | 
| 34 StreamWithoutArgsUIPolicy::~StreamWithoutArgsUIPolicy() {} |  | 
| 35 |  | 
| 36 scoped_refptr<Action> StreamWithoutArgsUIPolicy::ProcessArguments( |  | 
| 37     scoped_refptr<Action> action) const { |  | 
| 38   if (action->action_type() == Action::ACTION_DOM_ACCESS || |  | 
| 39       action->action_type() == Action::ACTION_DOM_EVENT || |  | 
| 40       arg_whitelist_api_.find(action->api_name()) != arg_whitelist_api_.end()) { |  | 
| 41     // No stripping of arguments |  | 
| 42   } else { |  | 
| 43     // Do not modify the Action in-place, as there might be other users. |  | 
| 44     action = action->Clone(); |  | 
| 45     action->set_args(scoped_ptr<ListValue>()); |  | 
| 46 |  | 
| 47     // Strip details of the web request modifications (for privacy reasons). |  | 
| 48     if (action->action_type() == Action::ACTION_WEB_REQUEST) { |  | 
| 49       DictionaryValue* details = NULL; |  | 
| 50       if (action->mutable_other()->GetDictionary(constants::kActionWebRequest, |  | 
| 51                                                  &details)) { |  | 
| 52         DictionaryValue::Iterator details_iterator(*details); |  | 
| 53         while (!details_iterator.IsAtEnd()) { |  | 
| 54           details->SetBoolean(details_iterator.key(), true); |  | 
| 55           details_iterator.Advance(); |  | 
| 56         } |  | 
| 57       } |  | 
| 58     } |  | 
| 59   } |  | 
| 60   return action; |  | 
| 61 } |  | 
| 62 |  | 
| 63 }  // namespace extensions |  | 
| OLD | NEW | 
|---|