| 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/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 |
| 11 #include "base/json/json_reader.h" | 11 #include "base/json/json_reader.h" |
| 12 #include "base/json/json_writer.h" | 12 #include "base/json/json_writer.h" |
| 13 #include "base/lazy_instance.h" | 13 #include "base/lazy_instance.h" |
| 14 #include "base/logging.h" | 14 #include "base/logging.h" |
| 15 #include "base/string_number_conversions.h" | 15 #include "base/string_number_conversions.h" |
| 16 #include "base/string_split.h" | 16 #include "base/string_split.h" |
| 17 #include "base/string_util.h" | 17 #include "base/string_util.h" |
| 18 #include "base/values.h" | 18 #include "base/values.h" |
| 19 #include "chrome/common/extensions/api/generated_schemas.h" | 19 #include "chrome/common/extensions/api/generated_schemas.h" |
| 20 #include "chrome/common/extensions/extension.h" | 20 #include "chrome/common/extensions/extension.h" |
| 21 #include "chrome/common/extensions/extension_permission_set.h" | 21 #include "chrome/common/extensions/extension_permission_set.h" |
| 22 #include "chrome/common/extensions/simple_feature_provider.h" | 22 #include "chrome/common/extensions/simple_feature_provider.h" |
| 23 #include "googleurl/src/gurl.h" | 23 #include "googleurl/src/gurl.h" |
| 24 #include "grit/common_resources.h" | 24 #include "grit/common_resources.h" |
| 25 #include "grit/extensions_api_resources.h" | 25 #include "grit/extensions_api_resources.h" |
| 26 #include "ui/base/layout.h" |
| 26 #include "ui/base/resource/resource_bundle.h" | 27 #include "ui/base/resource/resource_bundle.h" |
| 27 | 28 |
| 28 using base::DictionaryValue; | 29 using base::DictionaryValue; |
| 29 using base::ListValue; | 30 using base::ListValue; |
| 30 using base::Value; | 31 using base::Value; |
| 31 | 32 |
| 32 namespace extensions { | 33 namespace extensions { |
| 33 | 34 |
| 34 using api::GeneratedSchemas; | 35 using api::GeneratedSchemas; |
| 35 | 36 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 54 CHECK(child_list->GetDictionary(i, &item)); | 55 CHECK(child_list->GetDictionary(i, &item)); |
| 55 bool unprivileged = false; | 56 bool unprivileged = false; |
| 56 if (item->GetBoolean("unprivileged", &unprivileged)) | 57 if (item->GetBoolean("unprivileged", &unprivileged)) |
| 57 return unprivileged; | 58 return unprivileged; |
| 58 } | 59 } |
| 59 | 60 |
| 60 return false; | 61 return false; |
| 61 } | 62 } |
| 62 | 63 |
| 63 base::StringPiece ReadFromResource(int resource_id) { | 64 base::StringPiece ReadFromResource(int resource_id) { |
| 64 return ResourceBundle::GetSharedInstance().GetRawDataResource(resource_id); | 65 return ResourceBundle::GetSharedInstance().GetRawDataResource( |
| 66 resource_id, ui::SCALE_FACTOR_NONE); |
| 65 } | 67 } |
| 66 | 68 |
| 67 scoped_ptr<ListValue> LoadSchemaList(const std::string& name, | 69 scoped_ptr<ListValue> LoadSchemaList(const std::string& name, |
| 68 const base::StringPiece& schema) { | 70 const base::StringPiece& schema) { |
| 69 std::string error_message; | 71 std::string error_message; |
| 70 scoped_ptr<Value> result( | 72 scoped_ptr<Value> result( |
| 71 base::JSONReader::ReadAndReturnError( | 73 base::JSONReader::ReadAndReturnError( |
| 72 schema.as_string(), | 74 schema.as_string(), |
| 73 base::JSON_PARSE_RFC, // options | 75 base::JSON_PARSE_RFC, // options |
| 74 NULL, // error code | 76 NULL, // error code |
| (...skipping 722 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 797 | 799 |
| 798 void ExtensionAPI::LoadAllSchemas() { | 800 void ExtensionAPI::LoadAllSchemas() { |
| 799 while (unloaded_schemas_.size()) { | 801 while (unloaded_schemas_.size()) { |
| 800 std::map<std::string, base::StringPiece>::iterator it = | 802 std::map<std::string, base::StringPiece>::iterator it = |
| 801 unloaded_schemas_.begin(); | 803 unloaded_schemas_.begin(); |
| 802 LoadSchema(it->first, it->second); | 804 LoadSchema(it->first, it->second); |
| 803 } | 805 } |
| 804 } | 806 } |
| 805 | 807 |
| 806 } // namespace extensions | 808 } // namespace extensions |
| OLD | NEW |