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