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" |
(...skipping 376 matching lines...) Loading... |
387 | 387 |
388 db_enabled_ = has_threads_ | 388 db_enabled_ = has_threads_ |
389 && (CommandLine::ForCurrentProcess()-> | 389 && (CommandLine::ForCurrentProcess()-> |
390 HasSwitch(switches::kEnableExtensionActivityLogging) | 390 HasSwitch(switches::kEnableExtensionActivityLogging) |
391 || watchdog_apps_active_); | 391 || watchdog_apps_active_); |
392 | 392 |
393 ExtensionSystem::Get(profile_)->ready().Post( | 393 ExtensionSystem::Get(profile_)->ready().Post( |
394 FROM_HERE, | 394 FROM_HERE, |
395 base::Bind(&ActivityLog::StartObserving, base::Unretained(this))); | 395 base::Bind(&ActivityLog::StartObserving, base::Unretained(this))); |
396 | 396 |
397 // None of this should run on Android since the AL is behind ENABLE_EXTENSION | 397 // None of this should run on Android since the AL is behind ENABLE_EXTENSIONS |
398 // checks. However, UmaPolicy can't even compile on Android because it uses | 398 // checks. However, UmaPolicy can't even compile on Android because it uses |
399 // BrowserList and related classes that aren't compiled for Android. | 399 // BrowserList and related classes that aren't compiled for Android. |
400 #if !defined(OS_ANDROID) | 400 #if !defined(OS_ANDROID) |
401 if (!profile_->IsOffTheRecord()) | 401 if (!profile_->IsOffTheRecord()) |
402 uma_policy_ = new UmaPolicy(profile_); | 402 uma_policy_ = new UmaPolicy(profile_); |
403 #endif | 403 #endif |
404 | 404 |
405 ChooseDatabasePolicy(); | 405 ChooseDatabasePolicy(); |
406 } | 406 } |
407 | 407 |
(...skipping 151 matching lines...) Loading... |
559 if (uma_policy_) | 559 if (uma_policy_) |
560 uma_policy_->ProcessAction(action); | 560 uma_policy_->ProcessAction(action); |
561 if (IsDatabaseEnabled() && database_policy_) | 561 if (IsDatabaseEnabled() && database_policy_) |
562 database_policy_->ProcessAction(action); | 562 database_policy_->ProcessAction(action); |
563 if (IsWatchdogAppActive()) | 563 if (IsWatchdogAppActive()) |
564 observers_->Notify(&Observer::OnExtensionActivity, action); | 564 observers_->Notify(&Observer::OnExtensionActivity, action); |
565 if (testing_mode_) | 565 if (testing_mode_) |
566 VLOG(1) << action->PrintForDebug(); | 566 VLOG(1) << action->PrintForDebug(); |
567 } | 567 } |
568 | 568 |
| 569 #if defined(ENABLE_EXTENSIONS) |
569 void ActivityLog::OnScriptsExecuted( | 570 void ActivityLog::OnScriptsExecuted( |
570 const content::WebContents* web_contents, | 571 const content::WebContents* web_contents, |
571 const ExecutingScriptsMap& extension_ids, | 572 const ExecutingScriptsMap& extension_ids, |
572 int32 on_page_id, | 573 int32 on_page_id, |
573 const GURL& on_url) { | 574 const GURL& on_url) { |
574 Profile* profile = | 575 Profile* profile = |
575 Profile::FromBrowserContext(web_contents->GetBrowserContext()); | 576 Profile::FromBrowserContext(web_contents->GetBrowserContext()); |
576 ExtensionRegistry* registry = ExtensionRegistry::Get(profile); | 577 ExtensionRegistry* registry = ExtensionRegistry::Get(profile); |
577 for (ExecutingScriptsMap::const_iterator it = extension_ids.begin(); | 578 for (ExecutingScriptsMap::const_iterator it = extension_ids.begin(); |
578 it != extension_ids.end(); ++it) { | 579 it != extension_ids.end(); ++it) { |
(...skipping 23 matching lines...) Loading... |
602 action->mutable_other()->SetBoolean(constants::kActionPrerender, true); | 603 action->mutable_other()->SetBoolean(constants::kActionPrerender, true); |
603 for (std::set<std::string>::const_iterator it2 = it->second.begin(); | 604 for (std::set<std::string>::const_iterator it2 = it->second.begin(); |
604 it2 != it->second.end(); | 605 it2 != it->second.end(); |
605 ++it2) { | 606 ++it2) { |
606 action->mutable_args()->AppendString(*it2); | 607 action->mutable_args()->AppendString(*it2); |
607 } | 608 } |
608 LogAction(action); | 609 LogAction(action); |
609 } | 610 } |
610 } | 611 } |
611 } | 612 } |
| 613 #endif |
612 | 614 |
613 void ActivityLog::OnApiEventDispatched(const std::string& extension_id, | 615 void ActivityLog::OnApiEventDispatched(const std::string& extension_id, |
614 const std::string& event_name, | 616 const std::string& event_name, |
615 scoped_ptr<base::ListValue> event_args) { | 617 scoped_ptr<base::ListValue> event_args) { |
616 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 618 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
617 scoped_refptr<Action> action = new Action(extension_id, | 619 scoped_refptr<Action> action = new Action(extension_id, |
618 base::Time::Now(), | 620 base::Time::Now(), |
619 Action::ACTION_API_EVENT, | 621 Action::ACTION_API_EVENT, |
620 event_name); | 622 event_name); |
621 action->set_args(event_args.Pass()); | 623 action->set_args(event_args.Pass()); |
(...skipping 69 matching lines...) Loading... |
691 database_policy_->DeleteDatabase(); | 693 database_policy_->DeleteDatabase(); |
692 } | 694 } |
693 | 695 |
694 template <> | 696 template <> |
695 void BrowserContextKeyedAPIFactory<ActivityLog>::DeclareFactoryDependencies() { | 697 void BrowserContextKeyedAPIFactory<ActivityLog>::DeclareFactoryDependencies() { |
696 DependsOn(ExtensionsBrowserClient::Get()->GetExtensionSystemFactory()); | 698 DependsOn(ExtensionsBrowserClient::Get()->GetExtensionSystemFactory()); |
697 DependsOn(ExtensionRegistryFactory::GetInstance()); | 699 DependsOn(ExtensionRegistryFactory::GetInstance()); |
698 } | 700 } |
699 | 701 |
700 } // namespace extensions | 702 } // namespace extensions |
OLD | NEW |