Chromium Code Reviews| 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 ExtensionSet::ExtensionSet() { | 10 ExtensionSet::ExtensionSet() { |
| 11 } | 11 } |
| 12 | 12 |
| 13 ExtensionSet::~ExtensionSet() { | 13 ExtensionSet::~ExtensionSet() { |
| 14 } | 14 } |
| 15 | 15 |
| 16 size_t ExtensionSet::size() const { | 16 size_t ExtensionSet::size() const { |
| 17 return extensions_.size(); | 17 return extensions_.size(); |
| 18 } | 18 } |
| 19 | 19 |
| 20 bool ExtensionSet::empty() const { | |
|
Aaron Boodman
2011/12/01 08:27:12
I prefer is_empty() to avoid confusion with clear(
Yoyo Zhou
2011/12/05 19:34:09
Done.
| |
| 21 return extensions_.empty(); | |
| 22 } | |
| 23 | |
| 20 bool ExtensionSet::Contains(const std::string& extension_id) const { | 24 bool ExtensionSet::Contains(const std::string& extension_id) const { |
| 21 return extensions_.find(extension_id) != extensions_.end(); | 25 return extensions_.find(extension_id) != extensions_.end(); |
| 22 } | 26 } |
| 23 | 27 |
| 24 void ExtensionSet::Insert(const scoped_refptr<const Extension>& extension) { | 28 void ExtensionSet::Insert(const scoped_refptr<const Extension>& extension) { |
| 25 extensions_[extension->id()] = extension; | 29 extensions_[extension->id()] = extension; |
| 26 } | 30 } |
| 27 | 31 |
| 28 void ExtensionSet::Remove(const std::string& id) { | 32 void ExtensionSet::Remove(const std::string& id) { |
| 29 extensions_.erase(id); | 33 extensions_.erase(id); |
| 30 } | 34 } |
| 31 | 35 |
| 32 std::string ExtensionSet::GetIdByURL(const GURL& url) const { | 36 void ExtensionSet::Clear() { |
| 37 extensions_.clear(); | |
| 38 } | |
| 39 | |
| 40 std::string ExtensionSet::GetIDByURL(const GURL& url) const { | |
| 33 if (url.SchemeIs(chrome::kExtensionScheme)) | 41 if (url.SchemeIs(chrome::kExtensionScheme)) |
| 34 return url.host(); | 42 return url.host(); |
| 35 | 43 |
| 36 const Extension* extension = GetByURL(url); | 44 const Extension* extension = GetByURL(url); |
| 37 if (!extension) | 45 if (!extension) |
| 38 return ""; | 46 return ""; |
| 39 | 47 |
| 40 return extension->id(); | 48 return extension->id(); |
| 41 } | 49 } |
| 42 | 50 |
| (...skipping 29 matching lines...) Expand all Loading... | |
| 72 | 80 |
| 73 ExtensionMap::const_iterator i = extensions_.begin(); | 81 ExtensionMap::const_iterator i = extensions_.begin(); |
| 74 for (; i != extensions_.end(); ++i) { | 82 for (; i != extensions_.end(); ++i) { |
| 75 if (i->second->location() == Extension::COMPONENT && | 83 if (i->second->location() == Extension::COMPONENT && |
| 76 i->second->web_extent().MatchesURL(url)) | 84 i->second->web_extent().MatchesURL(url)) |
| 77 return true; | 85 return true; |
| 78 } | 86 } |
| 79 | 87 |
| 80 return false; | 88 return false; |
| 81 } | 89 } |
| OLD | NEW |