blob: d023d29e51d7e462622e8a1a9104c0c0458c5c3b [file] [log] [blame]
kolczyke1b79c752014-10-01 10:06:561// 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.
4
5#include "content/renderer/chrome_object_extensions_utils.h"
6
7#include "gin/converter.h"
8#include "v8/include/v8.h"
9
10namespace content {
11
deepak.s750d68f2015-04-30 07:32:4112v8::Local<v8::Object> GetOrCreateChromeObject(
13 v8::Isolate* isolate, v8::Local<v8::Object> global) {
14 v8::Local<v8::Object> chrome;
15 v8::Local<v8::Value> chrome_value =
kolczyke1b79c752014-10-01 10:06:5616 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 {
deepak.s750d68f2015-04-30 07:32:4121 chrome = v8::Local<v8::Object>::Cast(chrome_value);
kolczyke1b79c752014-10-01 10:06:5622 }
23 return chrome;
24}
25
26} // namespace content