summaryrefslogtreecommitdiffstats
path: root/chrome/browser/extensions/extensions_service.cc
diff options
context:
space:
mode:
authoraa@chromium.org <aa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-01-25 05:08:54 +0000
committeraa@chromium.org <aa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-01-25 05:08:54 +0000
commitbdbc87ca87fda52c3262240705d974030e9ed4b4 (patch)
tree6ca34f4c2ba9fe4b340075206846c115a5400d27 /chrome/browser/extensions/extensions_service.cc
parent1692ea885338dd799ae9f47151d2a7fd4d1b10c4 (diff)
downloadchromium_src-bdbc87ca87fda52c3262240705d974030e9ed4b4.zip
chromium_src-bdbc87ca87fda52c3262240705d974030e9ed4b4.tar.gz
chromium_src-bdbc87ca87fda52c3262240705d974030e9ed4b4.tar.bz2
Add user script support to extensions.
This is implemented mostly by relying on the existing user script code. But since extension user scripts are declared, not discovered in a directory, I had to add support for adding 'lone' user scripts to UserScriptMaster. This led to a bit of refactoring. Note that this CL relies on: http://codereview.chromium.org/18352 Review URL: http://codereview.chromium.org/18198 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@8614 0039d316-1c4b-4281-b951-d872f2087c98
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));