summaryrefslogtreecommitdiffstats
path: root/chrome/browser/extensions/extensions_service.cc
diff options
context:
space:
mode:
Diffstat (limited to 'chrome/browser/extensions/extensions_service.cc')
-rw-r--r--chrome/browser/extensions/extensions_service.cc25
1 files changed, 23 insertions, 2 deletions
diff --git a/chrome/browser/extensions/extensions_service.cc b/chrome/browser/extensions/extensions_service.cc
index 85d4fe8..e103821 100644
--- a/chrome/browser/extensions/extensions_service.cc
+++ b/chrome/browser/extensions/extensions_service.cc
@@ -9,6 +9,7 @@
#include "base/string_util.h"
#include "base/thread.h"
#include "chrome/browser/browser_process.h"
+#include "chrome/browser/extensions/user_script_master.h"
#include "chrome/common/json_value_serializer.h"
#include "chrome/common/notification_service.h"
@@ -17,10 +18,12 @@
const FilePath::CharType* ExtensionsService::kInstallDirectoryName =
FILE_PATH_LITERAL("Extensions");
-ExtensionsService::ExtensionsService(const FilePath& profile_directory)
+ExtensionsService::ExtensionsService(const FilePath& profile_directory,
+ UserScriptMaster* user_script_master)
: message_loop_(MessageLoop::current()),
backend_(new ExtensionsServiceBackend),
- install_directory_(profile_directory.Append(kInstallDirectoryName)) {
+ install_directory_(profile_directory.Append(kInstallDirectoryName)),
+ user_script_master_(user_script_master) {
}
ExtensionsService::~ExtensionsService() {
@@ -53,6 +56,24 @@ void ExtensionsService::OnExtensionsLoadedFromDirectory(
extensions_.insert(extensions_.end(), new_extensions->begin(),
new_extensions->end());
+ // Tell UserScriptMaster about any scripts in the loaded extensions.
+ for (ExtensionList::iterator extension = extensions_.begin();
+ extension != extensions_.end(); ++extension) {
+ const UserScriptList& scripts = (*extension)->user_scripts();
+ for (UserScriptList::const_iterator script = scripts.begin();
+ script != scripts.end(); ++script) {
+ user_script_master_->AddLoneScript(*script);
+ }
+ }
+
+ // Tell UserScriptMaster to also watch the extensions directory for changes
+ // and then kick off the first scan.
+ // TODO(aa): This should go away when we implement the --extension flag, since
+ // developing scripts in the Extensions directory will no longer be a common
+ // use-case.
+ user_script_master_->AddWatchedPath(install_directory_);
+ user_script_master_->StartScan();
+
NotificationService::current()->Notify(NOTIFY_EXTENSIONS_LOADED,
NotificationService::AllSources(),
Details<ExtensionList>(new_extensions));