| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 "chrome/renderer/extensions/runtime_custom_bindings.h" | 5 #include "chrome/renderer/extensions/runtime_custom_bindings.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
| 9 #include "base/values.h" | 9 #include "base/values.h" |
| 10 #include "chrome/common/extensions/extension_messages.h" | 10 #include "chrome/common/extensions/extension_messages.h" |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 152 } else if (view_type_string != kViewTypeAll) { | 152 } else if (view_type_string != kViewTypeAll) { |
| 153 return; | 153 return; |
| 154 } | 154 } |
| 155 | 155 |
| 156 std::string extension_id = context()->GetExtensionID(); | 156 std::string extension_id = context()->GetExtensionID(); |
| 157 if (extension_id.empty()) | 157 if (extension_id.empty()) |
| 158 return; | 158 return; |
| 159 | 159 |
| 160 std::vector<content::RenderView*> views = ExtensionHelper::GetExtensionViews( | 160 std::vector<content::RenderView*> views = ExtensionHelper::GetExtensionViews( |
| 161 extension_id, browser_window_id, view_type); | 161 extension_id, browser_window_id, view_type); |
| 162 v8::Local<v8::Array> v8_views = v8::Array::New(); | 162 v8::Local<v8::Array> v8_views = v8::Array::New(args.GetIsolate()); |
| 163 int v8_index = 0; | 163 int v8_index = 0; |
| 164 for (size_t i = 0; i < views.size(); ++i) { | 164 for (size_t i = 0; i < views.size(); ++i) { |
| 165 v8::Local<v8::Context> context = | 165 v8::Local<v8::Context> context = |
| 166 views[i]->GetWebView()->mainFrame()->mainWorldScriptContext(); | 166 views[i]->GetWebView()->mainFrame()->mainWorldScriptContext(); |
| 167 if (!context.IsEmpty()) { | 167 if (!context.IsEmpty()) { |
| 168 v8::Local<v8::Value> window = context->Global(); | 168 v8::Local<v8::Value> window = context->Global(); |
| 169 DCHECK(!window.IsEmpty()); | 169 DCHECK(!window.IsEmpty()); |
| 170 v8_views->Set(v8::Integer::New(v8_index++), window); | 170 v8_views->Set(v8::Integer::New(v8_index++), window); |
| 171 } | 171 } |
| 172 } | 172 } |
| 173 | 173 |
| 174 args.GetReturnValue().Set(v8_views); | 174 args.GetReturnValue().Set(v8_views); |
| 175 } | 175 } |
| 176 | 176 |
| 177 } // namespace extensions | 177 } // namespace extensions |
| OLD | NEW |