OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/app_bindings.h" | 5 #include "chrome/renderer/extensions/app_bindings.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/string16.h" | 8 #include "base/string16.h" |
9 #include "base/string_util.h" | 9 #include "base/string_util.h" |
10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
11 #include "base/values.h" | 11 #include "base/values.h" |
12 #include "chrome/common/chrome_switches.h" | 12 #include "chrome/common/chrome_switches.h" |
13 #include "chrome/common/extensions/extension_messages.h" | 13 #include "chrome/common/extensions/extension_messages.h" |
14 #include "chrome/common/extensions/extension_set.h" | 14 #include "chrome/common/extensions/extension_set.h" |
15 #include "chrome/common/extensions/manifest.h" | |
16 #include "chrome/renderer/extensions/chrome_v8_context.h" | 15 #include "chrome/renderer/extensions/chrome_v8_context.h" |
17 #include "chrome/renderer/extensions/extension_dispatcher.h" | 16 #include "chrome/renderer/extensions/extension_dispatcher.h" |
18 #include "chrome/renderer/extensions/extension_helper.h" | 17 #include "chrome/renderer/extensions/extension_helper.h" |
19 #include "content/public/renderer/v8_value_converter.h" | 18 #include "content/public/renderer/v8_value_converter.h" |
20 #include "content/public/renderer/render_view.h" | 19 #include "content/public/renderer/render_view.h" |
21 #include "grit/renderer_resources.h" | 20 #include "grit/renderer_resources.h" |
22 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h" | 21 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h" |
23 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" | 22 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" |
24 #include "v8/include/v8.h" | 23 #include "v8/include/v8.h" |
25 | 24 |
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
188 | 187 |
189 v8::Handle<v8::Value> AppBindingsHandler::GetDetailsForFrameImpl( | 188 v8::Handle<v8::Value> AppBindingsHandler::GetDetailsForFrameImpl( |
190 WebFrame* frame) { | 189 WebFrame* frame) { |
191 const ::Extension* extension = dispatcher_->extensions()->GetByURL( | 190 const ::Extension* extension = dispatcher_->extensions()->GetByURL( |
192 ExtensionURLInfo(frame->document().securityOrigin(), | 191 ExtensionURLInfo(frame->document().securityOrigin(), |
193 frame->document().url())); | 192 frame->document().url())); |
194 if (!extension) | 193 if (!extension) |
195 return v8::Null(); | 194 return v8::Null(); |
196 | 195 |
197 scoped_ptr<DictionaryValue> manifest_copy( | 196 scoped_ptr<DictionaryValue> manifest_copy( |
198 extension->manifest()->value()->DeepCopy()); | 197 extension->manifest_value()->DeepCopy()); |
199 manifest_copy->SetString("id", extension->id()); | 198 manifest_copy->SetString("id", extension->id()); |
200 scoped_ptr<V8ValueConverter> converter(V8ValueConverter::create()); | 199 scoped_ptr<V8ValueConverter> converter(V8ValueConverter::create()); |
201 return converter->ToV8Value(manifest_copy.get(), | 200 return converter->ToV8Value(manifest_copy.get(), |
202 frame->mainWorldScriptContext()); | 201 frame->mainWorldScriptContext()); |
203 } | 202 } |
204 | 203 |
205 v8::Handle<v8::Value> AppBindingsHandler::GetAppNotifyChannel( | 204 v8::Handle<v8::Value> AppBindingsHandler::GetAppNotifyChannel( |
206 const v8::Arguments& args) { | 205 const v8::Arguments& args) { |
207 // Read the required 'clientId' value out of the object at args[0]. | 206 // Read the required 'clientId' value out of the object at args[0]. |
208 std::string client_id; | 207 std::string client_id; |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
254 const std::string& channel_id, const std::string& error, int callback_id) { | 253 const std::string& channel_id, const std::string& error, int callback_id) { |
255 v8::HandleScope handle_scope; | 254 v8::HandleScope handle_scope; |
256 v8::Context::Scope context_scope(context_->v8_context()); | 255 v8::Context::Scope context_scope(context_->v8_context()); |
257 v8::Handle<v8::Value> argv[3]; | 256 v8::Handle<v8::Value> argv[3]; |
258 argv[0] = v8::String::New(channel_id.c_str()); | 257 argv[0] = v8::String::New(channel_id.c_str()); |
259 argv[1] = v8::String::New(error.c_str()); | 258 argv[1] = v8::String::New(error.c_str()); |
260 argv[2] = v8::Integer::New(callback_id); | 259 argv[2] = v8::Integer::New(callback_id); |
261 CHECK(context_->CallChromeHiddenMethod("app.onGetAppNotifyChannelResponse", | 260 CHECK(context_->CallChromeHiddenMethod("app.onGetAppNotifyChannelResponse", |
262 arraysize(argv), argv, NULL)); | 261 arraysize(argv), argv, NULL)); |
263 } | 262 } |
OLD | NEW |