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

Side by Side Diff: base/json/json_writer.cc

Issue 7038028: Initial support for cloudprint in print preview (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix bad merge Created 9 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/browser/about_flags.cc » ('j') | chrome/browser/about_flags.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 "base/json/json_writer.h" 5 #include "base/json/json_writer.h"
6 6
7 #include "base/json/string_escape.h" 7 #include "base/json/string_escape.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/stringprintf.h" 9 #include "base/stringprintf.h"
10 #include "base/string_number_conversions.h" 10 #include "base/string_number_conversions.h"
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 bool result = node->GetAsString(&value); 107 bool result = node->GetAsString(&value);
108 DCHECK(result); 108 DCHECK(result);
109 if (escape) { 109 if (escape) {
110 JsonDoubleQuote(UTF8ToUTF16(value), true, json_string_); 110 JsonDoubleQuote(UTF8ToUTF16(value), true, json_string_);
111 } else { 111 } else {
112 JsonDoubleQuote(value, true, json_string_); 112 JsonDoubleQuote(value, true, json_string_);
113 } 113 }
114 break; 114 break;
115 } 115 }
116 116
117 case Value::TYPE_BINARY:
Scott Byer 2011/05/24 23:40:32 If StringValue works with the constructed form str
118 {
119 const BinaryValue* data = static_cast<const BinaryValue*>(node);
120 std::string value(data->GetBuffer(), data->GetSize());
121 JsonDoubleQuote(value, true, json_string_);
122 break;
123 }
124
117 case Value::TYPE_LIST: 125 case Value::TYPE_LIST:
118 { 126 {
119 json_string_->append("["); 127 json_string_->append("[");
120 if (pretty_print_) 128 if (pretty_print_)
121 json_string_->append(" "); 129 json_string_->append(" ");
122 130
123 const ListValue* list = static_cast<const ListValue*>(node); 131 const ListValue* list = static_cast<const ListValue*>(node);
124 for (size_t i = 0; i < list->GetSize(); ++i) { 132 for (size_t i = 0; i < list->GetSize(); ++i) {
125 if (i != 0) { 133 if (i != 0) {
126 json_string_->append(","); 134 json_string_->append(",");
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
194 JsonDoubleQuote(UTF8ToUTF16(str), true, json_string_); 202 JsonDoubleQuote(UTF8ToUTF16(str), true, json_string_);
195 } 203 }
196 204
197 void JSONWriter::IndentLine(int depth) { 205 void JSONWriter::IndentLine(int depth) {
198 // It may be faster to keep an indent string so we don't have to keep 206 // It may be faster to keep an indent string so we don't have to keep
199 // reallocating. 207 // reallocating.
200 json_string_->append(std::string(depth * 3, ' ')); 208 json_string_->append(std::string(depth * 3, ' '));
201 } 209 }
202 210
203 } // namespace base 211 } // namespace base
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/about_flags.cc » ('j') | chrome/browser/about_flags.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698