| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #include "chrome/test/chromedriver/chrome/log.h" | 5 #include "chrome/test/chromedriver/chrome/log.h" |
| 6 | 6 |
| 7 #include "base/json/json_reader.h" | 7 #include "base/json/json_reader.h" |
| 8 #include "base/json/json_writer.h" | 8 #include "base/json/json_writer.h" |
| 9 #include "base/strings/string_util.h" | 9 #include "base/strings/string_util.h" |
| 10 #include "base/values.h" | 10 #include "base/values.h" |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 78 | 78 |
| 79 bool IsVLogOn(int vlog_level) { | 79 bool IsVLogOn(int vlog_level) { |
| 80 if (!g_is_vlog_on_func) | 80 if (!g_is_vlog_on_func) |
| 81 return false; | 81 return false; |
| 82 return g_is_vlog_on_func(vlog_level); | 82 return g_is_vlog_on_func(vlog_level); |
| 83 } | 83 } |
| 84 | 84 |
| 85 std::string PrettyPrintValue(const base::Value& value) { | 85 std::string PrettyPrintValue(const base::Value& value) { |
| 86 std::string json; | 86 std::string json; |
| 87 base::JSONWriter::WriteWithOptions( | 87 base::JSONWriter::WriteWithOptions( |
| 88 &value, base::JSONWriter::OPTIONS_PRETTY_PRINT, &json); | 88 value, base::JSONWriter::OPTIONS_PRETTY_PRINT, &json); |
| 89 #if defined(OS_WIN) | 89 #if defined(OS_WIN) |
| 90 base::RemoveChars(json, "\r", &json); | 90 base::RemoveChars(json, "\r", &json); |
| 91 #endif | 91 #endif |
| 92 // Remove the trailing newline. | 92 // Remove the trailing newline. |
| 93 if (json.length()) | 93 if (json.length()) |
| 94 json.resize(json.length() - 1); | 94 json.resize(json.length() - 1); |
| 95 return json; | 95 return json; |
| 96 } | 96 } |
| 97 | 97 |
| 98 std::string FormatValueForDisplay(const base::Value& value) { | 98 std::string FormatValueForDisplay(const base::Value& value) { |
| 99 scoped_ptr<base::Value> copy(SmartDeepCopy(&value)); | 99 scoped_ptr<base::Value> copy(SmartDeepCopy(&value)); |
| 100 return PrettyPrintValue(*copy); | 100 return PrettyPrintValue(*copy); |
| 101 } | 101 } |
| 102 | 102 |
| 103 std::string FormatJsonForDisplay(const std::string& json) { | 103 std::string FormatJsonForDisplay(const std::string& json) { |
| 104 scoped_ptr<base::Value> value(base::JSONReader::Read(json)); | 104 scoped_ptr<base::Value> value(base::JSONReader::Read(json)); |
| 105 if (!value) | 105 if (!value) |
| 106 value.reset(new base::StringValue(json)); | 106 value.reset(new base::StringValue(json)); |
| 107 return FormatValueForDisplay(*value); | 107 return FormatValueForDisplay(*value); |
| 108 } | 108 } |
| OLD | NEW |