From 703e807a70e50e32b3c4821c84c23bde69f73272 Mon Sep 17 00:00:00 2001 From: "aa@chromium.org" Date: Sat, 28 Mar 2009 19:56:51 +0000 Subject: Add more of the server-side plumbing for extension APIs. Also added getTabsForWindow() to drive it. Review URL: http://codereview.chromium.org/42680 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@12744 0039d316-1c4b-4281-b951-d872f2087c98 --- base/json_reader.h | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) (limited to 'base/json_reader.h') diff --git a/base/json_reader.h b/base/json_reader.h index ac4ca1a..9c4065b 100644 --- a/base/json_reader.h +++ b/base/json_reader.h @@ -85,6 +85,8 @@ class JSONReader { static const char* kUnsupportedEncoding; static const char* kUnquotedDictionaryKey; + JSONReader(); + // Reads and parses |json|, returning a Value. The caller owns the returned // instance. If |json| is not a properly formed JSON string, returns NULL. // If |allow_trailing_comma| is true, we will ignore trailing commas in @@ -99,25 +101,29 @@ class JSONReader { bool allow_trailing_comma, std::string* error_message_out); + // Returns the error message if the last call to JsonToValue() failed. If the + // last call did not fail, returns a valid empty string. + std::string error_message() { return error_message_; } + + // Reads and parses |json|, returning a Value. The caller owns the returned + // instance. If |json| is not a properly formed JSON string, returns NULL and + // a detailed error can be retrieved from |error_message()|. + // If |check_root| is true, we require that the root object be an object or + // array. Otherwise, it can be any valid JSON type. + // If |allow_trailing_comma| is true, we will ignore trailing commas in + // objects and arrays even though this goes against the RFC. + Value* JsonToValue(const std::string& json, bool check_root, + bool allow_trailing_comma); + private: static std::string FormatErrorMessage(int line, int column, const char* description); - JSONReader(); DISALLOW_EVIL_CONSTRUCTORS(JSONReader); FRIEND_TEST(JSONReaderTest, Reading); FRIEND_TEST(JSONReaderTest, ErrorMessages); - // Returns the error message if the last call to JsonToValue() failed. If the - // last call did not fail, returns a valid empty string. - std::string error_message() { return error_message_; } - - // Pass through method from JSONReader::Read. We have this so unittests can - // disable the root check. - Value* JsonToValue(const std::string& json, bool check_root, - bool allow_trailing_comma); - // Recursively build Value. Returns NULL if we don't have a valid JSON // string. If |is_root| is true, we verify that the root element is either // an object or an array. -- cgit v1.1