Chromium Code Reviews| Index: components/web_restrictions/renderer/web_restrictions_gin_wrapper.cc |
| diff --git a/components/web_restrictions/renderer/web_restrictions_gin_wrapper.cc b/components/web_restrictions/renderer/web_restrictions_gin_wrapper.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..23bfa8cde8c0f8fc39c8c0bb74199e4bc03b728d |
| --- /dev/null |
| +++ b/components/web_restrictions/renderer/web_restrictions_gin_wrapper.cc |
| @@ -0,0 +1,54 @@ |
| +// Copyright 2015 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "components/web_restrictions/renderer/web_restrictions_gin_wrapper.h" |
| + |
| +#include "content/public/renderer/render_frame.h" |
| +#include "gin/handle.h" |
| +#include "gin/object_template_builder.h" |
| +#include "third_party/WebKit/public/web/WebKit.h" |
| +#include "third_party/WebKit/public/web/WebLocalFrame.h" |
| + |
| +namespace web_restrictions { |
| + |
| +gin::WrapperInfo WebRestrictionsGinWrapper::kWrapperInfo = { |
| + gin::kEmbedderNativeGin}; |
| + |
| +// static |
| +void WebRestrictionsGinWrapper::Install(content::RenderFrame* render_frame) { |
| + v8::Isolate* isolate = blink::mainThreadIsolate(); |
| + v8::HandleScope handle_scope(isolate); |
| + v8::Local<v8::Context> context = |
| + render_frame->GetWebFrame()->mainWorldScriptContext(); |
| + if (context.IsEmpty()) |
| + return; |
| + v8::Context::Scope context_scope(context); |
| + gin::Handle<WebRestrictionsGinWrapper> controller = |
| + gin::CreateHandle(isolate, new WebRestrictionsGinWrapper(render_frame)); |
| + if (controller.IsEmpty()) |
| + return; |
| + v8::Local<v8::Object> global = context->Global(); |
| + global->Set(gin::StringToV8(isolate, "webRestriction"), controller.ToV8()); |
|
jochen (gone - plz use gerrit)
2016/02/19 14:51:21
this is put into the global namespace, why is this
Bernhard Bauer
2016/02/19 15:13:31
This is not a publicly available web platform API
|
| +} |
| + |
| +WebRestrictionsGinWrapper::WebRestrictionsGinWrapper( |
| + content::RenderFrame* render_frame) |
| + : content::RenderFrameObserver(render_frame) {} |
| + |
| +WebRestrictionsGinWrapper::~WebRestrictionsGinWrapper() {} |
| + |
| +bool WebRestrictionsGinWrapper::RequestPermission() { |
| + render_frame()->GetWebFrame()->reload(); |
| + return true; |
| +} |
| + |
| +gin::ObjectTemplateBuilder WebRestrictionsGinWrapper::GetObjectTemplateBuilder( |
| + v8::Isolate* isolate) { |
| + return gin::Wrappable<WebRestrictionsGinWrapper>::GetObjectTemplateBuilder( |
| + isolate) |
| + .SetMethod("requestPermission", |
| + &WebRestrictionsGinWrapper::RequestPermission); |
| +} |
| + |
| +} // namespace web_restrictions |