summaryrefslogtreecommitdiffstats
path: root/chrome/browser/extensions/user_script_master.cc
diff options
context:
space:
mode:
authormpcomplete@chromium.org <mpcomplete@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-02-25 22:10:50 +0000
committermpcomplete@chromium.org <mpcomplete@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-02-25 22:10:50 +0000
commitdb7331aecb1f0c01aecf4cd4627d08a8d5b08bc2 (patch)
tree5a33fc21cb1628462f9e365add27aeaf058d60fc /chrome/browser/extensions/user_script_master.cc
parentf56abff188b90b7f2d67a094930d7d9407df507d (diff)
downloadchromium_src-db7331aecb1f0c01aecf4cd4627d08a8d5b08bc2.zip
chromium_src-db7331aecb1f0c01aecf4cd4627d08a8d5b08bc2.tar.gz
chromium_src-db7331aecb1f0c01aecf4cd4627d08a8d5b08bc2.tar.bz2
Allow users to enable extensions in incognito. Requires
--enable-experimental-extension-apis . The UI needs work. Tab and window events are hooked up so that they work with incognito tabs/windows when enabled. BUG=32365 BUG=36292 Review URL: http://codereview.chromium.org/657041 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@40057 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/extensions/user_script_master.cc')
-rw-r--r--chrome/browser/extensions/user_script_master.cc29
1 files changed, 18 insertions, 11 deletions
diff --git a/chrome/browser/extensions/user_script_master.cc b/chrome/browser/extensions/user_script_master.cc
index a7d69f6..9506efd 100644
--- a/chrome/browser/extensions/user_script_master.cc
+++ b/chrome/browser/extensions/user_script_master.cc
@@ -294,6 +294,8 @@ UserScriptMaster::UserScriptMaster(const FilePath& script_dir, Profile* profile)
Source<Profile>(profile_));
registrar_.Add(this, NotificationType::EXTENSION_LOADED,
Source<Profile>(profile_));
+ registrar_.Add(this, NotificationType::EXTENSION_INCOGNITO_CHANGED,
+ Source<Profile>(profile_));
registrar_.Add(this, NotificationType::EXTENSION_UNLOADED,
Source<Profile>(profile_));
}
@@ -348,6 +350,22 @@ void UserScriptMaster::Observe(NotificationType type,
StartScan();
break;
}
+ case NotificationType::EXTENSION_INCOGNITO_CHANGED: {
+ // Toggle the incognito_enabled bit for any content scripts inside the
+ // extension.
+ Extension* extension =
+ Details<std::pair<Extension*, bool> >(details).ptr()->first;
+ bool incognito_enabled =
+ Details<std::pair<Extension*, bool> >(details).ptr()->second;
+ for (UserScriptList::iterator iter = lone_scripts_.begin();
+ iter != lone_scripts_.end(); ++iter) {
+ if (iter->extension_id() == extension->id())
+ (*iter).set_incognito_enabled(incognito_enabled);
+ }
+ if (extensions_service_ready_)
+ StartScan();
+ break;
+ }
case NotificationType::EXTENSION_UNLOADED: {
// Remove any content scripts.
@@ -378,14 +396,3 @@ void UserScriptMaster::StartScan() {
script_reloader_->StartScan(user_script_dir_, lone_scripts_);
}
-
-void UserScriptMaster::ReloadExtensionForTesting(Extension* extension) {
- bool incognito_enabled = profile_->GetExtensionsService()->
- IsIncognitoEnabled(extension->id());
- for (UserScriptList::iterator iter = lone_scripts_.begin();
- iter != lone_scripts_.end(); ++iter) {
- if (iter->extension_id() == extension->id())
- (*iter).set_incognito_enabled(incognito_enabled);
- }
- StartScan();
-}