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

Side by Side Diff: components/web_restriction/web_restriction_gin_wrapper.cc

Issue 1423713015: [WIP] WebRestrictions (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: continue review in split cl Created 4 years, 11 months 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
OLDNEW
(Empty)
1 // Copyright 2015 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 "components/web_restriction/web_restriction_gin_wrapper.h"
6
7 #include "content/public/renderer/render_frame.h"
8 #include "gin/handle.h"
9 #include "gin/object_template_builder.h"
10 #include "third_party/WebKit/public/web/WebKit.h"
11 #include "third_party/WebKit/public/web/WebLocalFrame.h"
12
13 namespace web_restriction {
14
15 gin::WrapperInfo WebRestrictionGinWrapper::kWrapperInfo = {
16 gin::kEmbedderNativeGin};
17
18 // static
19 void WebRestrictionGinWrapper::Install(content::RenderFrame* render_frame) {
20 v8::Isolate* isolate = blink::mainThreadIsolate();
21 v8::HandleScope handle_scope(isolate);
22 v8::Local<v8::Context> context =
23 render_frame->GetWebFrame()->mainWorldScriptContext();
24 if (context.IsEmpty())
25 return;
26 v8::Context::Scope context_scope(context);
27 gin::Handle<WebRestrictionGinWrapper> controller =
28 gin::CreateHandle(isolate, new WebRestrictionGinWrapper(render_frame));
29 if (controller.IsEmpty())
30 return;
31 v8::Local<v8::Object> global = context->Global();
32 global->Set(gin::StringToV8(isolate, "webRestriction"), controller.ToV8());
33 }
34
35 WebRestrictionGinWrapper::WebRestrictionGinWrapper(
36 content::RenderFrame* render_frame)
37 : render_frame_(render_frame) {}
38
39 WebRestrictionGinWrapper::~WebRestrictionGinWrapper() {}
40
41 bool WebRestrictionGinWrapper::RequestPermission() {
42 render_frame_->GetWebFrame()->reload();
43 return true;
44 }
45
46 gin::ObjectTemplateBuilder WebRestrictionGinWrapper::GetObjectTemplateBuilder(
47 v8::Isolate* isolate) {
48 return gin::Wrappable<WebRestrictionGinWrapper>::GetObjectTemplateBuilder(
49 isolate)
50 .SetMethod("requestPermission",
51 &WebRestrictionGinWrapper::RequestPermission);
52 }
53
54 } // namespace web_restriction
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698