Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4096)

Unified Diff: chrome/browser/extensions/extensions_service.cc

Issue 18198: Add user script support to extensions. (Closed)
Patch Set: Compile fixes for linux and mac Created 11 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/extensions/extensions_service.h ('k') | chrome/browser/extensions/user_script_master.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/extensions/extensions_service.cc
diff --git a/chrome/browser/extensions/extensions_service.cc b/chrome/browser/extensions/extensions_service.cc
index 85d4fe8f15b22ee491524d0bbb86b78f4b74270d..e1038217b8316a2e683e81902ce06bc0eb11495c 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));
« no previous file with comments | « chrome/browser/extensions/extensions_service.h ('k') | chrome/browser/extensions/user_script_master.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698