Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(6143)

Unified Diff: chrome/common/content_settings.h

Issue 15841011: Implement off-the-wire validation scheme for enum types. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Correct check in content_settings.h Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/common/content_settings.h
diff --git a/chrome/common/content_settings.h b/chrome/common/content_settings.h
index bf92413bc10e9d07f593279604856d7b00e9bc95..18e88b53a7154d73b686e0ca8110f4c26f9e8ccb 100644
--- a/chrome/common/content_settings.h
+++ b/chrome/common/content_settings.h
@@ -8,6 +8,7 @@
#include <string>
#include <vector>
+#include "base/enum_validation.h"
#include "chrome/common/content_settings_pattern.h"
#include "chrome/common/content_settings_types.h"
@@ -21,6 +22,9 @@ enum ContentSetting {
CONTENT_SETTING_SESSION_ONLY,
CONTENT_SETTING_NUM_SETTINGS
};
+template <> inline bool IsIntValidForEnum<ContentSetting>(int x) {
darin (slow to review) 2013/05/31 07:11:37 I don't have a solution to offer, but this feels k
+ return x >= CONTENT_SETTING_DEFAULT && x < CONTENT_SETTING_NUM_SETTINGS;
+}
// Range-checked conversion of an int to a ContentSetting, for use when reading
// prefs off disk.
« no previous file with comments | « base/enum_validation.h ('k') | ipc/ipc_message_macros.h » ('j') | ipc/ipc_message_macros.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698