OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "chrome/common/extensions/file_browser_action.h" |
| 6 |
| 7 #include "chrome/common/extensions/url_pattern.h" |
| 8 #include "googleurl/src/gurl.h" |
| 9 |
| 10 FileBrowserAction::FileBrowserAction() { |
| 11 } |
| 12 |
| 13 |
| 14 FileBrowserAction::~FileBrowserAction() { |
| 15 } |
| 16 |
| 17 void FileBrowserAction::AddPattern(const URLPattern& pattern) { |
| 18 patterns_.push_back(pattern); |
| 19 } |
| 20 |
| 21 void FileBrowserAction::ClearPatterns() { |
| 22 patterns_.clear(); |
| 23 } |
| 24 |
| 25 bool FileBrowserAction::ContainsURL(const GURL& url) const { |
| 26 for (PatternList::const_iterator pattern = patterns_.begin(); |
| 27 pattern != patterns_.end(); ++pattern) { |
| 28 if (pattern->MatchesUrl(url)) |
| 29 return true; |
| 30 } |
| 31 return false; |
| 32 } |
| 33 |
| 34 bool FileBrowserAction::OverlapsWith(const FileBrowserAction& other) const { |
| 35 // Two extension extents overlap if there is any one URL that would match at |
| 36 // least one pattern in each of the extents. |
| 37 for (PatternList::const_iterator i = patterns_.begin(); |
| 38 i != patterns_.end(); ++i) { |
| 39 for (PatternList::const_iterator j = other.patterns().begin(); |
| 40 j != other.patterns().end(); ++j) { |
| 41 if (i->OverlapsWith(*j)) |
| 42 return true; |
| 43 } |
| 44 } |
| 45 |
| 46 return false; |
| 47 } |
OLD | NEW |