Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(250)

Side by Side Diff: chrome/common/extensions/extension_set.cc

Issue 8789018: Revert 113047 - Make ExtensionService use ExtensionSet. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
Property Changes:
Added: svn:mergeinfo
OLDNEW
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
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
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 }
OLDNEW
« no previous file with comments | « chrome/common/extensions/extension_set.h ('k') | chrome/renderer/extensions/extension_dispatcher.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698