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/renderer/extensions/v8_schema_registry.h" | 5 #include "chrome/renderer/extensions/v8_schema_registry.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/values.h" | 8 #include "base/values.h" |
9 #include "chrome/common/extensions/api/extension_api.h" | 9 #include "chrome/common/extensions/api/extension_api.h" |
10 #include "content/public/renderer/v8_value_converter.h" | 10 #include "content/public/renderer/v8_value_converter.h" |
(...skipping 23 matching lines...) Expand all Loading... |
34 } | 34 } |
35 return v8_apis; | 35 return v8_apis; |
36 } | 36 } |
37 | 37 |
38 v8::Handle<v8::Object> V8SchemaRegistry::GetSchema(const std::string& api) { | 38 v8::Handle<v8::Object> V8SchemaRegistry::GetSchema(const std::string& api) { |
39 SchemaCache::iterator maybe_schema = schema_cache_.find(api); | 39 SchemaCache::iterator maybe_schema = schema_cache_.find(api); |
40 if (maybe_schema != schema_cache_.end()) | 40 if (maybe_schema != schema_cache_.end()) |
41 return maybe_schema->second; | 41 return maybe_schema->second; |
42 | 42 |
43 const base::DictionaryValue* schema = | 43 const base::DictionaryValue* schema = |
44 ExtensionAPI::GetInstance()->GetSchema(api); | 44 ExtensionAPI::GetSharedInstance()->GetSchema(api); |
45 CHECK(schema) << api; | 45 CHECK(schema) << api; |
46 | 46 |
47 scoped_ptr<V8ValueConverter> v8_value_converter(V8ValueConverter::create()); | 47 scoped_ptr<V8ValueConverter> v8_value_converter(V8ValueConverter::create()); |
48 v8::Persistent<v8::Object> v8_schema = | 48 v8::Persistent<v8::Object> v8_schema = |
49 v8::Persistent<v8::Object>::New(v8::Handle<v8::Object>::Cast( | 49 v8::Persistent<v8::Object>::New(v8::Handle<v8::Object>::Cast( |
50 v8_value_converter->ToV8Value(schema, context_))); | 50 v8_value_converter->ToV8Value(schema, context_))); |
51 CHECK(!v8_schema.IsEmpty()); | 51 CHECK(!v8_schema.IsEmpty()); |
52 schema_cache_[api] = v8_schema; | 52 schema_cache_[api] = v8_schema; |
53 return v8_schema; | 53 return v8_schema; |
54 } | 54 } |
55 | 55 |
56 } // namespace extensions | 56 } // namespace extensions |
OLD | NEW |