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

Unified Diff: chrome/browser/automation/automation_provider.cc

Issue 2821018: Follow-up on http://codereview.chromium.org/2861019 to address Powel's commen... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 10 years, 6 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/browser/automation/automation_provider.cc
===================================================================
--- chrome/browser/automation/automation_provider.cc (revision 50678)
+++ chrome/browser/automation/automation_provider.cc (working copy)
@@ -13,6 +13,7 @@
#include "base/file_version_info.h"
#include "base/json/json_reader.h"
#include "base/json/json_writer.h"
+#include "base/json/string_escape.h"
#include "base/keyboard_codes.h"
#include "base/message_loop.h"
#include "base/path_service.h"
@@ -1609,19 +1610,6 @@
Send(reply_message);
}
-std::string AutomationProvider::JSONErrorString(std::string err) {
- std::string prefix = "{\"error\": \"";
- std::string no_quote_err = err;
- std::string suffix = "\"}";
-
- // Don't allow input string to break JSON by embedding quotes.
- // Try and make sure the input string won't break json quoting rules.
- if (no_quote_err.find("\"") != std::string::npos)
- no_quote_err = "unhappy about embedded quote in error string";
-
- return prefix + no_quote_err + suffix;
-}
-
// Sample json input: { "command": "GetBrowserInfo" }
// Refer to GetBrowserInfo() in chrome/test/pyautolib/pyauto.py for
// sample json output.
@@ -2242,13 +2230,23 @@
}
}
- // if we get here, error.
+ // If we get here, error.
DCHECK(!json_return.empty());
AutomationMsg_SendJSONRequest::WriteReplyParams(
reply_message, json_return, false);
Send(reply_message);
}
+/* static */
+std::string AutomationProvider::JSONErrorString(std::string err) {
+ std::string prefix = "{\"error\": \"";
+ std::string no_quote_err;
+ std::string suffix = "\"}";
+
+ base::JsonDoubleQuote(err, false, &no_quote_err);
+ return prefix + no_quote_err + suffix;
+}
+
void AutomationProvider::SendJSONRequest(int handle,
std::string json_request,
IPC::Message* reply_message) {

Powered by Google App Engine
This is Rietveld 408576698