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

Side by Side Diff: gin/converter.h

Issue 1433293004: [Extensions] Don't allow gin::Define to be overridden (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 1 month 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 | « extensions/renderer/v8_helpers.h ('k') | no next file » | 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 #ifndef GIN_CONVERTER_H_ 5 #ifndef GIN_CONVERTER_H_
6 #define GIN_CONVERTER_H_ 6 #define GIN_CONVERTER_H_
7 7
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/logging.h" 11 #include "base/logging.h"
12 #include "base/strings/string_piece.h" 12 #include "base/strings/string_piece.h"
13 #include "gin/gin_export.h" 13 #include "gin/gin_export.h"
14 #include "v8/include/v8.h" 14 #include "v8/include/v8.h"
15 15
16 namespace gin { 16 namespace gin {
17 17
18 template<typename KeyType> 18 template<typename KeyType>
19 bool SetProperty(v8::Isolate* isolate, 19 bool SetProperty(v8::Isolate* isolate,
20 v8::Local<v8::Object> object, 20 v8::Local<v8::Object> object,
21 KeyType key, 21 KeyType key,
22 v8::Local<v8::Value> value) { 22 v8::Local<v8::Value> value) {
23 auto maybe = object->Set(isolate->GetCurrentContext(), key, value); 23 auto maybe =
24 object->DefineOwnProperty(isolate->GetCurrentContext(), key, value);
24 return !maybe.IsNothing() && maybe.FromJust(); 25 return !maybe.IsNothing() && maybe.FromJust();
25 } 26 }
26 27
27 template<typename T> 28 template<typename T>
28 struct ToV8ReturnsMaybe { 29 struct ToV8ReturnsMaybe {
29 static const bool value = false; 30 static const bool value = false;
30 }; 31 };
31 32
32 template<typename T, typename Enable = void> 33 template<typename T, typename Enable = void>
33 struct Converter {}; 34 struct Converter {};
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after
260 bool ConvertFromV8(v8::Isolate* isolate, v8::Local<v8::Value> input, 261 bool ConvertFromV8(v8::Isolate* isolate, v8::Local<v8::Value> input,
261 T* result) { 262 T* result) {
262 return Converter<T>::FromV8(isolate, input, result); 263 return Converter<T>::FromV8(isolate, input, result);
263 } 264 }
264 265
265 GIN_EXPORT std::string V8ToString(v8::Local<v8::Value> value); 266 GIN_EXPORT std::string V8ToString(v8::Local<v8::Value> value);
266 267
267 } // namespace gin 268 } // namespace gin
268 269
269 #endif // GIN_CONVERTER_H_ 270 #endif // GIN_CONVERTER_H_
OLDNEW
« no previous file with comments | « extensions/renderer/v8_helpers.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698