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 #ifndef WEBKIT_GLUE_RESOURCE_TYPE_H__ 6 #define WEBKIT_GLUE_RESOURCE_TYPE_H__ 7 8 #include "base/basictypes.h" 9 10 class ResourceType { 11 public: 12 enum Type { 13 MAIN_FRAME = 0, // top level page 14 SUB_FRAME, // frame or iframe 15 STYLESHEET, // a CSS stylesheet 16 SCRIPT, // an external script 17 IMAGE, // an image (jpg/gif/png/etc) 18 FONT_RESOURCE, // a font 19 SUB_RESOURCE, // an "other" subresource. 20 OBJECT, // an object (or embed) tag for a plugin, 21 // or a resource that a plugin requested. 22 MEDIA, // a media resource. 23 WORKER, // the main resource of a dedicated worker. 24 SHARED_WORKER, // the main resource of a shared worker. 25 PREFETCH, // an explicitly requested prefetch 26 FAVICON, // a favicon 27 LAST_TYPE // Place holder so we don't need to change ValidType 28 // everytime. 29 }; 30 ValidType(int32 type)31 static bool ValidType(int32 type) { 32 return type >= MAIN_FRAME && type < LAST_TYPE; 33 } 34 FromInt(int32 type)35 static Type FromInt(int32 type) { 36 return static_cast<Type>(type); 37 } 38 IsFrame(ResourceType::Type type)39 static bool IsFrame(ResourceType::Type type) { 40 return type == MAIN_FRAME || type == SUB_FRAME; 41 } 42 IsSharedWorker(ResourceType::Type type)43 static bool IsSharedWorker(ResourceType::Type type) { 44 return type == SHARED_WORKER; 45 } 46 IsSubresource(ResourceType::Type type)47 static bool IsSubresource(ResourceType::Type type) { 48 return type == STYLESHEET || 49 type == SCRIPT || 50 type == IMAGE || 51 type == FONT_RESOURCE || 52 type == SUB_RESOURCE || 53 type == WORKER; 54 } 55 56 private: 57 // Don't instantiate this class. 58 ResourceType(); 59 ~ResourceType(); 60 }; 61 #endif // WEBKIT_GLUE_RESOURCE_TYPE_H__ 62