mesa gn build: suppress -Wstring-conversion warnings
[chromium-blink-merge.git] / content / renderer / chrome_object_extensions_utils.cc
blobfe78ecc26d5b0a3bddfc18179b88b074932e70ed
1 // Copyright (c) 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "content/renderer/chrome_object_extensions_utils.h"
7 #include "gin/converter.h"
8 #include "v8/include/v8.h"
10 namespace content {
12 v8::Handle<v8::Object> GetOrCreateChromeObject(
13 v8::Isolate* isolate, v8::Handle<v8::Object> global) {
14 v8::Handle<v8::Object> chrome;
15 v8::Handle<v8::Value> chrome_value =
16 global->Get(gin::StringToV8(isolate, "chrome"));
17 if (chrome_value.IsEmpty() || !chrome_value->IsObject()) {
18 chrome = v8::Object::New(isolate);
19 global->Set(gin::StringToSymbol(isolate, "chrome"), chrome);
20 } else {
21 chrome = v8::Handle<v8::Object>::Cast(chrome_value);
23 return chrome;
26 } // namespace content