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

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

Issue 7003098: Start refractoring extension permissions into ExtensionPermissionSet. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Cleanup and update ExtensionPermissionSet data model. Created 9 years, 6 months 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
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/url_pattern_set.h" 5 #include "chrome/common/extensions/url_pattern_set.h"
6 6
7 #include "chrome/common/extensions/url_pattern.h" 7 #include "chrome/common/extensions/url_pattern.h"
8 #include "googleurl/src/gurl.h" 8 #include "googleurl/src/gurl.h"
9 9
10 // static
11 void URLPatternSet::CreateUnion(const URLPatternSet& set1,
12 const URLPatternSet& set2,
13 URLPatternSet* out) {
14 const URLPatternList list1 = set1.patterns();
15 const URLPatternList list2 = set2.patterns();
16
17 out->ClearPatterns();
18
19 // TODO(jstritar): This would be a lot easier if URLPattern had == overrided.
20 for (size_t i = 0; i < list1.size(); ++i) {
21 bool duplicate = false;
22 for (size_t j = 0; j < out->patterns().size(); ++j) {
23 if (list1.at(i).GetAsString() == out->patterns().at(j).GetAsString()) {
24 duplicate = true;
25 break;
26 }
27 }
28 if (!duplicate)
Matt Perry 2011/06/21 00:43:10 is there a strong reason to strip duplicates? if n
jstritar 2011/06/21 23:12:16 It doesn't really matter, except that they'll accu
29 out->AddPattern(list1.at(i));
30 }
31
32 for (size_t i = 0; i < list2.size(); ++i) {
33 bool duplicate = false;
34 for (size_t j = 0; j < out->patterns().size(); ++j) {
35 if (list2.at(i).GetAsString() == out->patterns().at(j).GetAsString()) {
36 duplicate = true;
37 break;
38 }
39 }
40 if (!duplicate)
41 out->AddPattern(list2.at(i));
42 }
43 }
44
10 URLPatternSet::URLPatternSet() { 45 URLPatternSet::URLPatternSet() {
11 } 46 }
12 47
13 URLPatternSet::URLPatternSet(const URLPatternSet& rhs) 48 URLPatternSet::URLPatternSet(const URLPatternSet& rhs)
14 : patterns_(rhs.patterns_) { 49 : patterns_(rhs.patterns_) {
15 } 50 }
16 51
17 URLPatternSet::~URLPatternSet() { 52 URLPatternSet::~URLPatternSet() {
18 } 53 }
19 54
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 i != patterns_.end(); ++i) { 86 i != patterns_.end(); ++i) {
52 for (URLPatternList::const_iterator j = other.patterns().begin(); 87 for (URLPatternList::const_iterator j = other.patterns().begin();
53 j != other.patterns().end(); ++j) { 88 j != other.patterns().end(); ++j) {
54 if (i->OverlapsWith(*j)) 89 if (i->OverlapsWith(*j))
55 return true; 90 return true;
56 } 91 }
57 } 92 }
58 93
59 return false; 94 return false;
60 } 95 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698