| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 <set> | 5 #include <set> |
| 6 #include <vector> | 6 #include <vector> |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/json/json_string_value_serializer.h" | 8 #include "base/json/json_string_value_serializer.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 52 // Computes whether the activity log is enabled in this browser (controlled by | 52 // Computes whether the activity log is enabled in this browser (controlled by |
| 53 // command-line flags) and caches the value (which is assumed never to change). | 53 // command-line flags) and caches the value (which is assumed never to change). |
| 54 class LogIsEnabled { | 54 class LogIsEnabled { |
| 55 public: | 55 public: |
| 56 LogIsEnabled() { | 56 LogIsEnabled() { |
| 57 ComputeIsEnabled(); | 57 ComputeIsEnabled(); |
| 58 } | 58 } |
| 59 | 59 |
| 60 void ComputeIsEnabled() { | 60 void ComputeIsEnabled() { |
| 61 enabled_ = CommandLine::ForCurrentProcess()-> | 61 enabled_ = CommandLine::ForCurrentProcess()-> |
| 62 HasSwitch(switches::kEnableExtensionActivityLogging) || | 62 HasSwitch(switches::kEnableExtensionActivityLogging); |
| 63 CommandLine::ForCurrentProcess()-> | |
| 64 HasSwitch(switches::kEnableExtensionActivityUI); | |
| 65 } | 63 } |
| 66 | 64 |
| 67 static LogIsEnabled* GetInstance() { | 65 static LogIsEnabled* GetInstance() { |
| 68 return Singleton<LogIsEnabled>::get(); | 66 return Singleton<LogIsEnabled>::get(); |
| 69 } | 67 } |
| 70 | 68 |
| 71 bool enabled() { return enabled_; } | 69 bool enabled() { return enabled_; } |
| 72 | 70 |
| 73 private: | 71 private: |
| 74 bool enabled_; | 72 bool enabled_; |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 139 return chrome::GetBrowserContextRedirectedInIncognito(context); | 137 return chrome::GetBrowserContextRedirectedInIncognito(context); |
| 140 } | 138 } |
| 141 | 139 |
| 142 // ActivityLog | 140 // ActivityLog |
| 143 | 141 |
| 144 // Use GetInstance instead of directly creating an ActivityLog. | 142 // Use GetInstance instead of directly creating an ActivityLog. |
| 145 ActivityLog::ActivityLog(Profile* profile) : profile_(profile) { | 143 ActivityLog::ActivityLog(Profile* profile) : profile_(profile) { |
| 146 // enable-extension-activity-logging and enable-extension-activity-ui | 144 // enable-extension-activity-logging and enable-extension-activity-ui |
| 147 log_activity_to_stdout_ = CommandLine::ForCurrentProcess()->HasSwitch( | 145 log_activity_to_stdout_ = CommandLine::ForCurrentProcess()->HasSwitch( |
| 148 switches::kEnableExtensionActivityLogging); | 146 switches::kEnableExtensionActivityLogging); |
| 149 log_activity_to_ui_ = CommandLine::ForCurrentProcess()->HasSwitch( | |
| 150 switches::kEnableExtensionActivityUI); | |
| 151 | 147 |
| 152 // enable-extension-activity-log-testing | 148 // enable-extension-activity-log-testing |
| 153 // This controls whether arguments are collected. | 149 // This controls whether arguments are collected. |
| 154 testing_mode_ = CommandLine::ForCurrentProcess()->HasSwitch( | 150 testing_mode_ = CommandLine::ForCurrentProcess()->HasSwitch( |
| 155 switches::kEnableExtensionActivityLogTesting); | 151 switches::kEnableExtensionActivityLogTesting); |
| 156 if (!testing_mode_) { | 152 if (!testing_mode_) { |
| 157 for (int i = 0; i < APIAction::kSizeAlwaysLog; i++) { | 153 for (int i = 0; i < APIAction::kSizeAlwaysLog; i++) { |
| 158 arg_whitelist_api_.insert(std::string(APIAction::kAlwaysLog[i])); | 154 arg_whitelist_api_.insert(std::string(APIAction::kAlwaysLog[i])); |
| 159 } | 155 } |
| 160 } | 156 } |
| (...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 499 return "content_script"; | 495 return "content_script"; |
| 500 case ActivityLog::ACTIVITY_EVENT_DISPATCH: | 496 case ActivityLog::ACTIVITY_EVENT_DISPATCH: |
| 501 return "event_dispatch"; | 497 return "event_dispatch"; |
| 502 default: | 498 default: |
| 503 NOTREACHED(); | 499 NOTREACHED(); |
| 504 return ""; | 500 return ""; |
| 505 } | 501 } |
| 506 } | 502 } |
| 507 | 503 |
| 508 } // namespace extensions | 504 } // namespace extensions |
| OLD | NEW |