| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef WEBKIT_GLUE_RESOURCE_TYPE_H__ | 5 #ifndef WEBKIT_GLUE_RESOURCE_TYPE_H__ |
| 6 #define WEBKIT_GLUE_RESOURCE_TYPE_H__ | 6 #define WEBKIT_GLUE_RESOURCE_TYPE_H__ |
| 7 | 7 |
| 8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 #include "third_party/WebKit/Source/WebKit/chromium/public/WebURLRequest.h" |
| 9 | 10 |
| 10 class ResourceType { | 11 class ResourceType { |
| 11 public: | 12 public: |
| 12 enum Type { | 13 enum Type { |
| 13 MAIN_FRAME = 0, // top level page | 14 MAIN_FRAME = 0, // top level page |
| 14 SUB_FRAME, // frame or iframe | 15 SUB_FRAME, // frame or iframe |
| 15 STYLESHEET, // a CSS stylesheet | 16 STYLESHEET, // a CSS stylesheet |
| 16 SCRIPT, // an external script | 17 SCRIPT, // an external script |
| 17 IMAGE, // an image (jpg/gif/png/etc) | 18 IMAGE, // an image (jpg/gif/png/etc) |
| 18 FONT_RESOURCE, // a font | 19 FONT_RESOURCE, // a font |
| (...skipping 11 matching lines...) Expand all Loading... |
| 30 }; | 31 }; |
| 31 | 32 |
| 32 static bool ValidType(int32 type) { | 33 static bool ValidType(int32 type) { |
| 33 return type >= MAIN_FRAME && type < LAST_TYPE; | 34 return type >= MAIN_FRAME && type < LAST_TYPE; |
| 34 } | 35 } |
| 35 | 36 |
| 36 static Type FromInt(int32 type) { | 37 static Type FromInt(int32 type) { |
| 37 return static_cast<Type>(type); | 38 return static_cast<Type>(type); |
| 38 } | 39 } |
| 39 | 40 |
| 41 static Type FromTargetType(WebKit::WebURLRequest::TargetType type); |
| 42 |
| 40 static bool IsFrame(ResourceType::Type type) { | 43 static bool IsFrame(ResourceType::Type type) { |
| 41 return type == MAIN_FRAME || type == SUB_FRAME; | 44 return type == MAIN_FRAME || type == SUB_FRAME; |
| 42 } | 45 } |
| 43 | 46 |
| 44 static bool IsSharedWorker(ResourceType::Type type) { | 47 static bool IsSharedWorker(ResourceType::Type type) { |
| 45 return type == SHARED_WORKER; | 48 return type == SHARED_WORKER; |
| 46 } | 49 } |
| 47 | 50 |
| 48 static bool IsSubresource(ResourceType::Type type) { | 51 static bool IsSubresource(ResourceType::Type type) { |
| 49 return type == STYLESHEET || | 52 return type == STYLESHEET || |
| 50 type == SCRIPT || | 53 type == SCRIPT || |
| 51 type == IMAGE || | 54 type == IMAGE || |
| 52 type == FONT_RESOURCE || | 55 type == FONT_RESOURCE || |
| 53 type == SUB_RESOURCE || | 56 type == SUB_RESOURCE || |
| 54 type == WORKER; | 57 type == WORKER; |
| 55 } | 58 } |
| 56 | 59 |
| 57 private: | 60 private: |
| 58 // Don't instantiate this class. | 61 // Don't instantiate this class. |
| 59 ResourceType(); | 62 ResourceType(); |
| 60 ~ResourceType(); | 63 ~ResourceType(); |
| 61 }; | 64 }; |
| 62 #endif // WEBKIT_GLUE_RESOURCE_TYPE_H__ | 65 #endif // WEBKIT_GLUE_RESOURCE_TYPE_H__ |
| OLD | NEW |