| Index: chrome/browser/extensions/extension_service.cc
|
| ===================================================================
|
| --- chrome/browser/extensions/extension_service.cc (revision 113069)
|
| +++ chrome/browser/extensions/extension_service.cc (working copy)
|
| @@ -444,15 +444,15 @@
|
| install_directory_.value().length(), 0, 500, 100);
|
| }
|
|
|
| -const ExtensionSet* ExtensionService::extensions() const {
|
| +const ExtensionList* ExtensionService::extensions() const {
|
| return &extensions_;
|
| }
|
|
|
| -const ExtensionSet* ExtensionService::disabled_extensions() const {
|
| +const ExtensionList* ExtensionService::disabled_extensions() const {
|
| return &disabled_extensions_;
|
| }
|
|
|
| -const ExtensionSet* ExtensionService::terminated_extensions() const {
|
| +const ExtensionList* ExtensionService::terminated_extensions() const {
|
| return &terminated_extensions_;
|
| }
|
|
|
| @@ -766,11 +766,14 @@
|
|
|
| bool ExtensionService::IsExtensionEnabled(
|
| const std::string& extension_id) const {
|
| - if (extensions_.Contains(extension_id) ||
|
| - terminated_extensions_.Contains(extension_id))
|
| + const Extension* extension =
|
| + GetExtensionByIdInternal(extension_id, true, false, true);
|
| + if (extension)
|
| return true;
|
|
|
| - if (disabled_extensions_.Contains(extension_id))
|
| + extension =
|
| + GetExtensionByIdInternal(extension_id, false, true, false);
|
| + if (extension)
|
| return false;
|
|
|
| // If the extension hasn't been loaded yet, check the prefs for it. Assume
|
| @@ -800,8 +803,11 @@
|
| return;
|
|
|
| // Move it over to the enabled list.
|
| - extensions_.Insert(make_scoped_refptr(extension));
|
| - disabled_extensions_.Remove(extension->id());
|
| + extensions_.push_back(make_scoped_refptr(extension));
|
| + ExtensionList::iterator iter = std::find(disabled_extensions_.begin(),
|
| + disabled_extensions_.end(),
|
| + extension);
|
| + disabled_extensions_.erase(iter);
|
|
|
| // Make sure any browser action contained within it is not hidden.
|
| extension_prefs_->SetBrowserActionVisibility(extension, true);
|
| @@ -831,11 +837,18 @@
|
| return;
|
|
|
| // Move it over to the disabled list.
|
| - disabled_extensions_.Insert(make_scoped_refptr(extension));
|
| - if (extensions_.Contains(extension->id()))
|
| - extensions_.Remove(extension->id());
|
| - else
|
| - terminated_extensions_.Remove(extension->id());
|
| + disabled_extensions_.push_back(make_scoped_refptr(extension));
|
| + ExtensionList::iterator iter = std::find(extensions_.begin(),
|
| + extensions_.end(),
|
| + extension);
|
| + if (iter != extensions_.end()) {
|
| + extensions_.erase(iter);
|
| + } else {
|
| + iter = std::find(terminated_extensions_.begin(),
|
| + terminated_extensions_.end(),
|
| + extension);
|
| + terminated_extensions_.erase(iter);
|
| + }
|
|
|
| NotifyExtensionUnloaded(extension, extension_misc::UNLOAD_REASON_DISABLE);
|
|
|
| @@ -1102,7 +1115,7 @@
|
| extension_prefs_->UpdateBlacklist(blacklist_set);
|
| std::vector<std::string> to_be_removed;
|
| // Loop current extensions, unload installed extensions.
|
| - for (ExtensionSet::const_iterator iter = extensions_.begin();
|
| + for (ExtensionList::const_iterator iter = extensions_.begin();
|
| iter != extensions_.end(); ++iter) {
|
| const Extension* extension = (*iter);
|
| if (blacklist_set.find(extension->id()) != blacklist_set.end()) {
|
| @@ -1145,7 +1158,7 @@
|
| void ExtensionService::CheckAdminBlacklist() {
|
| std::vector<std::string> to_be_removed;
|
| // Loop through extensions list, unload installed extensions.
|
| - for (ExtensionSet::const_iterator iter = extensions_.begin();
|
| + for (ExtensionList::const_iterator iter = extensions_.begin();
|
| iter != extensions_.end(); ++iter) {
|
| const Extension* extension = (*iter);
|
| if (!extension_prefs_->IsExtensionAllowedByPolicy(extension->id(),
|
| @@ -1346,10 +1359,10 @@
|
| }
|
|
|
| void ExtensionService::GetSyncDataListHelper(
|
| - const ExtensionSet& extensions,
|
| + const ExtensionList& extensions,
|
| const SyncBundle& bundle,
|
| std::vector<ExtensionSyncData>* sync_data_list) const {
|
| - for (ExtensionSet::const_iterator it = extensions.begin();
|
| + for (ExtensionList::const_iterator it = extensions.begin();
|
| it != extensions.end(); ++it) {
|
| const Extension& extension = **it;
|
| if (bundle.filter(extension) &&
|
| @@ -1480,7 +1493,8 @@
|
|
|
| extension_prefs_->SetIsIncognitoEnabled(extension_id, enabled);
|
|
|
| - bool extension_is_enabled = extensions_.Contains(extension->id());
|
| + bool extension_is_enabled = std::find(extensions_.begin(), extensions_.end(),
|
| + extension) != extensions_.end();
|
|
|
| // When we reload the extension the ID may be invalidated if we've passed it
|
| // by const ref everywhere. Make a copy to be safe.
|
| @@ -1557,7 +1571,8 @@
|
|
|
| extension_prefs_->SetAllowFileAccess(extension->id(), allow);
|
|
|
| - bool extension_is_enabled = extensions_.Contains(extension->id());
|
| + bool extension_is_enabled = std::find(extensions_.begin(), extensions_.end(),
|
| + extension) != extensions_.end();
|
| if (extension_is_enabled)
|
| ReloadExtension(extension->id());
|
| }
|
| @@ -1661,9 +1676,12 @@
|
| scoped_ptr<ExtensionGlobalError> global_error(
|
| new ExtensionGlobalError(AsWeakPtr()));
|
| bool needs_alert = false;
|
| - for (ExtensionSet::const_iterator iter = extensions_.begin();
|
| + for (ExtensionList::const_iterator iter = extensions_.begin();
|
| iter != extensions_.end(); ++iter) {
|
| const Extension* e = *iter;
|
| + if (!IsExtensionEnabled(e->id())) {
|
| + continue;
|
| + }
|
| if (Extension::IsExternalLocation(e->location())) {
|
| if (!extension_prefs_->IsExternalExtensionAcknowledged(e->id())) {
|
| global_error->AddExternalExtension(e->id());
|
| @@ -1763,10 +1781,13 @@
|
| // Clean up runtime data.
|
| extension_runtime_data_.erase(extension_id);
|
|
|
| -if (disabled_extensions_.Contains(extension->id())) {
|
| + ExtensionList::iterator iter = std::find(disabled_extensions_.begin(),
|
| + disabled_extensions_.end(),
|
| + extension.get());
|
| + if (iter != disabled_extensions_.end()) {
|
| UnloadedExtensionInfo details(extension, reason);
|
| details.already_disabled = true;
|
| - disabled_extensions_.Remove(extension->id());
|
| + disabled_extensions_.erase(iter);
|
| content::NotificationService::current()->Notify(
|
| chrome::NOTIFICATION_EXTENSION_UNLOADED,
|
| content::Source<Profile>(profile_),
|
| @@ -1778,9 +1799,11 @@
|
| return;
|
| }
|
|
|
| -// Remove the extension from our list.
|
| - extensions_.Remove(extension->id());
|
| + iter = std::find(extensions_.begin(), extensions_.end(), extension.get());
|
|
|
| + // Remove the extension from our list.
|
| + extensions_.erase(iter);
|
| +
|
| NotifyExtensionUnloaded(extension.get(), reason);
|
| }
|
|
|
| @@ -1788,9 +1811,10 @@
|
| profile_->GetExtensionSpecialStoragePolicy()->
|
| RevokeRightsForAllExtensions();
|
|
|
| - extensions_.Clear();
|
| - disabled_extensions_.Clear();
|
| - terminated_extensions_.Clear();
|
| + extensions_.clear();
|
| + disabled_extensions_.clear();
|
| + terminated_extension_ids_.clear();
|
| + terminated_extensions_.clear();
|
| extension_runtime_data_.clear();
|
|
|
| // TODO(erikkay) should there be a notification for this? We can't use
|
| @@ -1874,10 +1898,10 @@
|
|
|
| bool disabled = extension_prefs_->IsExtensionDisabled(extension->id());
|
| if (disabled) {
|
| - disabled_extensions_.Insert(scoped_extension);
|
| - // TODO(aa): This seems dodgy. AddExtension() could get called with a
|
| - // disabled extension for other reasons other than that an update was
|
| - // disabled, e.g. as in ExtensionManagementTest.InstallRequiresConfirm.
|
| + disabled_extensions_.push_back(scoped_extension);
|
| + // TODO(aa): This seems dodgy. It seems that AddExtension() could get called
|
| + // with a disabled extension for other reasons other than that an update was
|
| + // disabled.
|
| content::NotificationService::current()->Notify(
|
| chrome::NOTIFICATION_EXTENSION_UPDATE_DISABLED,
|
| content::Source<Profile>(profile_),
|
| @@ -1886,7 +1910,7 @@
|
| return;
|
| }
|
|
|
| - extensions_.Insert(scoped_extension);
|
| + extensions_.push_back(scoped_extension);
|
| SyncExtensionChangeIfNeeded(*extension);
|
| NotifyExtensionLoaded(extension);
|
| IdentifyAlertableExtensions();
|
| @@ -1998,11 +2022,10 @@
|
|
|
| void ExtensionService::UpdateActiveExtensionsInCrashReporter() {
|
| std::set<std::string> extension_ids;
|
| - for (ExtensionSet::const_iterator iter = extensions_.begin();
|
| - iter != extensions_.end(); ++iter) {
|
| - const Extension* extension = *iter;
|
| - if (!extension->is_theme() && extension->location() != Extension::COMPONENT)
|
| - extension_ids.insert(extension->id());
|
| + for (size_t i = 0; i < extensions_.size(); ++i) {
|
| + if (!extensions_[i]->is_theme() &&
|
| + extensions_[i]->location() != Extension::COMPONENT)
|
| + extension_ids.insert(extensions_[i]->id());
|
| }
|
|
|
| child_process_logging::SetActiveExtensions(extension_ids);
|
| @@ -2095,33 +2118,51 @@
|
| bool include_terminated) const {
|
| std::string lowercase_id = StringToLowerASCII(id);
|
| if (include_enabled) {
|
| - const Extension* extension = extensions_.GetByID(lowercase_id);
|
| - if (extension)
|
| - return extension;
|
| + for (ExtensionList::const_iterator iter = extensions_.begin();
|
| + iter != extensions_.end(); ++iter) {
|
| + if ((*iter)->id() == lowercase_id)
|
| + return *iter;
|
| + }
|
| }
|
| if (include_disabled) {
|
| - const Extension* extension = disabled_extensions_.GetByID(lowercase_id);
|
| - if (extension)
|
| - return extension;
|
| + for (ExtensionList::const_iterator iter = disabled_extensions_.begin();
|
| + iter != disabled_extensions_.end(); ++iter) {
|
| + if ((*iter)->id() == lowercase_id)
|
| + return *iter;
|
| + }
|
| }
|
| if (include_terminated) {
|
| - const Extension* extension = terminated_extensions_.GetByID(lowercase_id);
|
| - if (extension)
|
| - return extension;
|
| + for (ExtensionList::const_iterator iter = terminated_extensions_.begin();
|
| + iter != terminated_extensions_.end(); ++iter) {
|
| + if ((*iter)->id() == lowercase_id)
|
| + return *iter;
|
| + }
|
| }
|
| return NULL;
|
| }
|
|
|
| void ExtensionService::TrackTerminatedExtension(const Extension* extension) {
|
| - if (!terminated_extensions_.Contains(extension->id()))
|
| - terminated_extensions_.Insert(make_scoped_refptr(extension));
|
| + if (terminated_extension_ids_.insert(extension->id()).second)
|
| + terminated_extensions_.push_back(make_scoped_refptr(extension));
|
|
|
| + // TODO(yoz): Listen to navcontrollers for that extension. Is this a todo?
|
| +
|
| + // TODO(yoz): make sure this is okay in *ALL* the listeners!
|
| UnloadExtension(extension->id(), extension_misc::UNLOAD_REASON_TERMINATE);
|
| }
|
|
|
| void ExtensionService::UntrackTerminatedExtension(const std::string& id) {
|
| std::string lowercase_id = StringToLowerASCII(id);
|
| - terminated_extensions_.Remove(lowercase_id);
|
| + if (terminated_extension_ids_.erase(lowercase_id) <= 0)
|
| + return;
|
| +
|
| + for (ExtensionList::iterator iter = terminated_extensions_.begin();
|
| + iter != terminated_extensions_.end(); ++iter) {
|
| + if ((*iter)->id() == lowercase_id) {
|
| + terminated_extensions_.erase(iter);
|
| + return;
|
| + }
|
| + }
|
| }
|
|
|
| const Extension* ExtensionService::GetTerminatedExtension(
|
| @@ -2144,22 +2185,18 @@
|
| }
|
|
|
| const Extension* ExtensionService::GetExtensionByWebExtent(const GURL& url) {
|
| - // TODO(yoz): Should be ExtensionSet::GetByURL.
|
| - for (ExtensionSet::const_iterator iter = extensions_.begin();
|
| - iter != extensions_.end(); ++iter) {
|
| - if ((*iter)->web_extent().MatchesURL(url))
|
| - return *iter;
|
| + for (size_t i = 0; i < extensions_.size(); ++i) {
|
| + if (extensions_[i]->web_extent().MatchesURL(url))
|
| + return extensions_[i];
|
| }
|
| return NULL;
|
| }
|
|
|
| const Extension* ExtensionService::GetDisabledExtensionByWebExtent(
|
| const GURL& url) {
|
| - // TODO(yoz): Should be ExtensionSet::GetByURL.
|
| - for (ExtensionSet::const_iterator iter = disabled_extensions_.begin();
|
| - iter != disabled_extensions_.end(); ++iter) {
|
| - if ((*iter)->web_extent().MatchesURL(url))
|
| - return *iter;
|
| + for (size_t i = 0; i < disabled_extensions_.size(); ++i) {
|
| + if (disabled_extensions_[i]->web_extent().MatchesURL(url))
|
| + return disabled_extensions_[i];
|
| }
|
| return NULL;
|
| }
|
| @@ -2180,11 +2217,9 @@
|
|
|
| const Extension* ExtensionService::GetExtensionByOverlappingWebExtent(
|
| const URLPatternSet& extent) {
|
| - // TODO(yoz): Should be in ExtensionSet.
|
| - for (ExtensionSet::const_iterator iter = extensions_.begin();
|
| - iter != extensions_.end(); ++iter) {
|
| - if ((*iter)->web_extent().OverlapsWith(extent))
|
| - return *iter;
|
| + for (size_t i = 0; i < extensions_.size(); ++i) {
|
| + if (extensions_[i]->web_extent().OverlapsWith(extent))
|
| + return extensions_[i];
|
| }
|
|
|
| return NULL;
|
| @@ -2319,9 +2354,9 @@
|
|
|
| // Loaded extensions.
|
| std::vector<ExtensionMsg_Loaded_Params> loaded_extensions;
|
| - for (ExtensionSet::const_iterator iter = extensions_.begin();
|
| - iter != extensions_.end(); ++iter) {
|
| - loaded_extensions.push_back(ExtensionMsg_Loaded_Params(*iter));
|
| + for (size_t i = 0; i < extensions_.size(); ++i) {
|
| + loaded_extensions.push_back(
|
| + ExtensionMsg_Loaded_Params(extensions_[i]));
|
| }
|
| process->Send(new ExtensionMsg_Loaded(loaded_extensions));
|
| break;
|
| @@ -2372,7 +2407,7 @@
|
|
|
| ExtensionIdSet ExtensionService::GetAppIds() const {
|
| ExtensionIdSet result;
|
| - for (ExtensionSet::const_iterator it = extensions_.begin();
|
| + for (ExtensionList::const_iterator it = extensions_.begin();
|
| it != extensions_.end(); ++it) {
|
| if ((*it)->is_app() && (*it)->location() != Extension::COMPONENT)
|
| result.insert((*it)->id());
|
|
|
| Property changes on: chrome/browser/extensions/extension_service.cc
|
| ___________________________________________________________________
|
| Added: svn:mergeinfo
|
|
|
|
|