Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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 "content/renderer/web_ui_extension.h" | 5 #include "content/renderer/web_ui_extension.h" |
| 6 | 6 |
| 7 #include "base/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
| 8 #include "base/values.h" | 8 #include "base/values.h" |
| 9 #include "content/common/view_messages.h" | 9 #include "content/common/view_messages.h" |
| 10 #include "content/public/common/bindings_policy.h" | 10 #include "content/public/common/bindings_policy.h" |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 63 void WebUIExtension::Install(blink::WebFrame* frame) { | 63 void WebUIExtension::Install(blink::WebFrame* frame) { |
| 64 v8::Isolate* isolate = blink::mainThreadIsolate(); | 64 v8::Isolate* isolate = blink::mainThreadIsolate(); |
| 65 v8::HandleScope handle_scope(isolate); | 65 v8::HandleScope handle_scope(isolate); |
| 66 v8::Handle<v8::Context> context = frame->mainWorldScriptContext(); | 66 v8::Handle<v8::Context> context = frame->mainWorldScriptContext(); |
| 67 if (context.IsEmpty()) | 67 if (context.IsEmpty()) |
| 68 return; | 68 return; |
| 69 | 69 |
| 70 v8::Context::Scope context_scope(context); | 70 v8::Context::Scope context_scope(context); |
| 71 | 71 |
| 72 v8::Handle<v8::Object> global = context->Global(); | 72 v8::Handle<v8::Object> global = context->Global(); |
| 73 v8::Handle<v8::Object> chrome = | 73 v8::Handle<v8::Object> chrome; |
| 74 global->Get(gin::StringToV8(isolate, "chrome"))->ToObject(); | 74 v8::Handle<v8::Value> chrome_value = |
| 75 if (chrome.IsEmpty()) { | 75 global->Get(gin::StringToV8(isolate, "chrome")); |
| 76 if (chrome_value.IsEmpty() || !chrome_value->IsObject()) { | |
|
Mike West
2014/09/30 07:51:46
Please adjust skia_benchmarking_extension and memo
| |
| 76 chrome = v8::Object::New(isolate); | 77 chrome = v8::Object::New(isolate); |
| 77 global->Set(gin::StringToSymbol(isolate, "chrome"), chrome); | 78 global->Set(gin::StringToSymbol(isolate, "chrome"), chrome); |
| 79 } else { | |
| 80 chrome = chrome_value->ToObject(); | |
| 78 } | 81 } |
| 79 chrome->Set(gin::StringToSymbol(isolate, "send"), | 82 chrome->Set(gin::StringToSymbol(isolate, "send"), |
| 80 gin::CreateFunctionTemplate( | 83 gin::CreateFunctionTemplate( |
| 81 isolate, base::Bind(&WebUIExtension::Send))->GetFunction()); | 84 isolate, base::Bind(&WebUIExtension::Send))->GetFunction()); |
| 82 chrome->Set(gin::StringToSymbol(isolate, "getVariableValue"), | 85 chrome->Set(gin::StringToSymbol(isolate, "getVariableValue"), |
| 83 gin::CreateFunctionTemplate( | 86 gin::CreateFunctionTemplate( |
| 84 isolate, base::Bind(&WebUIExtension::GetVariableValue)) | 87 isolate, base::Bind(&WebUIExtension::GetVariableValue)) |
| 85 ->GetFunction()); | 88 ->GetFunction()); |
| 86 } | 89 } |
| 87 | 90 |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 131 std::string WebUIExtension::GetVariableValue(const std::string& name) { | 134 std::string WebUIExtension::GetVariableValue(const std::string& name) { |
| 132 blink::WebFrame* frame; | 135 blink::WebFrame* frame; |
| 133 RenderView* render_view; | 136 RenderView* render_view; |
| 134 if (!ShouldRespondToRequest(&frame, &render_view)) | 137 if (!ShouldRespondToRequest(&frame, &render_view)) |
| 135 return std::string(); | 138 return std::string(); |
| 136 | 139 |
| 137 return WebUIExtensionData::Get(render_view)->GetValue(name); | 140 return WebUIExtensionData::Get(render_view)->GetValue(name); |
| 138 } | 141 } |
| 139 | 142 |
| 140 } // namespace content | 143 } // namespace content |
| OLD | NEW |