| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/common/extensions/extension_set.h" | 5 #include "chrome/common/extensions/extension_set.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "chrome/common/url_constants.h" | 8 #include "chrome/common/url_constants.h" |
| 9 | 9 |
| 10 using WebKit::WebSecurityOrigin; | 10 using WebKit::WebSecurityOrigin; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 ExtensionSet::ExtensionSet() { | 22 ExtensionSet::ExtensionSet() { |
| 23 } | 23 } |
| 24 | 24 |
| 25 ExtensionSet::~ExtensionSet() { | 25 ExtensionSet::~ExtensionSet() { |
| 26 } | 26 } |
| 27 | 27 |
| 28 size_t ExtensionSet::size() const { | 28 size_t ExtensionSet::size() const { |
| 29 return extensions_.size(); | 29 return extensions_.size(); |
| 30 } | 30 } |
| 31 | 31 |
| 32 bool ExtensionSet::is_empty() const { | |
| 33 return extensions_.empty(); | |
| 34 } | |
| 35 | |
| 36 bool ExtensionSet::Contains(const std::string& extension_id) const { | 32 bool ExtensionSet::Contains(const std::string& extension_id) const { |
| 37 return extensions_.find(extension_id) != extensions_.end(); | 33 return extensions_.find(extension_id) != extensions_.end(); |
| 38 } | 34 } |
| 39 | 35 |
| 40 void ExtensionSet::Insert(const scoped_refptr<const Extension>& extension) { | 36 void ExtensionSet::Insert(const scoped_refptr<const Extension>& extension) { |
| 41 extensions_[extension->id()] = extension; | 37 extensions_[extension->id()] = extension; |
| 42 } | 38 } |
| 43 | 39 |
| 44 void ExtensionSet::Remove(const std::string& id) { | 40 void ExtensionSet::Remove(const std::string& id) { |
| 45 extensions_.erase(id); | 41 extensions_.erase(id); |
| 46 } | 42 } |
| 47 | 43 |
| 48 void ExtensionSet::Clear() { | 44 std::string ExtensionSet::GetIdByURL(const ExtensionURLInfo& info) const { |
| 49 extensions_.clear(); | |
| 50 } | |
| 51 | |
| 52 std::string ExtensionSet::GetIDByURL(const ExtensionURLInfo& info) const { | |
| 53 DCHECK(!info.origin().isNull()); | 45 DCHECK(!info.origin().isNull()); |
| 54 | 46 |
| 55 if (info.url().SchemeIs(chrome::kExtensionScheme)) | 47 if (info.url().SchemeIs(chrome::kExtensionScheme)) |
| 56 return info.origin().isUnique() ? "" : info.url().host(); | 48 return info.origin().isUnique() ? "" : info.url().host(); |
| 57 | 49 |
| 58 const Extension* extension = GetByURL(info); | 50 const Extension* extension = GetByURL(info); |
| 59 if (!extension) | 51 if (!extension) |
| 60 return ""; | 52 return ""; |
| 61 | 53 |
| 62 return extension->id(); | 54 return extension->id(); |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 107 | 99 |
| 108 ExtensionMap::const_iterator i = extensions_.begin(); | 100 ExtensionMap::const_iterator i = extensions_.begin(); |
| 109 for (; i != extensions_.end(); ++i) { | 101 for (; i != extensions_.end(); ++i) { |
| 110 if (i->second->location() == Extension::COMPONENT && | 102 if (i->second->location() == Extension::COMPONENT && |
| 111 i->second->web_extent().MatchesURL(info.url())) | 103 i->second->web_extent().MatchesURL(info.url())) |
| 112 return true; | 104 return true; |
| 113 } | 105 } |
| 114 | 106 |
| 115 return false; | 107 return false; |
| 116 } | 108 } |
| OLD | NEW |