1ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen// Copyright (c) 2011 The Chromium Authors. All rights reserved. 2ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen// Use of this source code is governed by a BSD-style license that can be 3ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen// found in the LICENSE file. 4ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen 5ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen#include "chrome/common/extensions/file_browser_handler.h" 6ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen 7ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen#include "chrome/common/extensions/url_pattern.h" 8ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen#include "googleurl/src/gurl.h" 9ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen 10ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian MonsenFileBrowserHandler::FileBrowserHandler() { 11ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen} 12ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen 13ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian MonsenFileBrowserHandler::~FileBrowserHandler() { 14ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen} 15ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen 16ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsenvoid FileBrowserHandler::AddPattern(const URLPattern& pattern) { 17ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen patterns_.push_back(pattern); 18ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen} 19ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen 20ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsenvoid FileBrowserHandler::ClearPatterns() { 21ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen patterns_.clear(); 22ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen} 23ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen 24ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsenbool FileBrowserHandler::MatchesURL(const GURL& url) const { 25ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen for (PatternList::const_iterator pattern = patterns_.begin(); 26ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen pattern != patterns_.end(); ++pattern) { 27ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen if (pattern->MatchesUrl(url)) 28ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen return true; 29ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen } 30ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen return false; 31ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen} 32ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen 33