1 // Copyright (c) 2012 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 #ifndef CHROME_BROWSER_EXTENSIONS_API_WEB_REQUEST_WEB_REQUEST_PERMISSIONS_H_ 6 #define CHROME_BROWSER_EXTENSIONS_API_WEB_REQUEST_WEB_REQUEST_PERMISSIONS_H_ 7 8 #include <map> 9 #include <string> 10 11 #include "base/basictypes.h" 12 13 class ExtensionInfoMap; 14 class GURL; 15 16 namespace net { 17 class URLRequest; 18 } 19 20 // This class is used to test whether extensions may modify web requests. 21 class WebRequestPermissions { 22 public: 23 // Different host permission checking modes for CanExtensionAccessURL. 24 enum HostPermissionsCheck { 25 DO_NOT_CHECK_HOST = 0, // No check. 26 REQUIRE_HOST_PERMISSION, // Permission needed for given URL. 27 REQUIRE_ALL_URLS // Permission needed for <all_urls>. 28 }; 29 30 // Returns true if the request shall not be reported to extensions. 31 static bool HideRequest(const ExtensionInfoMap* extension_info_map, 32 const net::URLRequest* request); 33 34 // |host_permission_check| controls how permissions are checked with regard to 35 // |url|. 36 static bool CanExtensionAccessURL( 37 const ExtensionInfoMap* extension_info_map, 38 const std::string& extension_id, 39 const GURL& url, 40 bool crosses_incognito, 41 HostPermissionsCheck host_permissions_check); 42 43 private: 44 DISALLOW_IMPLICIT_CONSTRUCTORS(WebRequestPermissions); 45 }; 46 47 #endif // CHROME_BROWSER_EXTENSIONS_API_WEB_REQUEST_WEB_REQUEST_PERMISSIONS_H_ 48