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

Side by Side Diff: chrome/common/extensions/api/extension_api.cc

Issue 10834004: Correct const accessors in base/values.(h|cc) (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Reverting webdriver:Command::parameters_ to const Created 8 years, 5 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
OLDNEW
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/common/extensions/api/extension_api.h" 5 #include "chrome/common/extensions/api/extension_api.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 // Returns true if |dict| has an unprivileged "true" property. 43 // Returns true if |dict| has an unprivileged "true" property.
44 bool IsUnprivileged(const DictionaryValue* dict) { 44 bool IsUnprivileged(const DictionaryValue* dict) {
45 bool unprivileged = false; 45 bool unprivileged = false;
46 return dict->GetBoolean("unprivileged", &unprivileged) && unprivileged; 46 return dict->GetBoolean("unprivileged", &unprivileged) && unprivileged;
47 } 47 }
48 48
49 // Returns whether the list at |name_space_node|.|child_kind| contains any 49 // Returns whether the list at |name_space_node|.|child_kind| contains any
50 // children with an { "unprivileged": true } property. 50 // children with an { "unprivileged": true } property.
51 bool HasUnprivilegedChild(const DictionaryValue* name_space_node, 51 bool HasUnprivilegedChild(const DictionaryValue* name_space_node,
52 const std::string& child_kind) { 52 const std::string& child_kind) {
53 ListValue* child_list = NULL; 53 const ListValue* child_list = NULL;
54 DictionaryValue* child_dict = NULL; 54 const DictionaryValue* child_dict = NULL;
55 55
56 if (name_space_node->GetList(child_kind, &child_list)) { 56 if (name_space_node->GetList(child_kind, &child_list)) {
57 for (size_t i = 0; i < child_list->GetSize(); ++i) { 57 for (size_t i = 0; i < child_list->GetSize(); ++i) {
58 DictionaryValue* item = NULL; 58 DictionaryValue* item = NULL;
59 CHECK(child_list->GetDictionary(i, &item)); 59 CHECK(child_list->GetDictionary(i, &item));
60 if (IsUnprivileged(item)) 60 if (IsUnprivileged(item))
61 return true; 61 return true;
62 } 62 }
63 } else if (name_space_node->GetDictionary(child_kind, &child_dict)) { 63 } else if (name_space_node->GetDictionary(child_kind, &child_dict)) {
64 for (DictionaryValue::Iterator it(*child_dict); it.HasNext(); 64 for (DictionaryValue::Iterator it(*child_dict); it.HasNext();
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 return item; 112 return item;
113 } 113 }
114 114
115 return NULL; 115 return NULL;
116 } 116 }
117 117
118 const DictionaryValue* GetSchemaChild(const DictionaryValue* schema_node, 118 const DictionaryValue* GetSchemaChild(const DictionaryValue* schema_node,
119 const std::string& child_name) { 119 const std::string& child_name) {
120 DictionaryValue* child_node = NULL; 120 DictionaryValue* child_node = NULL;
121 for (size_t i = 0; i < arraysize(kChildKinds); ++i) { 121 for (size_t i = 0; i < arraysize(kChildKinds); ++i) {
122 ListValue* list_node = NULL; 122 const ListValue* list_node = NULL;
123 if (!schema_node->GetList(kChildKinds[i], &list_node)) 123 if (!schema_node->GetList(kChildKinds[i], &list_node))
124 continue; 124 continue;
125 child_node = FindListItem(list_node, "name", child_name); 125 child_node = FindListItem(list_node, "name", child_name);
126 if (child_node) 126 if (child_node)
127 return child_node; 127 return child_node;
128 } 128 }
129 129
130 return NULL; 130 return NULL;
131 } 131 }
132 132
(...skipping 658 matching lines...) Expand 10 before | Expand all | Expand 10 after
791 std::string feature_name; 791 std::string feature_name;
792 SplitDependencyName(api_name, &feature_type, &feature_name); 792 SplitDependencyName(api_name, &feature_type, &feature_name);
793 793
794 // Only API features can have dependencies for now. 794 // Only API features can have dependencies for now.
795 if (feature_type != "api") 795 if (feature_type != "api")
796 return; 796 return;
797 797
798 const DictionaryValue* schema = GetSchema(feature_name); 798 const DictionaryValue* schema = GetSchema(feature_name);
799 CHECK(schema) << "Schema for " << feature_name << " not found"; 799 CHECK(schema) << "Schema for " << feature_name << " not found";
800 800
801 ListValue* dependencies = NULL; 801 const ListValue* dependencies = NULL;
802 if (!schema->GetList("dependencies", &dependencies)) 802 if (!schema->GetList("dependencies", &dependencies))
803 return; 803 return;
804 804
805 for (size_t i = 0; i < dependencies->GetSize(); ++i) { 805 for (size_t i = 0; i < dependencies->GetSize(); ++i) {
806 std::string dependency_name; 806 std::string dependency_name;
807 if (dependencies->GetString(i, &dependency_name) && 807 if (dependencies->GetString(i, &dependency_name) &&
808 !excluding.count(dependency_name)) { 808 !excluding.count(dependency_name)) {
809 out->insert(dependency_name); 809 out->insert(dependency_name);
810 } 810 }
811 } 811 }
(...skipping 30 matching lines...) Expand all
842 842
843 void ExtensionAPI::LoadAllSchemas() { 843 void ExtensionAPI::LoadAllSchemas() {
844 while (unloaded_schemas_.size()) { 844 while (unloaded_schemas_.size()) {
845 std::map<std::string, base::StringPiece>::iterator it = 845 std::map<std::string, base::StringPiece>::iterator it =
846 unloaded_schemas_.begin(); 846 unloaded_schemas_.begin();
847 LoadSchema(it->first, it->second); 847 LoadSchema(it->first, it->second);
848 } 848 }
849 } 849 }
850 850
851 } // namespace extensions 851 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/browser/web_resource/notification_promo.cc ('k') | chrome/common/extensions/api/extension_api_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698