| 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/webdriver/webdriver_util.h" | 5 #include "chrome/test/webdriver/webdriver_util.h" |
| 6 | 6 |
| 7 #include "base/base64.h" | 7 #include "base/base64.h" |
| 8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
| 10 #include "base/files/scoped_temp_dir.h" | 10 #include "base/files/scoped_temp_dir.h" |
| (...skipping 391 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 402 void TruncateString(std::string* data) { | 402 void TruncateString(std::string* data) { |
| 403 const size_t kMaxLength = 100; | 403 const size_t kMaxLength = 100; |
| 404 if (data->length() > kMaxLength) { | 404 if (data->length() > kMaxLength) { |
| 405 data->resize(kMaxLength); | 405 data->resize(kMaxLength); |
| 406 data->replace(kMaxLength - 3, 3, "..."); | 406 data->replace(kMaxLength - 3, 3, "..."); |
| 407 } | 407 } |
| 408 } | 408 } |
| 409 | 409 |
| 410 // Truncates all strings contained in the given value. | 410 // Truncates all strings contained in the given value. |
| 411 void TruncateContainedStrings(Value* value) { | 411 void TruncateContainedStrings(Value* value) { |
| 412 ListValue* list; | 412 ListValue* list = NULL; |
| 413 if (value->IsType(Value::TYPE_DICTIONARY)) { | 413 DictionaryValue* dict = NULL; |
| 414 DictionaryValue* dict = static_cast<DictionaryValue*>(value); | 414 if (value->GetAsDictionary(&dict)) { |
| 415 DictionaryValue::key_iterator key = dict->begin_keys(); | 415 for (DictionaryValue::Iterator it(*dict); !it.IsAtEnd(); it.Advance()) { |
| 416 for (; key != dict->end_keys(); ++key) { | |
| 417 Value* child; | |
| 418 if (!dict->GetWithoutPathExpansion(*key, &child)) | |
| 419 continue; | |
| 420 std::string data; | 416 std::string data; |
| 421 if (child->GetAsString(&data)) { | 417 if (it.value().GetAsString(&data)) { |
| 422 TruncateString(&data); | 418 TruncateString(&data); |
| 423 dict->SetWithoutPathExpansion(*key, new base::StringValue(data)); | 419 dict->SetWithoutPathExpansion(it.key(), new base::StringValue(data)); |
| 424 } else { | 420 } else { |
| 421 Value* child = NULL; |
| 422 dict->GetWithoutPathExpansion(it.key(), &child); |
| 425 TruncateContainedStrings(child); | 423 TruncateContainedStrings(child); |
| 426 } | 424 } |
| 427 } | 425 } |
| 428 } else if (value->GetAsList(&list)) { | 426 } else if (value->GetAsList(&list)) { |
| 429 for (size_t i = 0; i < list->GetSize(); ++i) { | 427 for (size_t i = 0; i < list->GetSize(); ++i) { |
| 430 Value* child; | 428 Value* child; |
| 431 if (!list->Get(i, &child)) | 429 if (!list->Get(i, &child)) |
| 432 continue; | 430 continue; |
| 433 std::string data; | 431 std::string data; |
| 434 if (child->GetAsString(&data)) { | 432 if (child->GetAsString(&data)) { |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 550 | 548 |
| 551 bool ValueConversionTraits<webdriver::SkipParsing>::SetFromValue( | 549 bool ValueConversionTraits<webdriver::SkipParsing>::SetFromValue( |
| 552 const Value* value, const webdriver::SkipParsing* t) { | 550 const Value* value, const webdriver::SkipParsing* t) { |
| 553 return true; | 551 return true; |
| 554 } | 552 } |
| 555 | 553 |
| 556 bool ValueConversionTraits<webdriver::SkipParsing>::CanConvert( | 554 bool ValueConversionTraits<webdriver::SkipParsing>::CanConvert( |
| 557 const Value* value) { | 555 const Value* value) { |
| 558 return true; | 556 return true; |
| 559 } | 557 } |
| OLD | NEW |