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

Side by Side Diff: components/policy/core/common/schema.cc

Issue 2816513002: Revert of Change base::Value::ListStorage to std::vector<base::Value> (Closed)
Patch Set: Created 3 years, 8 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
« no previous file with comments | « components/policy/core/common/registry_dict.cc ('k') | components/prefs/pref_member.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "components/policy/core/common/schema.h" 5 #include "components/policy/core/common/schema.h"
6 6
7 #include <limits.h> 7 #include <limits.h>
8 #include <stddef.h> 8 #include <stddef.h>
9 9
10 #include <algorithm> 10 #include <algorithm>
(...skipping 601 matching lines...) Expand 10 before | Expand all | Expand 10 after
612 *error = "Enum attribute must be non-empty"; 612 *error = "Enum attribute must be non-empty";
613 return false; 613 return false;
614 } 614 }
615 int offset_begin; 615 int offset_begin;
616 int offset_end; 616 int offset_end;
617 if (type == base::Value::Type::INTEGER) { 617 if (type == base::Value::Type::INTEGER) {
618 offset_begin = static_cast<int>(int_enums_.size()); 618 offset_begin = static_cast<int>(int_enums_.size());
619 int value; 619 int value;
620 for (base::ListValue::const_iterator it = possible_values->begin(); 620 for (base::ListValue::const_iterator it = possible_values->begin();
621 it != possible_values->end(); ++it) { 621 it != possible_values->end(); ++it) {
622 if (!it->GetAsInteger(&value)) { 622 if (!(*it)->GetAsInteger(&value)) {
623 *error = "Invalid enumeration member type"; 623 *error = "Invalid enumeration member type";
624 return false; 624 return false;
625 } 625 }
626 int_enums_.push_back(value); 626 int_enums_.push_back(value);
627 } 627 }
628 offset_end = static_cast<int>(int_enums_.size()); 628 offset_end = static_cast<int>(int_enums_.size());
629 } else if (type == base::Value::Type::STRING) { 629 } else if (type == base::Value::Type::STRING) {
630 offset_begin = static_cast<int>(string_enums_.size()); 630 offset_begin = static_cast<int>(string_enums_.size());
631 std::string value; 631 std::string value;
632 for (base::ListValue::const_iterator it = possible_values->begin(); 632 for (base::ListValue::const_iterator it = possible_values->begin();
633 it != possible_values->end(); ++it) { 633 it != possible_values->end(); ++it) {
634 if (!it->GetAsString(&value)) { 634 if (!(*it)->GetAsString(&value)) {
635 *error = "Invalid enumeration member type"; 635 *error = "Invalid enumeration member type";
636 return false; 636 return false;
637 } 637 }
638 strings_.push_back(value); 638 strings_.push_back(value);
639 string_enums_.push_back(strings_.back().c_str()); 639 string_enums_.push_back(strings_.back().c_str());
640 } 640 }
641 offset_end = static_cast<int>(string_enums_.size()); 641 offset_end = static_cast<int>(string_enums_.size());
642 } else { 642 } else {
643 *error = "Enumeration is only supported for integer and string."; 643 *error = "Enumeration is only supported for integer and string.";
644 return false; 644 return false;
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
819 AddDictKeyPrefixToPath(it.key(), error_path); 819 AddDictKeyPrefixToPath(it.key(), error_path);
820 if (!StrategyAllowInvalidOnTopLevel(strategy)) 820 if (!StrategyAllowInvalidOnTopLevel(strategy))
821 return false; 821 return false;
822 } 822 }
823 } 823 }
824 } 824 }
825 } 825 }
826 } else if (value.GetAsList(&list)) { 826 } else if (value.GetAsList(&list)) {
827 for (base::ListValue::const_iterator it = list->begin(); it != list->end(); 827 for (base::ListValue::const_iterator it = list->begin(); it != list->end();
828 ++it) { 828 ++it) {
829 if (!GetItems().Validate(*it, StrategyForNextLevel(strategy), error_path, 829 if (!*it ||
830 !GetItems().Validate(**it,
831 StrategyForNextLevel(strategy),
832 error_path,
830 error)) { 833 error)) {
831 // Invalid list item was detected. 834 // Invalid list item was detected.
832 AddListIndexPrefixToPath(it - list->begin(), error_path); 835 AddListIndexPrefixToPath(it - list->begin(), error_path);
833 if (!StrategyAllowInvalidOnTopLevel(strategy)) 836 if (!StrategyAllowInvalidOnTopLevel(strategy))
834 return false; 837 return false;
835 } 838 }
836 } 839 }
837 } else if (value.GetAsInteger(&int_value)) { 840 } else if (value.GetAsInteger(&int_value)) {
838 if (node_->extra != kInvalid && 841 if (node_->extra != kInvalid &&
839 !ValidateIntegerRestriction(node_->extra, int_value)) { 842 !ValidateIntegerRestriction(node_->extra, int_value)) {
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after
1102 return false; 1105 return false;
1103 } else { 1106 } else {
1104 int index = rnode->string_pattern_restriction.pattern_index; 1107 int index = rnode->string_pattern_restriction.pattern_index;
1105 DCHECK(index == rnode->string_pattern_restriction.pattern_index_backup); 1108 DCHECK(index == rnode->string_pattern_restriction.pattern_index_backup);
1106 re2::RE2* regex = storage_->CompileRegex(*storage_->string_enums(index)); 1109 re2::RE2* regex = storage_->CompileRegex(*storage_->string_enums(index));
1107 return re2::RE2::PartialMatch(str, *regex); 1110 return re2::RE2::PartialMatch(str, *regex);
1108 } 1111 }
1109 } 1112 }
1110 1113
1111 } // namespace policy 1114 } // namespace policy
OLDNEW
« no previous file with comments | « components/policy/core/common/registry_dict.cc ('k') | components/prefs/pref_member.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698