| 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 "chrome/browser/extensions/activity_log/activity_log.h" | 5 #include "chrome/browser/extensions/activity_log/activity_log.h" |
| 6 | 6 |
| 7 #include <set> | 7 #include <set> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| 11 #include "base/json/json_string_value_serializer.h" | 11 #include "base/json/json_string_value_serializer.h" |
| 12 #include "base/logging.h" | 12 #include "base/logging.h" |
| 13 #include "base/strings/string_util.h" | 13 #include "base/strings/string_util.h" |
| 14 #include "base/strings/utf_string_conversions.h" | 14 #include "base/strings/utf_string_conversions.h" |
| 15 #include "base/threading/thread_checker.h" | 15 #include "base/threading/thread_checker.h" |
| 16 #include "chrome/browser/extensions/activity_log/activity_action_constants.h" | 16 #include "chrome/browser/extensions/activity_log/activity_action_constants.h" |
| 17 #include "chrome/browser/extensions/activity_log/stream_noargs_ui_policy.h" | 17 #include "chrome/browser/extensions/activity_log/counting_policy.h" |
| 18 #include "chrome/browser/extensions/activity_log/fullstream_ui_policy.h" |
| 18 #include "chrome/browser/extensions/api/activity_log_private/activity_log_privat
e_api.h" | 19 #include "chrome/browser/extensions/api/activity_log_private/activity_log_privat
e_api.h" |
| 19 #include "chrome/browser/extensions/extension_service.h" | 20 #include "chrome/browser/extensions/extension_service.h" |
| 20 #include "chrome/browser/extensions/extension_system.h" | 21 #include "chrome/browser/extensions/extension_system.h" |
| 21 #include "chrome/browser/extensions/extension_system_factory.h" | 22 #include "chrome/browser/extensions/extension_system_factory.h" |
| 22 #include "chrome/browser/extensions/extension_tab_util.h" | 23 #include "chrome/browser/extensions/extension_tab_util.h" |
| 23 #include "chrome/browser/extensions/install_tracker_factory.h" | 24 #include "chrome/browser/extensions/install_tracker_factory.h" |
| 24 #include "chrome/browser/prerender/prerender_manager.h" | 25 #include "chrome/browser/prerender/prerender_manager.h" |
| 25 #include "chrome/browser/prerender/prerender_manager_factory.h" | 26 #include "chrome/browser/prerender/prerender_manager_factory.h" |
| 26 #include "chrome/browser/profiles/incognito_helpers.h" | 27 #include "chrome/browser/profiles/incognito_helpers.h" |
| 27 #include "chrome/browser/ui/browser.h" | 28 #include "chrome/browser/ui/browser.h" |
| (...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 233 // | 234 // |
| 234 // However, changing policies at runtime is still not recommended, and | 235 // However, changing policies at runtime is still not recommended, and |
| 235 // likely only should be done for unit tests. | 236 // likely only should be done for unit tests. |
| 236 if (policy_) | 237 if (policy_) |
| 237 policy_->Close(); | 238 policy_->Close(); |
| 238 | 239 |
| 239 switch (policy_type) { | 240 switch (policy_type) { |
| 240 case ActivityLogPolicy::POLICY_FULLSTREAM: | 241 case ActivityLogPolicy::POLICY_FULLSTREAM: |
| 241 policy_ = new FullStreamUIPolicy(profile_); | 242 policy_ = new FullStreamUIPolicy(profile_); |
| 242 break; | 243 break; |
| 243 case ActivityLogPolicy::POLICY_NOARGS: | 244 case ActivityLogPolicy::POLICY_COUNTS: |
| 244 policy_ = new StreamWithoutArgsUIPolicy(profile_); | 245 policy_ = new CountingPolicy(profile_); |
| 245 break; | 246 break; |
| 246 default: | 247 default: |
| 247 NOTREACHED(); | 248 NOTREACHED(); |
| 248 } | 249 } |
| 249 policy_type_ = policy_type; | 250 policy_type_ = policy_type; |
| 250 } | 251 } |
| 251 } | 252 } |
| 252 | 253 |
| 253 // Use GetInstance instead of directly creating an ActivityLog. | 254 // Use GetInstance instead of directly creating an ActivityLog. |
| 254 ActivityLog::ActivityLog(Profile* profile) | 255 ActivityLog::ActivityLog(Profile* profile) |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 295 tracker_->AddObserver(this); | 296 tracker_->AddObserver(this); |
| 296 ChooseDefaultPolicy(); | 297 ChooseDefaultPolicy(); |
| 297 initialized_ = true; | 298 initialized_ = true; |
| 298 } | 299 } |
| 299 | 300 |
| 300 void ActivityLog::ChooseDefaultPolicy() { | 301 void ActivityLog::ChooseDefaultPolicy() { |
| 301 if (policy_chosen_ || !enabled_) return; | 302 if (policy_chosen_ || !enabled_) return; |
| 302 if (testing_mode_) | 303 if (testing_mode_) |
| 303 SetDefaultPolicy(ActivityLogPolicy::POLICY_FULLSTREAM); | 304 SetDefaultPolicy(ActivityLogPolicy::POLICY_FULLSTREAM); |
| 304 else | 305 else |
| 305 SetDefaultPolicy(ActivityLogPolicy::POLICY_NOARGS); | 306 SetDefaultPolicy(ActivityLogPolicy::POLICY_COUNTS); |
| 306 } | 307 } |
| 307 | 308 |
| 308 void ActivityLog::Shutdown() { | 309 void ActivityLog::Shutdown() { |
| 309 if (tracker_) tracker_->RemoveObserver(this); | 310 if (tracker_) tracker_->RemoveObserver(this); |
| 310 } | 311 } |
| 311 | 312 |
| 312 ActivityLog::~ActivityLog() { | 313 ActivityLog::~ActivityLog() { |
| 313 if (policy_) | 314 if (policy_) |
| 314 policy_->Close(); | 315 policy_->Close(); |
| 315 } | 316 } |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 420 it2 != it->second.end(); | 421 it2 != it->second.end(); |
| 421 ++it2) { | 422 ++it2) { |
| 422 action->mutable_args()->AppendString(*it2); | 423 action->mutable_args()->AppendString(*it2); |
| 423 } | 424 } |
| 424 LogAction(action); | 425 LogAction(action); |
| 425 } | 426 } |
| 426 } | 427 } |
| 427 } | 428 } |
| 428 | 429 |
| 429 } // namespace extensions | 430 } // namespace extensions |
| OLD | NEW |