| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/shared_user_script_master.h" | 5 #include "chrome/browser/extensions/shared_user_script_master.h" |
| 6 | 6 |
| 7 #include "chrome/browser/extensions/extension_util.h" | 7 #include "chrome/browser/extensions/extension_util.h" |
| 8 #include "chrome/browser/profiles/profile.h" | 8 #include "chrome/browser/profiles/profile.h" |
| 9 #include "chrome/common/extensions/manifest_handlers/content_scripts_handler.h" | 9 #include "chrome/common/extensions/manifest_handlers/content_scripts_handler.h" |
| 10 #include "extensions/browser/extension_registry.h" | 10 #include "extensions/browser/extension_registry.h" |
| 11 #include "extensions/common/consumer.h" |
| 11 | 12 |
| 12 namespace extensions { | 13 namespace extensions { |
| 13 | 14 |
| 14 SharedUserScriptMaster::SharedUserScriptMaster(Profile* profile) | 15 SharedUserScriptMaster::SharedUserScriptMaster(Profile* profile) |
| 15 : loader_(profile, | 16 : loader_(profile, |
| 16 std::string() /* owner_extension_id */, | 17 ConsumerID() /* owner_extension_id */, |
| 17 true /* listen_for_extension_system_loaded */), | 18 true /* listen_for_extension_system_loaded */), |
| 18 profile_(profile), | 19 profile_(profile), |
| 19 extension_registry_observer_(this) { | 20 extension_registry_observer_(this) { |
| 20 extension_registry_observer_.Add(ExtensionRegistry::Get(profile_)); | 21 extension_registry_observer_.Add(ExtensionRegistry::Get(profile_)); |
| 21 } | 22 } |
| 22 | 23 |
| 23 SharedUserScriptMaster::~SharedUserScriptMaster() { | 24 SharedUserScriptMaster::~SharedUserScriptMaster() { |
| 24 } | 25 } |
| 25 | 26 |
| 26 void SharedUserScriptMaster::OnExtensionLoaded( | 27 void SharedUserScriptMaster::OnExtensionLoaded( |
| (...skipping 13 matching lines...) Expand all Loading... |
| 40 const Extension* extension) { | 41 const Extension* extension) { |
| 41 bool incognito_enabled = util::IsIncognitoEnabled(extension->id(), profile_); | 42 bool incognito_enabled = util::IsIncognitoEnabled(extension->id(), profile_); |
| 42 const UserScriptList& script_list = | 43 const UserScriptList& script_list = |
| 43 ContentScriptsInfo::GetContentScripts(extension); | 44 ContentScriptsInfo::GetContentScripts(extension); |
| 44 std::set<UserScript> script_set; | 45 std::set<UserScript> script_set; |
| 45 for (UserScriptList::const_iterator it = script_list.begin(); | 46 for (UserScriptList::const_iterator it = script_list.begin(); |
| 46 it != script_list.end(); | 47 it != script_list.end(); |
| 47 ++it) { | 48 ++it) { |
| 48 UserScript script = *it; | 49 UserScript script = *it; |
| 49 script.set_incognito_enabled(incognito_enabled); | 50 script.set_incognito_enabled(incognito_enabled); |
| 51 ConsumerID consumer_id(ConsumerID::EXTENSIONS, extension->id(), |
| 52 ConsumerID::TAB, ConsumerID::kDefaultInstanceID); |
| 53 script.set_consumer_id(consumer_id); |
| 50 script_set.insert(script); | 54 script_set.insert(script); |
| 51 } | 55 } |
| 52 | 56 |
| 53 return script_set; | 57 return script_set; |
| 54 } | 58 } |
| 55 | 59 |
| 56 } // namespace extensions | 60 } // namespace extensions |
| OLD | NEW |