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 |
32 bool ExtensionSet::Contains(const std::string& extension_id) const { | 36 bool ExtensionSet::Contains(const std::string& extension_id) const { |
33 return extensions_.find(extension_id) != extensions_.end(); | 37 return extensions_.find(extension_id) != extensions_.end(); |
34 } | 38 } |
35 | 39 |
36 void ExtensionSet::Insert(const scoped_refptr<const Extension>& extension) { | 40 void ExtensionSet::Insert(const scoped_refptr<const Extension>& extension) { |
37 extensions_[extension->id()] = extension; | 41 extensions_[extension->id()] = extension; |
38 } | 42 } |
39 | 43 |
40 void ExtensionSet::Remove(const std::string& id) { | 44 void ExtensionSet::Remove(const std::string& id) { |
41 extensions_.erase(id); | 45 extensions_.erase(id); |
42 } | 46 } |
43 | 47 |
44 std::string ExtensionSet::GetIdByURL(const ExtensionURLInfo& info) const { | 48 void ExtensionSet::Clear() { |
| 49 extensions_.clear(); |
| 50 } |
| 51 |
| 52 std::string ExtensionSet::GetIDByURL(const ExtensionURLInfo& info) const { |
45 DCHECK(!info.origin().isNull()); | 53 DCHECK(!info.origin().isNull()); |
46 | 54 |
47 if (info.url().SchemeIs(chrome::kExtensionScheme)) | 55 if (info.url().SchemeIs(chrome::kExtensionScheme)) |
48 return info.origin().isUnique() ? "" : info.url().host(); | 56 return info.origin().isUnique() ? "" : info.url().host(); |
49 | 57 |
50 const Extension* extension = GetByURL(info); | 58 const Extension* extension = GetByURL(info); |
51 if (!extension) | 59 if (!extension) |
52 return ""; | 60 return ""; |
53 | 61 |
54 return extension->id(); | 62 return extension->id(); |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
99 | 107 |
100 ExtensionMap::const_iterator i = extensions_.begin(); | 108 ExtensionMap::const_iterator i = extensions_.begin(); |
101 for (; i != extensions_.end(); ++i) { | 109 for (; i != extensions_.end(); ++i) { |
102 if (i->second->location() == Extension::COMPONENT && | 110 if (i->second->location() == Extension::COMPONENT && |
103 i->second->web_extent().MatchesURL(info.url())) | 111 i->second->web_extent().MatchesURL(info.url())) |
104 return true; | 112 return true; |
105 } | 113 } |
106 | 114 |
107 return false; | 115 return false; |
108 } | 116 } |
OLD | NEW |