OLD | NEW |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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 #include "chrome/renderer/sandbox_status_extension_android.h" | 5 #include "chrome/renderer/sandbox_status_extension_android.h" |
6 | 6 |
7 #include "base/android/build_info.h" | 7 #include "base/android/build_info.h" |
8 #include "base/bind.h" | 8 #include "base/bind.h" |
9 #include "base/files/file_util.h" | 9 #include "base/files/file_util.h" |
10 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
68 v8::HandleScope handle_scope(isolate); | 68 v8::HandleScope handle_scope(isolate); |
69 v8::Local<v8::Context> context = | 69 v8::Local<v8::Context> context = |
70 render_frame()->GetWebFrame()->MainWorldScriptContext(); | 70 render_frame()->GetWebFrame()->MainWorldScriptContext(); |
71 if (context.IsEmpty()) | 71 if (context.IsEmpty()) |
72 return; | 72 return; |
73 | 73 |
74 v8::Context::Scope context_scope(context); | 74 v8::Context::Scope context_scope(context); |
75 | 75 |
76 v8::Local<v8::Object> chrome = | 76 v8::Local<v8::Object> chrome = |
77 content::GetOrCreateChromeObject(isolate, context->Global()); | 77 content::GetOrCreateChromeObject(isolate, context->Global()); |
78 DCHECK(chrome->Set( | 78 bool success = chrome->Set( |
79 gin::StringToSymbol(isolate, "getAndroidSandboxStatus"), | 79 gin::StringToSymbol(isolate, "getAndroidSandboxStatus"), |
80 gin::CreateFunctionTemplate( | 80 gin::CreateFunctionTemplate( |
81 isolate, base::Bind(&SandboxStatusExtension::GetSandboxStatus, this)) | 81 isolate, base::Bind(&SandboxStatusExtension::GetSandboxStatus, this)) |
82 ->GetFunction())); | 82 ->GetFunction()); |
| 83 DCHECK(success); |
83 } | 84 } |
84 | 85 |
85 void SandboxStatusExtension::GetSandboxStatus(gin::Arguments* args) { | 86 void SandboxStatusExtension::GetSandboxStatus(gin::Arguments* args) { |
86 if (!render_frame()) | 87 if (!render_frame()) |
87 return; | 88 return; |
88 | 89 |
89 if (render_frame()->GetWebFrame()->GetSecurityOrigin().Host() != | 90 if (render_frame()->GetWebFrame()->GetSecurityOrigin().Host() != |
90 chrome::kChromeUISandboxHost) { | 91 chrome::kChromeUISandboxHost) { |
91 args->ThrowTypeError("Not allowed on this origin"); | 92 args->ThrowTypeError("Not allowed on this origin"); |
92 return; | 93 return; |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
147 v8::Local<v8::Function> callback_local = | 148 v8::Local<v8::Function> callback_local = |
148 v8::Local<v8::Function>::New(isolate, *callback); | 149 v8::Local<v8::Function>::New(isolate, *callback); |
149 | 150 |
150 std::unique_ptr<content::V8ValueConverter> converter( | 151 std::unique_ptr<content::V8ValueConverter> converter( |
151 content::V8ValueConverter::create()); | 152 content::V8ValueConverter::create()); |
152 | 153 |
153 v8::Local<v8::Value> argv[] = {converter->ToV8Value(status.get(), context)}; | 154 v8::Local<v8::Value> argv[] = {converter->ToV8Value(status.get(), context)}; |
154 render_frame()->GetWebFrame()->CallFunctionEvenIfScriptDisabled( | 155 render_frame()->GetWebFrame()->CallFunctionEvenIfScriptDisabled( |
155 callback_local, v8::Object::New(isolate), 1, argv); | 156 callback_local, v8::Object::New(isolate), 1, argv); |
156 } | 157 } |
OLD | NEW |