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/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" | 15 #include "chrome/common/extensions/manifest.h" |
16 #include "chrome/renderer/extensions/chrome_v8_context.h" | 16 #include "chrome/renderer/extensions/chrome_v8_context.h" |
| 17 #include "chrome/renderer/extensions/console.h" |
17 #include "chrome/renderer/extensions/dispatcher.h" | 18 #include "chrome/renderer/extensions/dispatcher.h" |
18 #include "chrome/renderer/extensions/extension_helper.h" | 19 #include "chrome/renderer/extensions/extension_helper.h" |
19 #include "content/public/renderer/v8_value_converter.h" | 20 #include "content/public/renderer/v8_value_converter.h" |
20 #include "content/public/renderer/render_view.h" | 21 #include "content/public/renderer/render_view.h" |
21 #include "grit/renderer_resources.h" | 22 #include "grit/renderer_resources.h" |
22 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h" | 23 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h" |
23 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" | 24 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" |
24 #include "v8/include/v8.h" | 25 #include "v8/include/v8.h" |
25 | 26 |
26 using WebKit::WebFrame; | 27 using WebKit::WebFrame; |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
99 return v8::ThrowException( | 100 return v8::ThrowException( |
100 v8::String::New("Argument 0 must be an object.")); | 101 v8::String::New("Argument 0 must be an object.")); |
101 } | 102 } |
102 | 103 |
103 v8::Local<v8::Context> context = | 104 v8::Local<v8::Context> context = |
104 v8::Local<v8::Object>::Cast(args[0])->CreationContext(); | 105 v8::Local<v8::Object>::Cast(args[0])->CreationContext(); |
105 CHECK(!context.IsEmpty()); | 106 CHECK(!context.IsEmpty()); |
106 | 107 |
107 WebFrame* target_frame = WebFrame::frameForContext(context); | 108 WebFrame* target_frame = WebFrame::frameForContext(context); |
108 if (!target_frame) { | 109 if (!target_frame) { |
109 return v8::ThrowException( | 110 console::Error(v8::Context::GetCalling(), |
110 v8::String::New("Could not find frame for specified object.")); | 111 "Could not find frame for specified object."); |
| 112 return v8::Undefined(); |
111 } | 113 } |
112 | 114 |
113 return GetDetailsForFrameImpl(target_frame); | 115 return GetDetailsForFrameImpl(target_frame); |
114 } | 116 } |
115 | 117 |
116 v8::Handle<v8::Value> AppBindings::GetDetailsForFrameImpl( | 118 v8::Handle<v8::Value> AppBindings::GetDetailsForFrameImpl( |
117 WebFrame* frame) { | 119 WebFrame* frame) { |
118 const Extension* extension = | 120 const Extension* extension = |
119 dispatcher_->extensions()->GetExtensionOrAppByURL( | 121 dispatcher_->extensions()->GetExtensionOrAppByURL( |
120 ExtensionURLInfo(frame->document().securityOrigin(), | 122 ExtensionURLInfo(frame->document().securityOrigin(), |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
199 v8::HandleScope handle_scope; | 201 v8::HandleScope handle_scope; |
200 v8::Context::Scope context_scope(context_->v8_context()); | 202 v8::Context::Scope context_scope(context_->v8_context()); |
201 v8::Handle<v8::Value> argv[2]; | 203 v8::Handle<v8::Value> argv[2]; |
202 argv[0] = v8::String::New(state.c_str()); | 204 argv[0] = v8::String::New(state.c_str()); |
203 argv[1] = v8::Integer::New(callback_id); | 205 argv[1] = v8::Integer::New(callback_id); |
204 CHECK(context_->CallChromeHiddenMethod("app.onInstallStateResponse", | 206 CHECK(context_->CallChromeHiddenMethod("app.onInstallStateResponse", |
205 arraysize(argv), argv, NULL)); | 207 arraysize(argv), argv, NULL)); |
206 } | 208 } |
207 | 209 |
208 } // namespace extensions | 210 } // namespace extensions |
OLD | NEW |